feat: add time-dependent Europe/Brussels dashboard greeting

The dashboard greeting was a fully static "Goedemorgen..." regardless of
actual time of day. New frontend/src/i18n/greeting.ts::getGreetingPeriod
is a pure, clock-injectable function resolving one of 4 periods (05:00-
11:59 morning, 12:00-17:59 afternoon, 18:00-22:59 evening, 23:00-04:59
night) against Europe/Brussels wall-clock time via
Intl.DateTimeFormat({ timeZone, hourCycle: "h23" }), which is DST-safe
by construction.

useGreetingPeriod.ts wires this into React with a 30s poll so the
greeting rolls over live while the app stays open, no reload required.
Each period now has its own greeting word and accompanying sentence in
all 3 languages (dashboard.json), replacing both the fixed "Goedemorgen"
and the fixed "Here's the fleet" follow-up sentence. Night never says
"Goedenacht" (used as a farewell, not a welcome, in Dutch).
This commit is contained in:
NuklearRabbit
2026-08-04 03:08:45 +02:00
parent d17af1c52a
commit e427313bce
8 changed files with 266 additions and 4 deletions
+23
View File
@@ -0,0 +1,23 @@
import { useEffect, useState } from "react";
import { getGreetingPeriod, type GreetingPeriod } from "./greeting";
// Checked frequently enough that a period rollover (e.g. 11:59 -> 12:00) is picked up
// within the Dashboard while the app stays open, without a page reload -- see section 9
// of the Fleet Ops final localization brief.
const CHECK_INTERVAL_MS = 30_000;
export function useGreetingPeriod(): GreetingPeriod {
const [period, setPeriod] = useState<GreetingPeriod>(() => getGreetingPeriod());
useEffect(() => {
const id = setInterval(() => {
setPeriod((current) => {
const next = getGreetingPeriod();
return next === current ? current : next;
});
}, CHECK_INTERVAL_MS);
return () => clearInterval(id);
}, []);
return period;
}