import { Check, Lock, Minus, UsersRound } from 'lucide-react' import type { NotificationDefault } from '@trek/shared' import { useTranslation } from '../../i18n' import { Tooltip } from '../../components/shared/Tooltip' import { SettingsCard } from '../../components/Settings/settingsKit' import { fs } from '../../components/shared/DialogShell' import { EVENT_LABEL_KEYS, channelLabel } from '../../components/Settings/notificationLabels' import { useNotificationDefaults } from './useNotificationDefaults' const NEXT: Record = { on: 'off', off: 'blocked', blocked: 'on' } const ICON = { on: Check, off: Minus, blocked: Lock } as const const TONE: Record = { on: 'bg-accent text-accent-text border-transparent', off: 'bg-surface-card text-content-muted border-edge', blocked: 'bg-danger-soft text-danger border-transparent', } const LABEL_KEYS: Record = { on: 'admin.notificationDefaults.on', off: 'admin.notificationDefaults.off', blocked: 'admin.notificationDefaults.blocked', } /** * What every user's notification cells start as (#1536). One cell per event and * channel, cycling On → Off → Blocked: Off is a default each user may still turn * on, Blocked is off for everyone and shows as locked in their settings. */ export default function AdminNotificationDefaultsPanel() { const { t } = useTranslation() const { matrix, saving, cycle } = useNotificationDefaults() if (!matrix) return null const channels = matrix.channels.filter(ch => matrix.event_types.some(evt => matrix.implemented_combos[evt]?.includes(ch.id))) const columns = `minmax(0, 1fr) ${channels.map(() => '76px').join(' ')}` return ( {/* The legend is the key to the cells below, so it reads in the same three chips. */}
{channels.map(ch => ( {channelLabel(ch, t)} ))}
{matrix.event_types.map(eventType => { const implemented = matrix.implemented_combos[eventType] ?? [] return (
{t(EVENT_LABEL_KEYS[eventType]) || eventType} {channels.map(ch => { if (!implemented.includes(ch.id)) return — const state = matrix.defaults[eventType]?.[ch.id] ?? 'on' const Icon = ICON[state] const label = `${t(EVENT_LABEL_KEYS[eventType]) || eventType}, ${channelLabel(ch, t)}: ${t(LABEL_KEYS[state])}` return (
) })}
) })}
) }