@burdenoff/microfe-notification 2026.1201.1 → 2026.1202.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/hooks/answeredAt.d.ts +8 -0
  2. package/dist/hooks/answeredAt.js +33 -0
  3. package/dist/hooks/answeredAt.js.map +1 -0
  4. package/dist/hooks/useNotificationAdmin.d.ts +2 -0
  5. package/dist/hooks/useNotificationAdmin.js +32 -31
  6. package/dist/hooks/useNotificationAdmin.js.map +1 -1
  7. package/dist/hooks/useNotificationPreferences.d.ts +2 -0
  8. package/dist/hooks/useNotificationPreferences.js +45 -43
  9. package/dist/hooks/useNotificationPreferences.js.map +1 -1
  10. package/dist/hooks/useNotificationTemplates.d.ts +2 -0
  11. package/dist/hooks/useNotificationTemplates.js +92 -88
  12. package/dist/hooks/useNotificationTemplates.js.map +1 -1
  13. package/dist/hooks/useNotificationTopics.d.ts +2 -0
  14. package/dist/hooks/useNotificationTopics.js +19 -18
  15. package/dist/hooks/useNotificationTopics.js.map +1 -1
  16. package/dist/hooks/useNotifications.d.ts +2 -0
  17. package/dist/hooks/useNotifications.js +69 -68
  18. package/dist/hooks/useNotifications.js.map +1 -1
  19. package/dist/hooks/usePreferenceToggles.d.ts +2 -0
  20. package/dist/hooks/usePreferenceToggles.js +19 -18
  21. package/dist/hooks/usePreferenceToggles.js.map +1 -1
  22. package/dist/v2/InboxPage.js +111 -107
  23. package/dist/v2/InboxPage.js.map +1 -1
  24. package/dist/v2/InboxRows.js +50 -45
  25. package/dist/v2/InboxRows.js.map +1 -1
  26. package/dist/v2/NotificationDetailPanel.js +97 -93
  27. package/dist/v2/NotificationDetailPanel.js.map +1 -1
  28. package/dist/v2/PreferencesPage.js +113 -106
  29. package/dist/v2/PreferencesPage.js.map +1 -1
  30. package/dist/v2/StaleHint.d.ts +4 -0
  31. package/dist/v2/StaleHint.js +18 -0
  32. package/dist/v2/StaleHint.js.map +1 -0
  33. package/dist/v2/admin/DeliveryLogPage.js +71 -69
  34. package/dist/v2/admin/DeliveryLogPage.js.map +1 -1
  35. package/dist/v2/admin/TemplateEditor.js +58 -55
  36. package/dist/v2/admin/TemplateEditor.js.map +1 -1
  37. package/dist/v2/admin/TemplatesPage.js +150 -142
  38. package/dist/v2/admin/TemplatesPage.js.map +1 -1
  39. package/dist/v2/admin/TopicDialog.js +66 -65
  40. package/dist/v2/admin/TopicDialog.js.map +1 -1
  41. package/dist/v2/admin/TopicsPage.js +85 -80
  42. package/dist/v2/admin/TopicsPage.js.map +1 -1
  43. package/dist/v2/admin/useTemplateDraft.js +73 -72
  44. package/dist/v2/admin/useTemplateDraft.js.map +1 -1
  45. package/dist/v2/model/loadedAt.d.ts +5 -0
  46. package/dist/v2/model/loadedAt.js +8 -0
  47. package/dist/v2/model/loadedAt.js.map +1 -0
  48. package/dist/v2/send/SendNotificationDialog.js +53 -51
  49. package/dist/v2/send/SendNotificationDialog.js.map +1 -1
  50. package/dist/v2/useNeedsConnection.d.ts +29 -0
  51. package/dist/v2/useNeedsConnection.js +51 -0
  52. package/dist/v2/useNeedsConnection.js.map +1 -0
  53. package/package.json +2 -2
