import type { NotificationDefault } from '@trek/shared'; import { EVENT_LABEL_KEYS, channelLabel } from '../../../components/Settings/notificationLabels'; import { useTranslation } from '../../../i18n'; import { DEFAULT_ICON, DEFAULT_LABEL_KEYS, NEXT_DEFAULT, defaultChannels, defaultOf, } from '../../../pages/admin/notificationDefaultsModel'; import { useNotificationDefaults } from '../../../pages/admin/useNotificationDefaults'; import { MAdminCard, MAdminCardHead } from './MAdminUi'; const TONE: Record = { on: 'border-transparent bg-m-act text-m-actfg', off: 'border-[color:var(--m-rowbr)] bg-[color:var(--m-ic)] text-m-muted', blocked: 'border-transparent bg-[color:color-mix(in_srgb,var(--m-st-danger)_14%,transparent)] text-[color:var(--m-st-danger)]', }; /** * What every user's notification cells start as (#1536), the phone's form of the * desktop grid: one row per event with a pill per channel, each tap cycling * On → Off → Blocked. Off is a default a user may still turn on, Blocked is off * for everyone and locked in their settings. */ export default function MAdminNotificationDefaults() { const { t } = useTranslation(); const { matrix, saving, cycle } = useNotificationDefaults(); if (!matrix) return null; const channels = defaultChannels(matrix); return ( {/* The key to the pills below, in the same three looks. */}
{(['on', 'off', 'blocked'] as const).map((state) => { const Icon = DEFAULT_ICON[state]; return ( {t(DEFAULT_LABEL_KEYS[state])} ); })}
{matrix.event_types.map((eventType) => { const implemented = matrix.implemented_combos[eventType] ?? []; const eventLabel = t(EVENT_LABEL_KEYS[eventType]) || eventType; return (
{eventLabel}
{channels .filter((ch) => implemented.includes(ch.id)) .map((ch) => { const state = defaultOf(matrix, eventType, ch.id); const Icon = DEFAULT_ICON[state]; return ( ); })}
); })}
); }