fix: Veille/ambre uniquement si sargasses à <100km, "banc" au lieu de "patch"

- 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 <noreply@anthropic.com>
This commit is contained in:
Gwadaking
2026-04-08 02:25:51 -04:00
parent 0d47a7ee89
commit a607fd3c99
2 changed files with 19 additions and 16 deletions

View File

@@ -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 (
<div className={`spot-panel__eta ${eta.cls}`}>
<span className="spot-panel__eta-icon">{eta.icon}</span>
@@ -111,7 +112,7 @@ export default function SpotPanel({ spot, activeStep, onClose }) {
<div className={`spot-panel__gauge gauge--${lvl}`}>
<p className="spot-panel__gauge-header">Indice de risque</p>
<span className="spot-panel__gauge-label">{scoreLabel(displayScore.value, lvl)}</span>
<span className="spot-panel__gauge-label">{scoreLabel(displayScore.value, lvl, displayScore.distance)}</span>
<div className="spot-panel__gauge-track">
<div
className="spot-panel__gauge-fill"
@@ -164,7 +165,7 @@ function PatchList({ patches }) {
return (
<div className="patch-list">
<p className="patch-list__title">
{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' : ''}
</p>
{patches.map((p, i) => {
const pct = Math.min((p.distanceKm / MAX_KM) * 100, 100);