Give every notification event type words to render

The matrix derives each row's label from the event name, so a new event
type gets a row whether or not anybody wrote the strings for it. That is
how SECURITY_ALERT has been rendering its own raw key since v1.23: the
forward i18n coverage test only sees literal call sites, and this key is
assembled from a runtime value.

Move the derivation out of the page so a test can compute the keys the
page computes, assert both resolve in all six bundles, and name the
missing one. Write the sign-in row's strings, and the strings for the
delegated-dose row and its push body.
This commit is contained in:
Marc-André Bombeck committed 2026-08-03 09:51:53 +02:00
1 parent 427e25d1ae
commit 696b4d7d1c
9 files changed
+202 -13

No files matched your search

+6 -13
View File
@@ -15,6 +15,10 @@ import {
EVENT_DEFAULT_ENABLED,
type EventType,
} from "@/lib/notifications/types";
import {
eventDescriptionTranslationKey,
eventTranslationKey,
} from "@/lib/notifications/event-labels";
import { queryKeys } from "@/lib/query-keys";
import { apiGet, apiPut } from "@/lib/api/api-fetch";
@@ -38,17 +42,6 @@ interface PreferencesData {
eventTypes: string[];
}
/** Maps SCREAMING_SNAKE event type to translation key, e.g. MEDICATION_REMINDER → eventMedicationReminder */
function eventTranslationKey(eventType: string): string {
return (
"notifications.event" +
eventType
.toLowerCase()
.replace(/_([a-z])/g, (_, c: string) => c.toUpperCase())
.replace(/^./, (c) => c.toUpperCase())
);
}
export default function NotificationsPage() {
const { isAuthenticated, isLoading: authLoading } = useAuth();
const { t } = useTranslations();
@@ -265,7 +258,7 @@ export default function NotificationsPage() {
<tbody>
{eventTypes.map((eventType, idx) => {
const nameKey = eventTranslationKey(eventType);
const descKey = nameKey + "Desc";
const descKey = eventDescriptionTranslationKey(eventType);
return (
<tr
key={eventType}
@@ -311,7 +304,7 @@ export default function NotificationsPage() {
<div className="space-y-4 md:hidden">
{eventTypes.map((eventType) => {
const nameKey = eventTranslationKey(eventType);
const descKey = nameKey + "Desc";
const descKey = eventDescriptionTranslationKey(eventType);
return (
<div
key={eventType}