import type { Criticality, HealthStatus } from "./api"; import type { Panel } from "./routing/urlState"; /** The UI speaks Belgian Dutch and shows times in Brussels, whatever the browser says. */ export const LOCALE = "nl-BE"; export const TIME_ZONE = "Europe/Brussels"; export const STATUS_LABELS: Record = { healthy: "Gezond", degraded: "Verminderd", down: "Uitgevallen", recovering: "Herstellend", maintenance: "Onderhoud", unknown: "Onbekend", unmonitored: "Niet bewaakt", }; export const statusText = (status: HealthStatus): string => STATUS_LABELS[status] ?? status; const CRITICALITY_LABELS: Record = { low: "laag", medium: "gemiddeld", high: "hoog", critical: "kritiek", }; export const criticalityText = (value: string): string => CRITICALITY_LABELS[value as Criticality] ?? value; const LIFECYCLE_LABELS: Record = { active: "actief", missing: "ontbrekend", stale: "verouderd", retired: "uitgefaseerd", ignored: "genegeerd", }; export const lifecycleText = (value: string): string => LIFECYCLE_LABELS[value] ?? value; export const MONITORING_LABELS: Record = { active_probe: "Actieve controle", docker_health: "Docker-gezondheid", appops_observation: "Waargenomen via AppOps", observed: "Runtime waargenomen", unmonitored: "Niet bewaakt", disabled: "Bewaking uitgeschakeld", }; const PROVIDER_LABELS: Record = { active_probe: "Actieve controle", docker: "Docker", appops: "AppOps", runtime: "Runtime", manual: "Handmatig", }; export const providerText = (value: string): string => PROVIDER_LABELS[value] ?? value.replace("_", " "); const PROVIDER_HEALTH_LABELS: Record = { healthy: "gezond", degraded: "verminderd", unavailable: "niet beschikbaar", unknown: "onbekend", }; export const providerHealthText = (value: string): string => PROVIDER_HEALTH_LABELS[value] ?? value; export const PANEL_LABELS: Record = { overview: "Overzicht", topology: "Topologie", incidents: "Incidenten", services: "Services", discovery: "Detectie", changes: "Wijzigingen", activity: "Activiteit", config: "Configuratie", settings: "Instellingen", }; const MODE_LABELS: Record = { landscape: "Landschap", dependencies: "Afhankelijkheden", impact: "Impact", }; export const modeText = (mode: string): string => MODE_LABELS[mode] ?? mode; /** 19-11-2026 21:19:00 in Brussels time. */ export function formatDateTime(value: string | Date): string { return new Date(value).toLocaleString(LOCALE, { timeZone: TIME_ZONE, dateStyle: "short", timeStyle: "medium" }); } /** 21:19 in Brussels time. */ export function formatTime(value: string | Date): string { return new Date(value).toLocaleTimeString(LOCALE, { timeZone: TIME_ZONE, hour: "2-digit", minute: "2-digit" }); } /** "donderdag 19 november 2026" in Brussels time. */ export function formatDay(value: string | Date): string { return new Date(value).toLocaleDateString(LOCALE, { timeZone: TIME_ZONE, weekday: "long", day: "numeric", month: "long", year: "numeric", }); } /** Calendar day in Brussels, as a sortable key. */ export function dayKey(value: string | Date): string { return new Intl.DateTimeFormat("en-CA", { timeZone: TIME_ZONE, year: "numeric", month: "2-digit", day: "2-digit" }).format( new Date(value), ); } /** 99,5 with a decimal comma. */ export function formatNumber(value: number, digits = 0): string { return value.toLocaleString(LOCALE, { minimumFractionDigits: digits, maximumFractionDigits: digits }); }