@@ -1 +1 @@
1
- {"version":3,"file":"DeliveryLogPage.js","names":["TONE_ICON","CheckCircle2","XCircle","Clock","COUNT","TONE_TEXT","DeliveryLogPage","details","useFeatureFlagDetails","paths","useNotificationPaths","on","AdminPageV2","DeliveryLog","Navigate","recipientOf","notification","tr","DeliveryCounts","useTr","StatusChip","counts","Segmented","tone","onTone","DeliveryLine","when","useWhenLabels","item","Icon","state","onOpen","channelWord","DeliveryDays","groupByDay","items","group","DeliveryEmpty","EmptyState","filtered","DeliveryLoading","Skeleton","index","admin","useNotificationAdmin","setTone","useState","openId","setOpenId","withState","useMemo","deliveryState","out","shown","empty","body","LoadError","WorkspacePage","PageHeader","NotificationDetailPanel"],"sources":["../../../src/v2/admin/DeliveryLogPage.tsx"],"sourcesContent":["/**\n * The delivery log (BOFF-16785, C2; the mockup's `ndelivery`), under fe-libs' `accountPagesV2`:\n * every notification sent, and whether it arrived. Counts first (delivered, didn't arrive, waiting),\n * then a line each, grouped by day: what was sent to whom, how, and what happened, with an icon and a\n * word. A line opens the notification's panel, read-only. Admins only (`AdminPageV2`), behind the\n * same flag as today (`notification.history`). Today's hook (`useNotificationAdmin`).\n */\nimport { useMemo, useState } from 'react';\nimport { Navigate } from 'react-router';\nimport { CheckCircle2, Clock, XCircle } from 'lucide-react';\nimport { useFeatureFlagDetails } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport {\n EmptyState,\n LoadError,\n Segmented,\n Skeleton,\n StatusChip,\n WorkspacePage,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationAdmin } from '../../hooks/useNotificationAdmin';\nimport type { Notification } from '../../types';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { NotificationDetailPanel } from '../NotificationDetailPanel';\nimport { groupByDay } from '../model/days';\nimport { channelWord, deliveryState, type DeliveryTone } from './words';\n\ntype ToneFilter = 'any' | DeliveryTone;\n\nconst TONE_ICON = { ok: CheckCircle2, bad: XCircle, waiting: Clock } as const;\nconst COUNT = new Intl.NumberFormat();\nconst TONE_TEXT: Record<DeliveryTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n};\n\nexport function DeliveryLogPage() {\n const details = useFeatureFlagDetails('notification.history');\n const paths = useNotificationPaths();\n const on = details ? Boolean(details.value) : false;\n // Someone without the permission sees the lock, whatever the flag says (alpha check BOFF-17355:\n // a member got today's inbox here). An admin while `notification.history` is off goes to the\n // inbox, as today, but the redesigned one, never today's page.\n return (\n <AdminPageV2 tool=\"deliveryLog\" back={false}>\n {on ? <DeliveryLog /> : <Navigate to={paths.inbox} replace />}\n </AdminPageV2>\n );\n}\n\nfunction recipientOf(\n notification: Notification,\n tr: (key: string, fallback: string) => string\n): string {\n return (\n notification.recipientEmail ||\n notification.recipientPhone ||\n tr('notifications.v3.log.inApp', 'someone in the app')\n );\n}\n\ntype LogItem = {\n notification: Notification;\n state: ReturnType<typeof deliveryState>;\n createdAt: string;\n};\n\nfunction DeliveryCounts({\n counts,\n tone,\n onTone,\n}: {\n counts: Record<DeliveryTone, number>;\n tone: ToneFilter;\n onTone: (tone: ToneFilter) => void;\n}) {\n const tr = useTr();\n return (\n <div className=\"flex flex-wrap items-center gap-2\" data-testid=\"log-counts\">\n <StatusChip status=\"ok\">\n {tr('notifications.v3.log.delivered', '{{count}} delivered', {\n count: COUNT.format(counts.ok),\n })}\n </StatusChip>\n <StatusChip status=\"bad\">\n {tr('notifications.v3.log.failed', '{{count}} didn’t arrive', {\n count: COUNT.format(counts.bad),\n })}\n </StatusChip>\n <StatusChip status=\"waiting\">\n {tr('notifications.v3.log.waiting', '{{count}} waiting', {\n count: COUNT.format(counts.waiting),\n })}\n </StatusChip>\n <span className=\"flex-1\" />\n <Segmented<ToneFilter>\n aria-label={tr('notifications.v3.log.show', 'Show')}\n value={tone}\n onValueChange={onTone}\n options={[\n { value: 'any', label: tr('notifications.v3.log.any', 'All') },\n { value: 'ok', label: tr('notifications.v3.delivery.delivered', 'Delivered') },\n { value: 'bad', label: tr('notifications.v3.delivery.failed', 'Didn’t arrive') },\n { value: 'waiting', label: tr('notifications.v3.log.waitingShort', 'Waiting') },\n ]}\n />\n </div>\n );\n}\n\nfunction DeliveryLine({ item, onOpen }: { item: LogItem; onOpen: (id: string) => void }) {\n const tr = useTr();\n const when = useWhenLabels();\n const { notification, state } = item;\n const Icon = TONE_ICON[state.tone];\n return (\n <li data-row-id={notification.id}>\n <button\n type=\"button\"\n className=\"flex w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-3 py-2.5 text-left\"\n onClick={() => onOpen(notification.id)}\n >\n <Icon className={`size-4 shrink-0 ${TONE_TEXT[state.tone]}`} aria-hidden=\"true\" />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-sm text-text-primary\">\n {tr('notifications.v3.log.line', '{{title}} → {{who}}', {\n title: notification.title,\n who: recipientOf(notification, tr),\n })}\n </span>\n <span className=\"block truncate text-xs text-text-secondary\">\n {channelWord(notification.channel, tr)} · {state.word}\n </span>\n </span>\n <time className=\"shrink-0 text-xs text-text-muted\" dateTime={notification.createdAt}>\n {when.moment(notification.createdAt)}\n </time>\n </button>\n </li>\n );\n}\n\nfunction DeliveryDays({ items, onOpen }: { items: LogItem[]; onOpen: (id: string) => void }) {\n const tr = useTr();\n return (\n <div className=\"flex flex-col gap-4\" data-testid=\"log-rows\">\n {groupByDay(items, tr).map((group) => (\n <section key={group.key} aria-label={group.label} className=\"flex flex-col gap-1\">\n <h2 className=\"m-0 px-1 text-xs font-medium text-text-muted\">{group.label}</h2>\n <ul className=\"m-0 flex list-none flex-col divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle bg-bg-surface p-0\">\n {group.items.map((item) => (\n <DeliveryLine key={item.notification.id} item={item} onOpen={onOpen} />\n ))}\n </ul>\n </section>\n ))}\n </div>\n );\n}\n\nfunction DeliveryEmpty({ filtered }: { filtered: boolean }) {\n const tr = useTr();\n return (\n <EmptyState\n kind={filtered ? 'filtered' : 'first-use'}\n title={\n filtered\n ? tr('notifications.v3.log.noneTitle', 'Nothing here')\n : tr('notifications.v3.log.emptyTitle', 'Nothing sent yet')\n }\n description={tr(\n 'notifications.v3.log.emptyBody',\n 'Each notification sent is listed here with what happened to it.'\n )}\n />\n );\n}\n\nfunction DeliveryLoading() {\n return (\n <div className=\"flex flex-col gap-2\" aria-busy=\"true\">\n {Array.from({ length: 6 }, (_, index) => (\n <Skeleton key={index} className=\"h-12 w-full rounded-lg\" />\n ))}\n </div>\n );\n}\n\nfunction DeliveryLog() {\n const tr = useTr();\n const paths = useNotificationPaths();\n const admin = useNotificationAdmin();\n const [tone, setTone] = useState<ToneFilter>('any');\n const [openId, setOpenId] = useState<string | null>(null);\n const withState = useMemo<LogItem[]>(\n () =>\n admin.notifications.map((notification) => ({\n notification,\n state: deliveryState(notification.deliveryStatus, tr),\n createdAt: notification.createdAt,\n })),\n [admin.notifications, tr]\n );\n const counts = useMemo(() => {\n const out = { ok: 0, bad: 0, waiting: 0 };\n for (const item of withState) out[item.state.tone] += 1;\n return out;\n }, [withState]);\n const shown = tone === 'any' ? withState : withState.filter((item) => item.state.tone === tone);\n const empty = withState.length === 0;\n\n let body = <DeliveryDays items={shown} onOpen={setOpenId} />;\n if (admin.error && empty) {\n body = (\n <LoadError\n what={tr('notifications.v3.log.title', 'Delivery log')}\n error={admin.error}\n onRetry={() => void admin.refetch()}\n />\n );\n } else if (admin.isLoading && empty) {\n body = <DeliveryLoading />;\n } else if (shown.length === 0) {\n body = <DeliveryEmpty filtered={tone !== 'any'} />;\n }\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.log.title', 'Delivery log')}\n description={tr(\n 'notifications.v3.log.purpose',\n 'Every notification sent, and whether it arrived.'\n )}\n back={{ label: tr('notifications.v3.title', 'Notifications'), to: paths.inbox }}\n />\n <div className=\"flex flex-col gap-3\">\n <DeliveryCounts counts={counts} tone={tone} onTone={setTone} />\n {body}\n </div>\n <NotificationDetailPanel id={openId} onClose={() => setOpenId(null)} />\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgCA,IAAMA,IAAY;CAAE,IAAIC;CAAc,KAAKC;CAAS,SAASC;AAAM,GAC7DC,IAAQ,IAAI,KAAK,aAAa,GAC9BC,IAA0C;CAC9C,IAAI;CACJ,KAAK;CACL,SAAS;AACX;AAEA,SAAgBC,IAAkB;CAChC,IAAMC,IAAUC,EAAsB,sBAAsB,GACtDC,IAAQC,EAAqB,GAC7BC,IAAKJ,IAAU,EAAQA,EAAQ,QAAS;CAI9C,OACE,kBAACK,GAAD;EAAa,MAAK;EAAc,MAAM;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QAAQ;CACnC,CAAA,IAEMA,EAAM,aAAaW,IAC5B,IAAO,kBAACd,GAAD,CAAkB,CAAA,IAChBa,EAAM,WAAW,MAC1B,IAAO,kBAAChB,GAAD,EAAe,UAAUd,MAAS,MAAQ,CAAA,IAIjD,kBAACkC,GAAD,EAAA,UAAA;EACE,kBAACC,GAAD;GACE,SAAQ;GACR,OAAOzC,EAAG,8BAA8B,cAAc;GACtD,aAAaA,EACX,gCACA,kDACF;GACA,MAAM;IAAE,OAAOA,EAAG,0BAA0B,eAAe;IAAG,IAAIR,EAAM;GAAM;EAC/E,CAAA;EACD,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACS,GAAD;IAAwB;IAAc;IAAM,QAAQ2B;GAAU,CAAA,GAC7DU,CACE;;EACL,kBAACI,GAAD;GAAyB,IAAIZ;GAAQ,eAAeC,EAAU,IAAI;EAAI,CAAA;CACzD,EAAA,CAAA;AAEnB"}
1
+ {"version":3,"file":"DeliveryLogPage.js","names":["TONE_ICON","CheckCircle2","XCircle","Clock","COUNT","TONE_TEXT","DeliveryLogPage","details","useFeatureFlagDetails","paths","useNotificationPaths","on","AdminPageV2","DeliveryLog","Navigate","recipientOf","notification","tr","DeliveryCounts","useTr","StatusChip","counts","Segmented","tone","onTone","DeliveryLine","when","useWhenLabels","item","Icon","state","onOpen","channelWord","DeliveryDays","groupByDay","items","group","DeliveryEmpty","EmptyState","filtered","DeliveryLoading","Skeleton","index","admin","useNotificationAdmin","setTone","useState","openId","setOpenId","withState","useMemo","deliveryState","out","shown","empty","body","LoadError","WorkspacePage","PageHeader","StaleHint","NotificationDetailPanel"],"sources":["../../../src/v2/admin/DeliveryLogPage.tsx"],"sourcesContent":["/**\n * The delivery log (BOFF-16785, C2; the mockup's `ndelivery`), under fe-libs' `accountPagesV2`:\n * every notification sent, and whether it arrived. Counts first (delivered, didn't arrive, waiting),\n * then a line each, grouped by day: what was sent to whom, how, and what happened, with an icon and a\n * word. A line opens the notification's panel, read-only. Admins only (`AdminPageV2`), behind the\n * same flag as today (`notification.history`). Today's hook (`useNotificationAdmin`).\n */\nimport { useMemo, useState } from 'react';\nimport { Navigate } from 'react-router';\nimport { CheckCircle2, Clock, XCircle } from 'lucide-react';\nimport { useFeatureFlagDetails } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport {\n EmptyState,\n LoadError,\n Segmented,\n Skeleton,\n StatusChip,\n WorkspacePage,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationAdmin } from '../../hooks/useNotificationAdmin';\nimport type { Notification } from '../../types';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { NotificationDetailPanel } from '../NotificationDetailPanel';\nimport { groupByDay } from '../model/days';\nimport { channelWord, deliveryState, type DeliveryTone } from './words';\nimport { StaleHint } from '../StaleHint';\n\ntype ToneFilter = 'any' | DeliveryTone;\n\nconst TONE_ICON = { ok: CheckCircle2, bad: XCircle, waiting: Clock } as const;\nconst COUNT = new Intl.NumberFormat();\nconst TONE_TEXT: Record<DeliveryTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n};\n\nexport function DeliveryLogPage() {\n const details = useFeatureFlagDetails('notification.history');\n const paths = useNotificationPaths();\n const on = details ? Boolean(details.value) : false;\n // Someone without the permission sees the lock, whatever the flag says (alpha check BOFF-17355:\n // a member got today's inbox here). An admin while `notification.history` is off goes to the\n // inbox, as today, but the redesigned one, never today's page.\n return (\n <AdminPageV2 tool=\"deliveryLog\" back={false}>\n {on ? <DeliveryLog /> : <Navigate to={paths.inbox} replace />}\n </AdminPageV2>\n );\n}\n\nfunction recipientOf(\n notification: Notification,\n tr: (key: string, fallback: string) => string\n): string {\n return (\n notification.recipientEmail ||\n notification.recipientPhone ||\n tr('notifications.v3.log.inApp', 'someone in the app')\n );\n}\n\ntype LogItem = {\n notification: Notification;\n state: ReturnType<typeof deliveryState>;\n createdAt: string;\n};\n\nfunction DeliveryCounts({\n counts,\n tone,\n onTone,\n}: {\n counts: Record<DeliveryTone, number>;\n tone: ToneFilter;\n onTone: (tone: ToneFilter) => void;\n}) {\n const tr = useTr();\n return (\n <div className=\"flex flex-wrap items-center gap-2\" data-testid=\"log-counts\">\n <StatusChip status=\"ok\">\n {tr('notifications.v3.log.delivered', '{{count}} delivered', {\n count: COUNT.format(counts.ok),\n })}\n </StatusChip>\n <StatusChip status=\"bad\">\n {tr('notifications.v3.log.failed', '{{count}} didn’t arrive', {\n count: COUNT.format(counts.bad),\n })}\n </StatusChip>\n <StatusChip status=\"waiting\">\n {tr('notifications.v3.log.waiting', '{{count}} waiting', {\n count: COUNT.format(counts.waiting),\n })}\n </StatusChip>\n <span className=\"flex-1\" />\n <Segmented<ToneFilter>\n aria-label={tr('notifications.v3.log.show', 'Show')}\n value={tone}\n onValueChange={onTone}\n options={[\n { value: 'any', label: tr('notifications.v3.log.any', 'All') },\n { value: 'ok', label: tr('notifications.v3.delivery.delivered', 'Delivered') },\n { value: 'bad', label: tr('notifications.v3.delivery.failed', 'Didn’t arrive') },\n { value: 'waiting', label: tr('notifications.v3.log.waitingShort', 'Waiting') },\n ]}\n />\n </div>\n );\n}\n\nfunction DeliveryLine({ item, onOpen }: { item: LogItem; onOpen: (id: string) => void }) {\n const tr = useTr();\n const when = useWhenLabels();\n const { notification, state } = item;\n const Icon = TONE_ICON[state.tone];\n return (\n <li data-row-id={notification.id}>\n <button\n type=\"button\"\n className=\"flex w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-3 py-2.5 text-left\"\n onClick={() => onOpen(notification.id)}\n >\n <Icon className={`size-4 shrink-0 ${TONE_TEXT[state.tone]}`} aria-hidden=\"true\" />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-sm text-text-primary\">\n {tr('notifications.v3.log.line', '{{title}} → {{who}}', {\n title: notification.title,\n who: recipientOf(notification, tr),\n })}\n </span>\n <span className=\"block truncate text-xs text-text-secondary\">\n {channelWord(notification.channel, tr)} · {state.word}\n </span>\n </span>\n <time className=\"shrink-0 text-xs text-text-muted\" dateTime={notification.createdAt}>\n {when.moment(notification.createdAt)}\n </time>\n </button>\n </li>\n );\n}\n\nfunction DeliveryDays({ items, onOpen }: { items: LogItem[]; onOpen: (id: string) => void }) {\n const tr = useTr();\n return (\n <div className=\"flex flex-col gap-4\" data-testid=\"log-rows\">\n {groupByDay(items, tr).map((group) => (\n <section key={group.key} aria-label={group.label} className=\"flex flex-col gap-1\">\n <h2 className=\"m-0 px-1 text-xs font-medium text-text-muted\">{group.label}</h2>\n <ul className=\"m-0 flex list-none flex-col divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle bg-bg-surface p-0\">\n {group.items.map((item) => (\n <DeliveryLine key={item.notification.id} item={item} onOpen={onOpen} />\n ))}\n </ul>\n </section>\n ))}\n </div>\n );\n}\n\nfunction DeliveryEmpty({ filtered }: { filtered: boolean }) {\n const tr = useTr();\n return (\n <EmptyState\n kind={filtered ? 'filtered' : 'first-use'}\n title={\n filtered\n ? tr('notifications.v3.log.noneTitle', 'Nothing here')\n : tr('notifications.v3.log.emptyTitle', 'Nothing sent yet')\n }\n description={tr(\n 'notifications.v3.log.emptyBody',\n 'Each notification sent is listed here with what happened to it.'\n )}\n />\n );\n}\n\nfunction DeliveryLoading() {\n return (\n <div className=\"flex flex-col gap-2\" aria-busy=\"true\">\n {Array.from({ length: 6 }, (_, index) => (\n <Skeleton key={index} className=\"h-12 w-full rounded-lg\" />\n ))}\n </div>\n );\n}\n\nfunction DeliveryLog() {\n const tr = useTr();\n const paths = useNotificationPaths();\n const admin = useNotificationAdmin();\n const [tone, setTone] = useState<ToneFilter>('any');\n const [openId, setOpenId] = useState<string | null>(null);\n const withState = useMemo<LogItem[]>(\n () =>\n admin.notifications.map((notification) => ({\n notification,\n state: deliveryState(notification.deliveryStatus, tr),\n createdAt: notification.createdAt,\n })),\n [admin.notifications, tr]\n );\n const counts = useMemo(() => {\n const out = { ok: 0, bad: 0, waiting: 0 };\n for (const item of withState) out[item.state.tone] += 1;\n return out;\n }, [withState]);\n const shown = tone === 'any' ? withState : withState.filter((item) => item.state.tone === tone);\n const empty = withState.length === 0;\n\n let body = <DeliveryDays items={shown} onOpen={setOpenId} />;\n if (admin.error && empty) {\n body = (\n <LoadError\n what={tr('notifications.v3.log.title', 'Delivery log')}\n error={admin.error}\n onRetry={() => void admin.refetch()}\n />\n );\n } else if (admin.isLoading && empty) {\n body = <DeliveryLoading />;\n } else if (shown.length === 0) {\n body = <DeliveryEmpty filtered={tone !== 'any'} />;\n }\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.log.title', 'Delivery log')}\n description={tr(\n 'notifications.v3.log.purpose',\n 'Every notification sent, and whether it arrived.'\n )}\n back={{ label: tr('notifications.v3.title', 'Notifications'), to: paths.inbox }}\n />\n <StaleHint loadedAt={admin.dataUpdatedAt} />\n <div className=\"flex flex-col gap-3\">\n <DeliveryCounts counts={counts} tone={tone} onTone={setTone} />\n {body}\n </div>\n <NotificationDetailPanel id={openId} onClose={() => setOpenId(null)} />\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AAiCA,IAAMA,IAAY;CAAE,IAAIC;CAAc,KAAKC;CAAS,SAASC;AAAM,GAC7DC,IAAQ,IAAI,KAAK,aAAa,GAC9BC,IAA0C;CAC9C,IAAI;CACJ,KAAK;CACL,SAAS;AACX;AAEA,SAAgBC,IAAkB;CAChC,IAAMC,IAAUC,EAAsB,sBAAsB,GACtDC,IAAQC,EAAqB,GAC7BC,IAAKJ,IAAU,EAAQA,EAAQ,QAAS;CAI9C,OACE,kBAACK,GAAD;EAAa,MAAK;EAAc,MAAM;EACnC,UAAAD,IAAK,kBAACE,GAAD,CAAc,CAAA,IAAI,kBAACC,GAAD;GAAU,IAAIL,EAAM;GAAO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AAM,WAAW,MAC1B,IAAO,kBAAChB,GAAD,EAAe,UAAUd,MAAS,MAAQ,CAAA,IAIjD,kBAACkC,GAAD,EAAA,UAAA;EACE,kBAACC,GAAD;GACE,SAAQ;GACR,OAAOzC,EAAG,8BAA8B,cAAc;GACtD,aAAaA,EACX,gCACA,kDACF;GACA,MAAM;IAAE,OAAOA,EAAG,0BAA0B,eAAe;IAAG,IAAIR,EAAM;GAAM;EAC/E,CAAA;EACD,kBAACkD,GAAD,EAAW,UAAUhB,EAAM,cAAgB,CAAA;EAC3C,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACzB,GAAD;IAAwB;IAAc;IAAM,QAAQ2B;GAAU,CAAA,GAC7DU,CACE;;EACL,kBAACK,GAAD;GAAyB,IAAIb;GAAQ,eAAeC,EAAU,IAAI;EAAI,CAAA;CACzD,EAAA,CAAA;AAEnB"}
@@ -1,87 +1,90 @@
1
1
  import { useTr as e } from "../../shared/hooks/useTr.js";
2
- import { useNotificationPaths as t } from "../../navigation-v2/paths.js";
3
- import { TemplateFields as n } from "./TemplateFields.js";
4
- import { TemplatePreview as r } from "./TemplatePreview.js";
5
- import { useTemplateDraft as i } from "./useTemplateDraft.js";
6
- import { channelWord as a, kindWord as o } from "./words.js";
7
- import { useRef as s } from "react";
8
- import { useAppShell as c } from "@burdenoff/fe-libs/shared/providers/shell";
9
- import { Mail as l } from "lucide-react";
10
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
11
- import { PageHeader as f } from "@burdenoff/fe-libs/chrome";
12
- import { Button as p, IconTile as m, Notice as h, StatusChip as g, WorkspacePage as _ } from "@burdenoff/fe-libs/ui";
2
+ import { useNeedsConnection as t, waitingButton as n, waitingItem as r } from "../useNeedsConnection.js";
3
+ import { useNotificationPaths as i } from "../../navigation-v2/paths.js";
4
+ import { TemplateFields as a } from "./TemplateFields.js";
5
+ import { TemplatePreview as o } from "./TemplatePreview.js";
6
+ import { useTemplateDraft as s } from "./useTemplateDraft.js";
7
+ import { channelWord as c, kindWord as l } from "./words.js";
8
+ import { useRef as u } from "react";
9
+ import { useAppShell as d } from "@burdenoff/fe-libs/shared/providers/shell";
10
+ import { Mail as f } from "lucide-react";
11
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
12
+ import { PageHeader as h } from "@burdenoff/fe-libs/chrome";
13
+ import { Button as g, IconTile as _, Notice as v, StatusChip as y, WorkspacePage as b } from "@burdenoff/fe-libs/ui";
13
14
  // src/v2/admin/TemplateEditor.tsx
14
- function v({ template: n, draft: r }) {
15
- let i = e(), s = t(), c = n?.enabled ? /* @__PURE__ */ u(g, {
15
+ function x({ template: a, draft: o }) {
16
+ let s = e(), u = t(), d = i(), m = a?.enabled ? /* @__PURE__ */ p(y, {
16
17
  status: "ok",
17
- children: i("notifications.v3.on", "On")
18
- }) : /* @__PURE__ */ u(g, {
18
+ children: s("notifications.v3.on", "On")
19
+ }) : /* @__PURE__ */ p(y, {
19
20
  status: "paused",
20
- children: i("notifications.v3.off", "Off")
21
+ children: s("notifications.v3.off", "Off")
21
22
  });
22
- return /* @__PURE__ */ u(f, {
23
+ return /* @__PURE__ */ p(h, {
23
24
  variant: "compact",
24
- title: n?.name || r.name.trim() || i("notifications.v3.template.new", "New template"),
25
- description: n ? i("notifications.v3.template.purpose", "{{kind}} · sent by {{channel}}", {
26
- kind: o(n.type, i),
27
- channel: a(n.channel, i).toLowerCase()
28
- }) : i("notifications.v3.template.newPurpose", "Write it once; it’s filled in for each person when it’s sent."),
29
- icon: /* @__PURE__ */ u(m, {
25
+ title: a?.name || o.name.trim() || s("notifications.v3.template.new", "New template"),
26
+ description: a ? s("notifications.v3.template.purpose", "{{kind}} · sent by {{channel}}", {
27
+ kind: l(a.type, s),
28
+ channel: c(a.channel, s).toLowerCase()
29
+ }) : s("notifications.v3.template.newPurpose", "Write it once; it’s filled in for each person when it’s sent."),
30
+ icon: /* @__PURE__ */ p(_, {
30
31
  size: "md",
31
- children: /* @__PURE__ */ u(l, { "aria-hidden": "true" })
32
+ children: /* @__PURE__ */ p(f, { "aria-hidden": "true" })
32
33
  }),
33
34
  back: {
34
- label: i("notifications.v3.templates.title", "Templates"),
35
- to: s.templates
35
+ label: s("notifications.v3.templates.title", "Templates"),
36
+ to: d.templates
36
37
  },
37
- badge: n ? c : void 0,
38
- primary: /* @__PURE__ */ u(p, {
39
- busy: r.saving,
40
- disabled: !r.ready,
41
- onClick: () => void r.save(),
38
+ badge: a ? m : void 0,
39
+ primary: /* @__PURE__ */ p(g, {
40
+ busy: o.saving,
41
+ ...n(u, !o.ready),
42
+ onClick: () => void o.save(),
42
43
  "data-testid": "template-save",
43
- children: n ? i("notifications.v3.template.save", "Save") : i("notifications.v3.template.create", "Create template")
44
+ children: a ? s("notifications.v3.template.save", "Save") : s("notifications.v3.template.create", "Create template")
44
45
  }),
45
- more: n ? [{
46
+ more: a ? [{
46
47
  id: "toggle",
47
- label: n.enabled ? i("notifications.v3.templates.turnOff", "Turn off") : i("notifications.v3.templates.turnOn", "Turn on"),
48
- onSelect: () => void r.toggle()
48
+ label: a.enabled ? s("notifications.v3.templates.turnOff", "Turn off") : s("notifications.v3.templates.turnOn", "Turn on"),
49
+ ...r(u),
50
+ onSelect: () => void o.toggle()
49
51
  }, {
50
52
  id: "delete",
51
- label: i("notifications.v3.templates.delete", "Delete"),
53
+ label: s("notifications.v3.templates.delete", "Delete"),
52
54
  danger: !0,
53
- onSelect: () => void r.remove()
55
+ ...r(u),
56
+ onSelect: () => void o.remove()
54
57
  }] : void 0
55
58
  });
56
59
  }
57
- function y({ template: t, onChanged: a }) {
58
- let o = e(), { productName: l } = c(), f = s(null), p = s(null), m = i(t, f, p, a);
59
- return /* @__PURE__ */ d(_, { children: [
60
- /* @__PURE__ */ u(v, {
60
+ function S({ template: t, onChanged: n }) {
61
+ let r = e(), { productName: i } = d(), c = u(null), l = u(null), f = s(t, c, l, n);
62
+ return /* @__PURE__ */ m(b, { children: [
63
+ /* @__PURE__ */ p(x, {
61
64
  template: t,
62
- draft: m
65
+ draft: f
63
66
  }),
64
- m.problem ? /* @__PURE__ */ u(h, {
67
+ f.problem ? /* @__PURE__ */ p(v, {
65
68
  tone: "bad",
66
69
  role: "alert",
67
- children: m.problem
70
+ children: f.problem
68
71
  }) : null,
69
- /* @__PURE__ */ d("div", {
72
+ /* @__PURE__ */ m("div", {
70
73
  className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-6 max-lg:grid-cols-1",
71
- children: [/* @__PURE__ */ u(n, {
74
+ children: [/* @__PURE__ */ p(a, {
72
75
  template: t,
73
- draft: m,
74
- titleRef: f,
75
- messageRef: p
76
- }), /* @__PURE__ */ u(r, {
77
- productName: l || o("notifications.v3.template.productFallback", "Your product"),
78
- title: m.stored.title,
79
- message: m.stored.message,
80
- details: m.details
76
+ draft: f,
77
+ titleRef: c,
78
+ messageRef: l
79
+ }), /* @__PURE__ */ p(o, {
80
+ productName: i || r("notifications.v3.template.productFallback", "Your product"),
81
+ title: f.stored.title,
82
+ message: f.stored.message,
83
+ details: f.details
81
84
  })]
82
85
  })
83
86
  ] });
84
87
  }
85
- export { y as TemplateEditor };
88
+ export { S as TemplateEditor };
86
89
 
87
90
  //# sourceMappingURL=TemplateEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateEditor.js","names":["TemplateHeader","tr","useTr","paths","useNotificationPaths","onOff","template","StatusChip","PageHeader","draft","kindWord","channelWord","IconTile","Mail","Button","TemplateEditor","useAppShell","titleRef","useRef","messageRef","useTemplateDraft","onChanged","WorkspacePage","Notice","TemplateFields","TemplatePreview","productName"],"sources":["../../../src/v2/admin/TemplateEditor.tsx"],"sourcesContent":["/**\n * The template editor (BOFF-16785, C2): the header, the form and the live preview. Title and\n * message are edited as people read them (`[First name]`); saving stores today's text\n * (`{{firstName}}`) and the details as today's `variables`.\n */\nimport { useRef } from 'react';\nimport { Mail } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { Button, IconTile, Notice, StatusChip, WorkspacePage } from '@burdenoff/fe-libs/ui';\nimport { useAppShell } from '@burdenoff/fe-libs/shared/providers/shell';\nimport type { BackendNotificationTemplate } from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { TemplateFields } from './TemplateFields';\nimport { TemplatePreview } from './TemplatePreview';\nimport { useTemplateDraft, type TemplateDraft } from './useTemplateDraft';\nimport { channelWord, kindWord } from './words';\n\nfunction TemplateHeader({\n template,\n draft,\n}: {\n template: BackendNotificationTemplate | null;\n draft: TemplateDraft;\n}) {\n const tr = useTr();\n const paths = useNotificationPaths();\n const onOff = template?.enabled ? (\n <StatusChip status=\"ok\">{tr('notifications.v3.on', 'On')}</StatusChip>\n ) : (\n <StatusChip status=\"paused\">{tr('notifications.v3.off', 'Off')}</StatusChip>\n );\n return (\n <PageHeader\n variant=\"compact\"\n title={\n template?.name || draft.name.trim() || tr('notifications.v3.template.new', 'New template')\n }\n description={\n template\n ? tr('notifications.v3.template.purpose', '{{kind}} · sent by {{channel}}', {\n kind: kindWord(template.type, tr),\n channel: channelWord(template.channel, tr).toLowerCase(),\n })\n : tr(\n 'notifications.v3.template.newPurpose',\n 'Write it once; it’s filled in for each person when it’s sent.'\n )\n }\n icon={\n <IconTile size=\"md\">\n <Mail aria-hidden=\"true\" />\n </IconTile>\n }\n back={{ label: tr('notifications.v3.templates.title', 'Templates'), to: paths.templates }}\n badge={template ? onOff : undefined}\n primary={\n <Button\n busy={draft.saving}\n disabled={!draft.ready}\n onClick={() => void draft.save()}\n data-testid=\"template-save\"\n >\n {template\n ? tr('notifications.v3.template.save', 'Save')\n : tr('notifications.v3.template.create', 'Create template')}\n </Button>\n }\n more={\n template\n ? [\n {\n id: 'toggle',\n label: template.enabled\n ? tr('notifications.v3.templates.turnOff', 'Turn off')\n : tr('notifications.v3.templates.turnOn', 'Turn on'),\n onSelect: () => void draft.toggle(),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n onSelect: () => void draft.remove(),\n },\n ]\n : undefined\n }\n />\n );\n}\n\nexport function TemplateEditor({\n template,\n onChanged,\n}: {\n template: BackendNotificationTemplate | null;\n /** Read the template again after turning it on or off. */\n onChanged?: () => void;\n}) {\n const tr = useTr();\n const { productName } = useAppShell();\n const titleRef = useRef<HTMLInputElement>(null);\n const messageRef = useRef<HTMLTextAreaElement>(null);\n const draft = useTemplateDraft(template, titleRef, messageRef, onChanged);\n return (\n <WorkspacePage>\n <TemplateHeader template={template} draft={draft} />\n {draft.problem ? (\n <Notice tone=\"bad\" role=\"alert\">\n {draft.problem}\n </Notice>\n ) : null}\n <div className=\"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-6 max-lg:grid-cols-1\">\n <TemplateFields\n template={template}\n draft={draft}\n titleRef={titleRef}\n messageRef={messageRef}\n />\n <TemplatePreview\n productName={\n productName || tr('notifications.v3.template.productFallback', 'Your product')\n }\n title={draft.stored.title}\n message={draft.stored.message}\n details={draft.details}\n />\n </div>\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAASA,EAAe,EACtB,aACA,YAIC;CACD,IAAMC,IAAKC,EAAM,GACXC,IAAQC,EAAqB,GAC7BC,IAAQC,GAAU,UACtB,kBAACC,GAAD;EAAY,QAAO;EAAM,UAAAN,EAAG,uBAAuB,IAAI;CAAc,CAAA,IAErE,kBAACM,GAAD;EAAY,QAAO;EAAU,UAAAN,EAAG,wBAAwB,KAAK;CAAc,CAAA;CAE7E,OACE,kBAACO,GAAD;EACE,SAAQ;EACR,OACEF,GAAU,QAAQG,EAAM,KAAK,KAAK,KAAKR,EAAG,iCAAiC,cAAc;EAE3F,aACEK,IACIL,EAAG,qCAAqC,kCAAkC;GACxE,MAAMS,EAASJ,EAAS,MAAML,CAAE;GAChC,SAASU,EAAYL,EAAS,SAASL,CAAE,CAAC,CAAC,YAAY;EACzD,CAAC,IACDA,EACE,wCACA,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OAAO;IACpB,SAASA,EAAM,OAAO;IACtB,SAASA,EAAM;GAChB,CAAA,CACE;;CACQ,EAAA,CAAA;AAEnB"}
1
+ {"version":3,"file":"TemplateEditor.js","names":["TemplateHeader","tr","useTr","connection","useNeedsConnection","paths","useNotificationPaths","onOff","template","StatusChip","PageHeader","draft","kindWord","channelWord","IconTile","Mail","Button","waitingButton","waitingItem","TemplateEditor","useAppShell","titleRef","useRef","messageRef","useTemplateDraft","onChanged","WorkspacePage","Notice","TemplateFields","TemplatePreview","productName"],"sources":["../../../src/v2/admin/TemplateEditor.tsx"],"sourcesContent":["/**\n * The template editor (BOFF-16785, C2): the header, the form and the live preview. Title and\n * message are edited as people read them (`[First name]`); saving stores today's text\n * (`{{firstName}}`) and the details as today's `variables`.\n */\nimport { useRef } from 'react';\nimport { Mail } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { Button, IconTile, Notice, StatusChip, WorkspacePage } from '@burdenoff/fe-libs/ui';\nimport { useAppShell } from '@burdenoff/fe-libs/shared/providers/shell';\nimport type { BackendNotificationTemplate } from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNeedsConnection, waitingButton, waitingItem } from '../useNeedsConnection';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { TemplateFields } from './TemplateFields';\nimport { TemplatePreview } from './TemplatePreview';\nimport { useTemplateDraft, type TemplateDraft } from './useTemplateDraft';\nimport { channelWord, kindWord } from './words';\n\nfunction TemplateHeader({\n template,\n draft,\n}: {\n template: BackendNotificationTemplate | null;\n draft: TemplateDraft;\n}) {\n const tr = useTr();\n const connection = useNeedsConnection();\n const paths = useNotificationPaths();\n const onOff = template?.enabled ? (\n <StatusChip status=\"ok\">{tr('notifications.v3.on', 'On')}</StatusChip>\n ) : (\n <StatusChip status=\"paused\">{tr('notifications.v3.off', 'Off')}</StatusChip>\n );\n return (\n <PageHeader\n variant=\"compact\"\n title={\n template?.name || draft.name.trim() || tr('notifications.v3.template.new', 'New template')\n }\n description={\n template\n ? tr('notifications.v3.template.purpose', '{{kind}} · sent by {{channel}}', {\n kind: kindWord(template.type, tr),\n channel: channelWord(template.channel, tr).toLowerCase(),\n })\n : tr(\n 'notifications.v3.template.newPurpose',\n 'Write it once; it’s filled in for each person when it’s sent.'\n )\n }\n icon={\n <IconTile size=\"md\">\n <Mail aria-hidden=\"true\" />\n </IconTile>\n }\n back={{ label: tr('notifications.v3.templates.title', 'Templates'), to: paths.templates }}\n badge={template ? onOff : undefined}\n primary={\n <Button\n busy={draft.saving}\n {...waitingButton(connection, !draft.ready)}\n onClick={() => void draft.save()}\n data-testid=\"template-save\"\n >\n {template\n ? tr('notifications.v3.template.save', 'Save')\n : tr('notifications.v3.template.create', 'Create template')}\n </Button>\n }\n more={\n template\n ? [\n {\n id: 'toggle',\n label: template.enabled\n ? tr('notifications.v3.templates.turnOff', 'Turn off')\n : tr('notifications.v3.templates.turnOn', 'Turn on'),\n ...waitingItem(connection),\n onSelect: () => void draft.toggle(),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n ...waitingItem(connection),\n onSelect: () => void draft.remove(),\n },\n ]\n : undefined\n }\n />\n );\n}\n\nexport function TemplateEditor({\n template,\n onChanged,\n}: {\n template: BackendNotificationTemplate | null;\n /** Read the template again after turning it on or off. */\n onChanged?: () => void;\n}) {\n const tr = useTr();\n const { productName } = useAppShell();\n const titleRef = useRef<HTMLInputElement>(null);\n const messageRef = useRef<HTMLTextAreaElement>(null);\n const draft = useTemplateDraft(template, titleRef, messageRef, onChanged);\n return (\n <WorkspacePage>\n <TemplateHeader template={template} draft={draft} />\n {draft.problem ? (\n <Notice tone=\"bad\" role=\"alert\">\n {draft.problem}\n </Notice>\n ) : null}\n <div className=\"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-6 max-lg:grid-cols-1\">\n <TemplateFields\n template={template}\n draft={draft}\n titleRef={titleRef}\n messageRef={messageRef}\n />\n <TemplatePreview\n productName={\n productName || tr('notifications.v3.template.productFallback', 'Your product')\n }\n title={draft.stored.title}\n message={draft.stored.message}\n details={draft.details}\n />\n </div>\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,SAASA,EAAe,EACtB,aACA,YAIC;CACD,IAAMC,IAAKC,EAAM,GACXC,IAAaC,EAAmB,GAChCC,IAAQC,EAAqB,GAC7BC,IAAQC,GAAU,UACtB,kBAACC,GAAD;EAAY,QAAO;EAAM,UAAAR,EAAG,uBAAuB,IAAI;CAAc,CAAA,IAErE,kBAACQ,GAAD;EAAY,QAAO;EAAU,UAAAR,EAAG,wBAAwB,KAAK;CAAc,CAAA;CAE7E,OACE,kBAACS,GAAD;EACE,SAAQ;EACR,OACEF,GAAU,QAAQG,EAAM,KAAK,KAAK,KAAKV,EAAG,iCAAiC,cAAc;EAE3F,aACEO,IACIP,EAAG,qCAAqC,kCAAkC;GACxE,MAAMW,EAASJ,EAAS,MAAMP,CAAE;GAChC,SAASY,EAAYL,EAAS,SAASP,CAAE,CAAC,CAAC,YAAY;EACzD,CAAC,IACDA,EACE,wCACA,+DACF;EAEN,MACE,kBAACa,GAAD;GAAU,MAAK;GACb,UAAA,kBAACC,GAAD,EAAM,eAAY,OAAQ,CAAA;EAClB,CAAA;EAEZ,MAAM;GAAE,OAAOd,EAAG,oCAAoC,WAAW;GAAG,IAAII,EAAM;EAAU;EACxF,OAAOG,IAAWD,IAAQ,KAAA;EAC1B,SACE,kBAACS,GAAD;GACE,MAAML,EAAM;GACZ,GAAIM,EAAcd,GAAY,CAACQ,EAAM,KAAK;GAC1C,eAAe,KAAKA,EAAM,KAAK;GAC/B,eAAY;GAEX,UAAAH,IACGP,EAAG,kCAAkC,MAAM,IAC3CA,EAAG,oCAAoC,iBAAiB;EACtD,CAAA;EAEV,MACEO,IACI,CACE;GACE,IAAI;GACJ,OAAOA,EAAS,UACZP,EAAG,sCAAsC,UAAU,IACnDA,EAAG,qCAAqC,SAAS;GACrD,GAAGiB,EAAYf,CAAU;GACzB,gBAAgB,KAAKQ,EAAM,OAAO;EACpC,GACA;GACE,IAAI;GACJ,OAAOV,EAAG,qCAAqC,QAAQ;GACvD,QAAQ;GACR,GAAGiB,EAAYf,CAAU;GACzB,gBAAgB,KAAKQ,EAAM,OAAO;EACpC,CACF,IACA,KAAA;CAEP,CAAA;AAEL;AAEA,SAAgBQ,EAAe,EAC7B,aACA,gBAKC;CACD,IAAMlB,IAAKC,EAAM,GACX,EAAE,mBAAgBkB,EAAY,GAC9BC,IAAWC,EAAyB,IAAI,GACxCC,IAAaD,EAA4B,IAAI,GAC7CX,IAAQa,EAAiBhB,GAAUa,GAAUE,GAAYE,CAAS;CACxE,OACE,kBAACC,GAAD,EAAA,UAAA;EACE,kBAAC1B,GAAD;GAA0B;GAAiB;EAAQ,CAAA;EAClDW,EAAM,UACL,kBAACgB,GAAD;GAAQ,MAAK;GAAM,MAAK;GACrB,UAAAhB,EAAM;EACD,CAAA,IACN;EACJ,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACiB,GAAD;IACY;IACH;IACG;IACE;GACb,CAAA,GACD,kBAACC,GAAD;IACE,aACEC,KAAe7B,EAAG,6CAA6C,cAAc;IAE/E,OAAOU,EAAM,OAAO;IACpB,SAASA,EAAM,OAAO;IACtB,SAASA,EAAM;GAChB,CAAA,CACE;;CACQ,EAAA,CAAA;AAEnB"}
@@ -1,169 +1,177 @@
1
1
  import { useNotificationTemplates as e } from "../../hooks/useNotificationTemplates.js";
2
2
  import { useTr as t } from "../../shared/hooks/useTr.js";
3
- import { useNotificationPaths as n } from "../../navigation-v2/paths.js";
4
- import { AdminPageV2 as r } from "../../navigation-v2/AdminPageV2.js";
5
- import { channelWord as i, kindWord as a } from "./words.js";
6
- import { readDetails as o, toReadable as s } from "./templateText.js";
7
- import { useMemo as c, useState as l } from "react";
8
- import { Mail as u, Plus as d, Search as f } from "lucide-react";
9
- import { useNavigate as p } from "react-router";
10
- import { jsx as m, jsxs as h } from "react/jsx-runtime";
11
- import { PageHeader as g } from "@burdenoff/fe-libs/chrome";
12
- import { ActionMenu as _, Button as v, DataRows as y, EmptyState as b, IconTile as x, Input as S, LoadError as C, StatusChip as w, WorkspacePage as T, useConfirm as E, useNotify as D, useWhenLabels as O } from "@burdenoff/fe-libs/ui";
3
+ import { useConnectionGate as n, useNeedsConnection as r, waitingItem as i } from "../useNeedsConnection.js";
4
+ import { useNotificationPaths as a } from "../../navigation-v2/paths.js";
5
+ import { AdminPageV2 as o } from "../../navigation-v2/AdminPageV2.js";
6
+ import { channelWord as s, kindWord as c } from "./words.js";
7
+ import { readDetails as l, toReadable as u } from "./templateText.js";
8
+ import { StaleHint as d } from "../StaleHint.js";
9
+ import { useMemo as f, useState as p } from "react";
10
+ import { Mail as m, Plus as h, Search as g } from "lucide-react";
11
+ import { useNavigate as _ } from "react-router";
12
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
13
+ import { PageHeader as b } from "@burdenoff/fe-libs/chrome";
14
+ import { ActionMenu as x, Button as S, DataRows as C, EmptyState as w, IconTile as T, Input as E, LoadError as D, StatusChip as O, WorkspacePage as k, useConfirm as A, useNotify as j, useWhenLabels as M } from "@burdenoff/fe-libs/ui";
13
15
  // src/v2/admin/TemplatesPage.tsx
14
- function k() {
15
- return /* @__PURE__ */ m(r, {
16
+ function N() {
17
+ return /* @__PURE__ */ v(o, {
16
18
  tool: "templates",
17
19
  back: !1,
18
- children: /* @__PURE__ */ m(A, {})
20
+ children: /* @__PURE__ */ v(P, {})
19
21
  });
20
22
  }
21
- function A() {
22
- let r = t(), k = p(), A = n(), j = E(), M = D(), N = O(), P = e(), [F, I] = l(""), L = c(() => {
23
- let e = F.trim().toLowerCase(), t = P.allTemplates;
23
+ function P() {
24
+ let o = t(), N = r(), P = _(), F = a(), I = A(), L = n(), R = j(), z = M(), B = e(), [V, H] = p(""), U = f(() => {
25
+ let e = V.trim().toLowerCase(), t = B.allTemplates;
24
26
  return e ? t.filter((t) => t.name.toLowerCase().includes(e) || (t.subject ?? "").toLowerCase().includes(e)) : t;
25
- }, [F, P.allTemplates]), R = async (e) => {
27
+ }, [V, B.allTemplates]), W = async (e) => {
26
28
  try {
27
- await P.updateTemplate(e.id, { enabled: !e.enabled }), M({
28
- title: e.enabled ? r("notifications.v3.templates.turnedOff", "{{name}} is off", { name: e.name }) : r("notifications.v3.templates.turnedOn", "{{name}} is on", { name: e.name }),
29
+ await B.updateTemplate(e.id, { enabled: !e.enabled }), R({
30
+ title: e.enabled ? o("notifications.v3.templates.turnedOff", "{{name}} is off", { name: e.name }) : o("notifications.v3.templates.turnedOn", "{{name}} is on", { name: e.name }),
29
31
  tone: "success"
30
- }), await P.refetch();
32
+ }), await B.refetch();
31
33
  } catch {
32
- M({
33
- title: r("notifications.v3.templates.saveFailed", "Couldn’t save. Try again."),
34
+ R({
35
+ title: o("notifications.v3.templates.saveFailed", "Couldn’t save. Try again."),
34
36
  tone: "error"
35
37
  });
36
38
  }
37
- }, z = async (e) => {
38
- if (await j({
39
- title: r("notifications.v3.templates.deleteTitle", "Delete {{name}}?", { name: e.name }),
40
- description: r("notifications.v3.templates.deleteBody", "Anything that sends this template stops sending it. Messages already sent stay as they are."),
41
- confirmLabel: r("notifications.v3.templates.delete", "Delete"),
39
+ }, G = async (e) => {
40
+ if (await I({
41
+ title: o("notifications.v3.templates.deleteTitle", "Delete {{name}}?", { name: e.name }),
42
+ description: o("notifications.v3.templates.deleteBody", "Anything that sends this template stops sending it. Messages already sent stay as they are."),
43
+ confirmLabel: o("notifications.v3.templates.delete", "Delete"),
42
44
  tone: "danger",
43
45
  typeToConfirm: e.name
44
- })) try {
45
- await P.deleteTemplate(e.id), M({
46
- title: r("notifications.v3.templates.deleted", "Deleted {{name}}", { name: e.name }),
46
+ }) && !L()) try {
47
+ await B.deleteTemplate(e.id), R({
48
+ title: o("notifications.v3.templates.deleted", "Deleted {{name}}", { name: e.name }),
47
49
  tone: "success"
48
- }), await P.refetch();
50
+ }), await B.refetch();
49
51
  } catch {
50
- M({
51
- title: r("notifications.v3.templates.deleteFailed", "Couldn’t delete it. Try again."),
52
+ R({
53
+ title: o("notifications.v3.templates.deleteFailed", "Couldn’t delete it. Try again."),
52
54
  tone: "error"
53
55
  });
54
56
  }
55
57
  };
56
- return /* @__PURE__ */ h(T, { children: [/* @__PURE__ */ m(g, {
57
- variant: "compact",
58
- title: r("notifications.v3.templates.title", "Templates"),
59
- description: r("notifications.v3.templates.purpose", "Messages written once and sent many times: what they say, and how they’re sent."),
60
- back: {
61
- label: r("notifications.v3.title", "Notifications"),
62
- to: A.inbox
63
- },
64
- primary: /* @__PURE__ */ h(v, {
65
- onClick: () => k(A.newTemplate),
66
- "data-testid": "templates-new",
67
- children: [/* @__PURE__ */ m(d, { "aria-hidden": "true" }), r("notifications.v3.templates.new", "New template")]
68
- })
69
- }), /* @__PURE__ */ h("div", {
70
- className: "flex flex-col gap-3",
71
- children: [/* @__PURE__ */ h("label", {
72
- className: "relative block max-w-md",
73
- children: [
74
- /* @__PURE__ */ m("span", {
75
- className: "sr-only",
76
- children: r("notifications.v3.templates.search", "Search templates")
77
- }),
78
- /* @__PURE__ */ m(f, {
79
- className: "pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted",
80
- "aria-hidden": "true"
81
- }),
82
- /* @__PURE__ */ m(S, {
83
- type: "search",
84
- className: "pl-9",
85
- value: F,
86
- placeholder: r("notifications.v3.templates.search", "Search templates"),
87
- onChange: (e) => I(e.target.value)
88
- })
89
- ]
90
- }), P.error && L.length === 0 ? /* @__PURE__ */ m(C, {
91
- what: r("notifications.v3.templates.title", "Templates"),
92
- error: P.error,
93
- onRetry: () => void P.refetch()
94
- }) : !P.isLoading && L.length === 0 ? F.trim() ? /* @__PURE__ */ m(b, {
95
- kind: "no-results",
96
- title: r("notifications.v3.templates.noMatch", "No templates match"),
97
- description: r("notifications.v3.empty.searchBody", "Try other words.")
98
- }) : /* @__PURE__ */ m(b, {
99
- kind: "first-use",
100
- title: r("notifications.v3.templates.emptyTitle", "No templates yet"),
101
- description: r("notifications.v3.templates.emptyBody", "A template is a message you write once, like a welcome email, and send many times."),
102
- action: /* @__PURE__ */ m(v, {
103
- onClick: () => k(A.newTemplate),
104
- children: r("notifications.v3.templates.new", "New template")
105
- })
106
- }) : /* @__PURE__ */ m(y, {
107
- items: L,
108
- loading: P.isLoading && L.length === 0,
109
- skeletonRows: 5,
110
- getId: (e) => e.id,
111
- label: r("notifications.v3.templates.title", "Templates"),
112
- lead: {
113
- header: r("notifications.v3.templates.template", "Template"),
114
- media: () => /* @__PURE__ */ m(x, {
115
- size: "sm",
116
- children: /* @__PURE__ */ m(u, { "aria-hidden": "true" })
117
- }),
118
- title: (e) => e.name,
119
- subtitle: (e) => e.subject ? s(e.subject, o(e.variables)) : void 0,
120
- onOpen: (e) => k(A.template(e.slug))
58
+ return /* @__PURE__ */ y(k, { children: [
59
+ /* @__PURE__ */ v(b, {
60
+ variant: "compact",
61
+ title: o("notifications.v3.templates.title", "Templates"),
62
+ description: o("notifications.v3.templates.purpose", "Messages written once and sent many times: what they say, and how they’re sent."),
63
+ back: {
64
+ label: o("notifications.v3.title", "Notifications"),
65
+ to: F.inbox
121
66
  },
122
- columns: [
123
- {
124
- id: "kind",
125
- header: r("notifications.v3.templates.kind", "About"),
126
- cell: (e) => a(e.type, r)
127
- },
128
- {
129
- id: "channel",
130
- header: r("notifications.v3.templates.channel", "Sent by"),
131
- cell: (e) => i(e.channel, r)
132
- },
133
- {
134
- id: "edited",
135
- header: r("notifications.v3.templates.edited", "Edited"),
136
- cell: (e) => N.moment(e.updatedAt)
137
- },
138
- {
139
- id: "status",
140
- header: r("notifications.v3.templates.status", "Status"),
141
- cell: (e) => e.enabled ? /* @__PURE__ */ m(w, {
142
- status: "ok",
143
- children: r("notifications.v3.on", "On")
144
- }) : /* @__PURE__ */ m(w, {
145
- status: "paused",
146
- children: r("notifications.v3.off", "Off")
147
- })
148
- }
149
- ],
150
- actions: (e) => /* @__PURE__ */ m(_, {
151
- placement: "row",
152
- label: r("notifications.v3.templates.actionsFor", "Actions for {{name}}", { name: e.name }),
153
- items: [{
154
- id: "toggle",
155
- label: e.enabled ? r("notifications.v3.templates.turnOff", "Turn off") : r("notifications.v3.templates.turnOn", "Turn on"),
156
- onSelect: () => void R(e)
157
- }, {
158
- id: "delete",
159
- label: r("notifications.v3.templates.delete", "Delete"),
160
- danger: !0,
161
- onSelect: () => void z(e)
162
- }]
67
+ primary: /* @__PURE__ */ y(S, {
68
+ onClick: () => P(F.newTemplate),
69
+ "data-testid": "templates-new",
70
+ children: [/* @__PURE__ */ v(h, { "aria-hidden": "true" }), o("notifications.v3.templates.new", "New template")]
163
71
  })
164
- })]
165
- })] });
72
+ }),
73
+ /* @__PURE__ */ v(d, { loadedAt: B.dataUpdatedAt }),
74
+ /* @__PURE__ */ y("div", {
75
+ className: "flex flex-col gap-3",
76
+ children: [/* @__PURE__ */ y("label", {
77
+ className: "relative block max-w-md",
78
+ children: [
79
+ /* @__PURE__ */ v("span", {
80
+ className: "sr-only",
81
+ children: o("notifications.v3.templates.search", "Search templates")
82
+ }),
83
+ /* @__PURE__ */ v(g, {
84
+ className: "pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted",
85
+ "aria-hidden": "true"
86
+ }),
87
+ /* @__PURE__ */ v(E, {
88
+ type: "search",
89
+ className: "pl-9",
90
+ value: V,
91
+ placeholder: o("notifications.v3.templates.search", "Search templates"),
92
+ onChange: (e) => H(e.target.value)
93
+ })
94
+ ]
95
+ }), B.error && U.length === 0 ? /* @__PURE__ */ v(D, {
96
+ what: o("notifications.v3.templates.title", "Templates"),
97
+ error: B.error,
98
+ onRetry: () => void B.refetch()
99
+ }) : !B.isLoading && U.length === 0 ? V.trim() ? /* @__PURE__ */ v(w, {
100
+ kind: "no-results",
101
+ title: o("notifications.v3.templates.noMatch", "No templates match"),
102
+ description: o("notifications.v3.empty.searchBody", "Try other words.")
103
+ }) : /* @__PURE__ */ v(w, {
104
+ kind: "first-use",
105
+ title: o("notifications.v3.templates.emptyTitle", "No templates yet"),
106
+ description: o("notifications.v3.templates.emptyBody", "A template is a message you write once, like a welcome email, and send many times."),
107
+ action: /* @__PURE__ */ v(S, {
108
+ onClick: () => P(F.newTemplate),
109
+ children: o("notifications.v3.templates.new", "New template")
110
+ })
111
+ }) : /* @__PURE__ */ v(C, {
112
+ items: U,
113
+ loading: B.isLoading && U.length === 0,
114
+ skeletonRows: 5,
115
+ getId: (e) => e.id,
116
+ label: o("notifications.v3.templates.title", "Templates"),
117
+ lead: {
118
+ header: o("notifications.v3.templates.template", "Template"),
119
+ media: () => /* @__PURE__ */ v(T, {
120
+ size: "sm",
121
+ children: /* @__PURE__ */ v(m, { "aria-hidden": "true" })
122
+ }),
123
+ title: (e) => e.name,
124
+ subtitle: (e) => e.subject ? u(e.subject, l(e.variables)) : void 0,
125
+ onOpen: (e) => P(F.template(e.slug))
126
+ },
127
+ columns: [
128
+ {
129
+ id: "kind",
130
+ header: o("notifications.v3.templates.kind", "About"),
131
+ cell: (e) => c(e.type, o)
132
+ },
133
+ {
134
+ id: "channel",
135
+ header: o("notifications.v3.templates.channel", "Sent by"),
136
+ cell: (e) => s(e.channel, o)
137
+ },
138
+ {
139
+ id: "edited",
140
+ header: o("notifications.v3.templates.edited", "Edited"),
141
+ cell: (e) => z.moment(e.updatedAt)
142
+ },
143
+ {
144
+ id: "status",
145
+ header: o("notifications.v3.templates.status", "Status"),
146
+ cell: (e) => e.enabled ? /* @__PURE__ */ v(O, {
147
+ status: "ok",
148
+ children: o("notifications.v3.on", "On")
149
+ }) : /* @__PURE__ */ v(O, {
150
+ status: "paused",
151
+ children: o("notifications.v3.off", "Off")
152
+ })
153
+ }
154
+ ],
155
+ actions: (e) => /* @__PURE__ */ v(x, {
156
+ placement: "row",
157
+ label: o("notifications.v3.templates.actionsFor", "Actions for {{name}}", { name: e.name }),
158
+ items: [{
159
+ id: "toggle",
160
+ label: e.enabled ? o("notifications.v3.templates.turnOff", "Turn off") : o("notifications.v3.templates.turnOn", "Turn on"),
161
+ ...i(N),
162
+ onSelect: () => void W(e)
163
+ }, {
164
+ id: "delete",
165
+ label: o("notifications.v3.templates.delete", "Delete"),
166
+ danger: !0,
167
+ ...i(N),
168
+ onSelect: () => void G(e)
169
+ }]
170
+ })
171
+ })]
172
+ })
173
+ ] });
166
174
  }
167
- export { k as TemplatesPage };
175
+ export { N as TemplatesPage };
168
176
 
169
177
  //# sourceMappingURL=TemplatesPage.js.map