fix(vigilance): désactiver onglet J+1 si absent du bulletin
All checks were successful
Deploy info-canicule / deploy (push) Successful in 1m29s
All checks were successful
Deploy info-canicule / deploy (push) Successful in 1m29s
- Ajoute `hasJ1Period()` — source de vérité réelle au lieu de s'appuyer sur l'heure de publication (fixe 6h/16h non fiable, bulletins constatés à 23h et 00h01). - Home : `tomorrowAvailable` conditionné à `hasJ1Period(snapshot)` en plus de `currentEcheance === 'J'`. - Dept : `j1Available` pilote la colonne Demain du tableau de comparaison et le calcul `tomorrowColor`/`changed`. - Tooltip J+1 désactivé : suppression de la mention "vers 6h". - cache.ts / vigilance.ts : `bulletinIsSuperseded` + refresh sync via `shouldRevalidateSync` (pré-existant, inclus dans le push). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
29c1151fea
commit
759cda8ea9
4 changed files with 78 additions and 19 deletions
|
|
@ -1,7 +1,7 @@
|
|||
---
|
||||
import Base from '../../layouts/Base.astro';
|
||||
import VigilanceChip from '../../components/VigilanceChip.astro';
|
||||
import { getVigilanceSnapshot, alertsForDepartement, currentEcheance } from '../../lib/vigilance';
|
||||
import { getVigilanceSnapshot, alertsForDepartement, currentEcheance, hasJ1Period } from '../../lib/vigilance';
|
||||
import { getDepartement, isDrom } from '../../lib/departements';
|
||||
import { PHENOMENA, COLOR_LABEL, COLORS } from '../../lib/phenomena';
|
||||
import type { PhenomenonId, ColorId } from '../../lib/phenomena';
|
||||
|
|
@ -77,8 +77,9 @@ if (!drom) {
|
|||
const stationLabel = hourly ? `${hourly.stationName} (${hourly.distKm} km)` : null;
|
||||
|
||||
const ech = snapshot ? currentEcheance(snapshot) : 'J';
|
||||
const j1Available = snapshot ? (ech === 'J' && hasJ1Period(snapshot)) : false;
|
||||
const today = snapshot ? alertsForDepartement(snapshot, dept.code, ech) : [];
|
||||
const tomorrow = (snapshot && ech === 'J') ? alertsForDepartement(snapshot, dept.code, 'J1') : [];
|
||||
const tomorrow = j1Available ? alertsForDepartement(snapshot!, dept.code, 'J1') : [];
|
||||
|
||||
// Sort by severity desc, pick top alert for the hero block
|
||||
const sortedToday = [...today].sort((a, b) => b.colorId - a.colorId);
|
||||
|
|
@ -108,8 +109,8 @@ const comparisonRows = PHENOM_IDS.map((id) => ({
|
|||
id,
|
||||
phen: PHENOMENA[id],
|
||||
todayColor: (todayByPhenom.get(id) ?? 1) as ColorId,
|
||||
tomorrowColor: ech === 'J' ? ((tomorrowByPhenom.get(id) ?? 1) as ColorId) : null,
|
||||
changed: ech === 'J' && (todayByPhenom.get(id) ?? 1) !== (tomorrowByPhenom.get(id) ?? 1),
|
||||
tomorrowColor: j1Available ? ((tomorrowByPhenom.get(id) ?? 1) as ColorId) : null,
|
||||
changed: j1Available && (todayByPhenom.get(id) ?? 1) !== (tomorrowByPhenom.get(id) ?? 1),
|
||||
}));
|
||||
|
||||
// Phenomena with no active alert today (green)
|
||||
|
|
@ -283,7 +284,7 @@ const topPhen = topAlert ? PHENOMENA[topAlert.phenomenonId] : null;
|
|||
)}
|
||||
|
||||
{/* Today vs Tomorrow comparison */}
|
||||
{(today.length > 0 || tomorrow.length > 0 || ech === 'J') && (
|
||||
{(today.length > 0 || tomorrow.length > 0 || j1Available) && (
|
||||
<div class="ic-card" style="margin-bottom: 28px; overflow-x: auto;">
|
||||
<h3 style="margin-bottom: 16px;">
|
||||
Aujourd'hui{todayLabel ? ` — ${todayLabel}` : ''} vs Demain{tomorrowLabel ? ` — ${tomorrowLabel}` : ''}
|
||||
|
|
@ -291,7 +292,7 @@ const topPhen = topAlert ? PHENOMENA[topAlert.phenomenonId] : null;
|
|||
<div class="comparison-grid" style="display: grid; grid-template-columns: 1.5fr 1fr 1fr; gap: 6px 12px; align-items: center; min-width: 360px;">
|
||||
<span class="kicker">Phénomène</span>
|
||||
<span class="kicker" style="text-align: center;">Aujourd'hui</span>
|
||||
{ech === 'J'
|
||||
{j1Available
|
||||
? <span class="kicker" style="text-align: center;">Demain</span>
|
||||
: <span class="kicker" style="text-align: center; opacity: 0.4;">Demain</span>
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue