From a607fd3c99c33b3f0cb920fcca5209dd37b25f27 Mon Sep 17 00:00:00 2001 From: Gwadaking Date: Wed, 8 Apr 2026 02:25:51 -0400 Subject: [PATCH] =?UTF-8?q?fix:=20Veille/ambre=20uniquement=20si=20sargass?= =?UTF-8?q?es=20=C3=A0=20<100km,=20"banc"=20au=20lieu=20de=20"patch"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - scoreLabel/etaLabel/SpotMarker conditionnent Veille à distance<100km pour éviter l'alerte ambre sur les spots sans sargasses proches - "patch" → "banc de sargasses" dans le SpotPanel Co-Authored-By: Claude Sonnet 4.6 --- frontend/src/components/Map/SargassesMap.jsx | 14 +++++++------ .../src/components/SpotPanel/SpotPanel.jsx | 21 ++++++++++--------- 2 files changed, 19 insertions(+), 16 deletions(-) diff --git a/frontend/src/components/Map/SargassesMap.jsx b/frontend/src/components/Map/SargassesMap.jsx index a8cc8f3..503087a 100644 --- a/frontend/src/components/Map/SargassesMap.jsx +++ b/frontend/src/components/Map/SargassesMap.jsx @@ -98,7 +98,7 @@ const makeLayerStyles = (isPrediction, opacity) => ({ }); // ── SVG Markers ─────────────────────────────────────────────────────────── -function SpotMarker({ level, scoreValue, isSelected, name }) { +function SpotMarker({ level, scoreValue, scoreDist, isSelected, name }) { const size = isSelected ? 36 : 28; const shadow = 'filter: drop-shadow(2px 3px 0px rgba(0,0,0,0.35))'; @@ -123,7 +123,7 @@ function SpotMarker({ level, scoreValue, isSelected, name }) { ); if (level === 'low') { - const isWatch = (scoreValue ?? 0) >= 15; + const isWatch = (scoreValue ?? 0) >= 15 && scoreDist != null && scoreDist < 100; return (
@@ -193,9 +193,10 @@ export default function SargassesMap({ onSpotSelect, selectedSpotId, activeStep, spots.forEach(s => { api.spots.score(s.id) .then(d => { - const level = d?.score?.level; - const value = d?.score?.value ?? 0; - if (level) setSpotScores(prev => ({ ...prev, [s.id]: { level, value } })); + const level = d?.score?.level; + const value = d?.score?.value ?? 0; + const distance = d?.score?.distance ?? null; + if (level) setSpotScores(prev => ({ ...prev, [s.id]: { level, value, distance } })); }) .catch(() => {}); }); @@ -299,6 +300,7 @@ export default function SargassesMap({ onSpotSelect, selectedSpotId, activeStep, const sc = spotScores[spot.id]; const level = sc?.level; const scoreValue = sc?.value ?? 0; + const scoreDist = sc?.distance ?? null; return ( onSpotSelect(spot)} > - + ); })} diff --git a/frontend/src/components/SpotPanel/SpotPanel.jsx b/frontend/src/components/SpotPanel/SpotPanel.jsx index fb77a66..0c3051d 100644 --- a/frontend/src/components/SpotPanel/SpotPanel.jsx +++ b/frontend/src/components/SpotPanel/SpotPanel.jsx @@ -3,10 +3,10 @@ import { api } from '../../api/client'; import usePushSubscription from '../../hooks/usePushSubscription'; import './SpotPanel.css'; -function scoreLabel(value, level) { - if (level === 'high') return 'Impact'; - if (level === 'medium') return 'Risque'; - if (value >= 15) return 'Veille'; +function scoreLabel(value, level, distance) { + if (level === 'high') return 'Impact'; + if (level === 'medium') return 'Risque'; + if (value >= 15 && distance != null && distance < 100) return 'Veille'; return 'OK'; } const TYPE_ICON = { beach: '🏖', port: '⚓', surf: '🏄', fishing: '🎣' }; @@ -28,14 +28,15 @@ function computeEta(score, horizons) { return null; } -function etaLabel(etaHours, score) { +function etaLabel(etaHours, score, distance) { if (etaHours === 0) return { icon: '🚨', label: 'Impact en cours', cls: 'eta--now' }; if (etaHours === 6) return { icon: '⚠️', label: 'Impact prévu dans ~6h', cls: 'eta--soon' }; if (etaHours === 12) return { icon: '⚠️', label: 'Impact prévu dans ~12h', cls: 'eta--soon' }; if (etaHours === 24) return { icon: '🕐', label: 'Impact prévu dans ~24h', cls: 'eta--later' }; if (etaHours === 48) return { icon: '🕐', label: 'Impact prévu dans ~48h', cls: 'eta--later' }; - if ((score ?? 0) >= 15) return { icon: '👁', label: 'Sargasses en surveillance', cls: 'eta--watch' }; - return { icon: '✅', label: 'Aucun impact prévu (48h)', cls: 'eta--safe' }; + if ((score ?? 0) >= 15 && distance != null && distance < 100) + return { icon: '👁', label: 'Sargasses en surveillance', cls: 'eta--watch' }; + return { icon: '✅', label: 'Aucun impact prévu (48h)', cls: 'eta--safe' }; } const HORIZON_LABELS = { now: 'Maintenant', h6: '+6h', h12: '+12h', h24: '+24h', h48: '+48h' }; @@ -100,7 +101,7 @@ export default function SpotPanel({ spot, activeStep, onClose }) { : ( <> {activeStep === 'now' && (() => { - const eta = etaLabel(computeEta(data?.score, data?.horizons), data?.score?.value); + const eta = etaLabel(computeEta(data?.score, data?.horizons), data?.score?.value, data?.score?.distance); return (
{eta.icon} @@ -111,7 +112,7 @@ export default function SpotPanel({ spot, activeStep, onClose }) {

Indice de risque

- {scoreLabel(displayScore.value, lvl)} + {scoreLabel(displayScore.value, lvl, displayScore.distance)}

- {patches.length} patch{patches.length > 1 ? 'es' : ''} détecté{patches.length > 1 ? 's' : ''} + {patches.length} banc{patches.length > 1 ? 's' : ''} de sargasses détecté{patches.length > 1 ? 's' : ''}

{patches.map((p, i) => { const pct = Math.min((p.distanceKm / MAX_KM) * 100, 100);