// apps/web/src/server/notifications/render.ts
import type { NotifEvent } from './event-registry.js';
import { en } from '@/lib/i18n/en.js';
import { he } from '@/lib/i18n/he.js';

/**
 * Look up the title string for a notification event in both locales.
 * Keys live in the `notif` namespace as `event.<event-id>`.
 */
export function renderTitle(event: NotifEvent, _data: unknown): { he: string; en: string } {
  const k = `event.${event}` as keyof typeof he.notif;
  return {
    he: (he.notif as Record<string, string>)[k as string] ?? event,
    en: (en.notif as Record<string, string>)[k as string] ?? event,
  };
}

/**
 * Look up the body string for a notification event in both locales.
 * Keys live in the `notif` namespace as `body.<event-id>`.
 * Returns null when no body key is registered (most events have no body).
 */
export function renderBody(
  event: NotifEvent,
  _data: unknown,
): { he: string | null; en: string | null } {
  const k = `body.${event}` as string;
  return {
    he: (he.notif as Record<string, string>)[k] ?? null,
    en: (en.notif as Record<string, string>)[k] ?? null,
  };
}
