@burdenoff/microfe-notification 2026.1129.1 → 2026.1129.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 (50) hide show
  1. package/dist/NotificationRoutes.js +27 -27
  2. package/dist/NotificationRoutes.js.map +1 -1
  3. package/dist/generated/global-operations.d.ts +4 -0
  4. package/dist/generated/global-operations.js +4 -0
  5. package/dist/generated/global-operations.js.map +1 -1
  6. package/dist/hooks/useNotificationTemplates.d.ts +3 -0
  7. package/dist/translations/en.d.ts +124 -0
  8. package/dist/v2/NotificationDetailPanel.d.ts +4 -3
  9. package/dist/v2/NotificationDetailPanel.js +1 -1
  10. package/dist/v2/NotificationDetailPanel.js.map +1 -1
  11. package/dist/v2/admin/ChoiceSelect.d.ts +9 -0
  12. package/dist/v2/admin/ChoiceSelect.js +24 -0
  13. package/dist/v2/admin/ChoiceSelect.js.map +1 -0
  14. package/dist/v2/admin/DeliveryLogPage.d.ts +1 -0
  15. package/dist/v2/admin/DeliveryLogPage.js +207 -0
  16. package/dist/v2/admin/DeliveryLogPage.js.map +1 -0
  17. package/dist/v2/admin/InsertDetail.d.ts +6 -0
  18. package/dist/v2/admin/InsertDetail.js +77 -0
  19. package/dist/v2/admin/InsertDetail.js.map +1 -0
  20. package/dist/v2/admin/TemplateEditor.d.ts +6 -0
  21. package/dist/v2/admin/TemplateEditor.js +92 -0
  22. package/dist/v2/admin/TemplateEditor.js.map +1 -0
  23. package/dist/v2/admin/TemplateFields.d.ts +9 -0
  24. package/dist/v2/admin/TemplateFields.js +130 -0
  25. package/dist/v2/admin/TemplateFields.js.map +1 -0
  26. package/dist/v2/admin/TemplatePage.d.ts +1 -0
  27. package/dist/v2/admin/TemplatePage.js +62 -0
  28. package/dist/v2/admin/TemplatePage.js.map +1 -0
  29. package/dist/v2/admin/TemplatePreview.d.ts +8 -0
  30. package/dist/v2/admin/TemplatePreview.js +112 -0
  31. package/dist/v2/admin/TemplatePreview.js.map +1 -0
  32. package/dist/v2/admin/TemplatesPage.d.ts +1 -0
  33. package/dist/v2/admin/TemplatesPage.js +173 -0
  34. package/dist/v2/admin/TemplatesPage.js.map +1 -0
  35. package/dist/v2/admin/TopicDialog.d.ts +11 -0
  36. package/dist/v2/admin/TopicDialog.js +113 -0
  37. package/dist/v2/admin/TopicDialog.js.map +1 -0
  38. package/dist/v2/admin/TopicsPage.d.ts +1 -0
  39. package/dist/v2/admin/TopicsPage.js +152 -0
  40. package/dist/v2/admin/TopicsPage.js.map +1 -0
  41. package/dist/v2/admin/templateText.d.ts +35 -0
  42. package/dist/v2/admin/templateText.js +109 -0
  43. package/dist/v2/admin/templateText.js.map +1 -0
  44. package/dist/v2/admin/useTemplateDraft.d.ts +32 -0
  45. package/dist/v2/admin/useTemplateDraft.js +117 -0
  46. package/dist/v2/admin/useTemplateDraft.js.map +1 -0
  47. package/dist/v2/admin/words.d.ts +15 -0
  48. package/dist/v2/admin/words.js +67 -0
  49. package/dist/v2/admin/words.js.map +1 -0
  50. package/package.json +1 -1
@@ -55,6 +55,7 @@ export declare function useNotificationTemplates(initialFilter?: TemplateFilter)
55
55
  name: string;
56
56
  description: string | null;
57
57
  type: import('../generated/global-types').NotificationType;
58
+ channel: import('../generated/global-types').NotificationChannel;
58
59
  locale: string;
59
60
  subject: string | null;
60
61
  bodyTemplate: string;
@@ -73,6 +74,7 @@ export declare function useNotificationTemplates(initialFilter?: TemplateFilter)
73
74
  name: string;
74
75
  description: string | null;
75
76
  type: import('../generated/global-types').NotificationType;
77
+ channel: import('../generated/global-types').NotificationChannel;
76
78
  locale: string;
77
79
  subject: string | null;
78
80
  bodyTemplate: string;
@@ -113,6 +115,7 @@ export declare function useNotificationTemplate(slug: string | undefined, locale
113
115
  name: string;
114
116
  description: string | null;
115
117
  type: import('../generated/global-types').NotificationType;
118
+ channel: import('../generated/global-types').NotificationChannel;
116
119
  locale: string;
117
120
  subject: string | null;
118
121
  bodyTemplate: string;
@@ -470,6 +470,22 @@ export declare const enTranslations: {
470
470
  v3: {
471
471
  actionsFor: string;
472
472
  archive: string;
473
+ cancel: string;
474
+ channel: {
475
+ email: string;
476
+ inApp: string;
477
+ other: string;
478
+ push: string;
479
+ slack: string;
480
+ sms: string;
481
+ whatsapp: string;
482
+ };
483
+ delivery: {
484
+ delivered: string;
485
+ failed: string;
486
+ sent: string;
487
+ waiting: string;
488
+ };
473
489
  empty: {
474
490
  actionBody: string;
475
491
  actionTitle: string;
@@ -497,12 +513,36 @@ export declare const enTranslations: {
497
513
  sent: string;
498
514
  unsubscribed: string;
499
515
  };
516
+ kind: {
517
+ activity: string;
518
+ alerts: string;
519
+ news: string;
520
+ other: string;
521
+ updates: string;
522
+ };
523
+ log: {
524
+ any: string;
525
+ delivered: string;
526
+ emptyBody: string;
527
+ emptyTitle: string;
528
+ failed: string;
529
+ inApp: string;
530
+ line: string;
531
+ noneTitle: string;
532
+ purpose: string;
533
+ show: string;
534
+ title: string;
535
+ waiting: string;
536
+ waitingShort: string;
537
+ };
500
538
  markAll: string;
501
539
  markedAll: string;
502
540
  markRead: string;
503
541
  markUnread: string;
504
542
  more: string;
505
543
  needsYou: string;
544
+ off: string;
545
+ on: string;
506
546
  panel: {
507
547
  close: string;
508
548
  loading: string;
@@ -533,6 +573,69 @@ export declare const enTranslations: {
533
573
  archived: string;
534
574
  unread: string;
535
575
  };
576
+ template: {
577
+ anotherDetail: string;
578
+ channel: string;
579
+ channelFixed: string;
580
+ create: string;
581
+ created: string;
582
+ detailName: string;
583
+ detailPlaceholder: string;
584
+ detailsHelp: string;
585
+ form: string;
586
+ htmlKept: string;
587
+ insert: string;
588
+ kind: string;
589
+ loading: string;
590
+ message: string;
591
+ messagePlaceholder: string;
592
+ missingBody: string;
593
+ missingTitle: string;
594
+ name: string;
595
+ namePlaceholder: string;
596
+ new: string;
597
+ newDetail: string;
598
+ newDetailHelp: string;
599
+ newPurpose: string;
600
+ now: string;
601
+ preview: string;
602
+ previewFrom: string;
603
+ previewMessage: string;
604
+ previewTitle: string;
605
+ previewWith: string;
606
+ productFallback: string;
607
+ purpose: string;
608
+ save: string;
609
+ saved: string;
610
+ title: string;
611
+ titlePlaceholder: string;
612
+ what: string;
613
+ };
614
+ templates: {
615
+ actionsFor: string;
616
+ channel: string;
617
+ delete: string;
618
+ deleteBody: string;
619
+ deleted: string;
620
+ deleteFailed: string;
621
+ deleteTitle: string;
622
+ edited: string;
623
+ emptyBody: string;
624
+ emptyTitle: string;
625
+ kind: string;
626
+ new: string;
627
+ noMatch: string;
628
+ purpose: string;
629
+ saveFailed: string;
630
+ search: string;
631
+ status: string;
632
+ template: string;
633
+ title: string;
634
+ turnedOff: string;
635
+ turnedOn: string;
636
+ turnOff: string;
637
+ turnOn: string;
638
+ };
536
639
  thing: {
537
640
  affectedRuns: string;
538
641
  attempt: string;
@@ -544,6 +647,27 @@ export declare const enTranslations: {
544
647
  timeline: string;
545
648
  title: string;
546
649
  today: string;
650
+ topics: {
651
+ about: string;
652
+ create: string;
653
+ created: string;
654
+ deleteBody: string;
655
+ deleteTitle: string;
656
+ dialogHelp: string;
657
+ edit: string;
658
+ editTitle: string;
659
+ emptyBody: string;
660
+ emptyTitle: string;
661
+ namePlaceholder: string;
662
+ new: string;
663
+ people: string;
664
+ purpose: string;
665
+ saved: string;
666
+ title: string;
667
+ topic: string;
668
+ turnedOff: string;
669
+ turnedOn: string;
670
+ };
547
671
  unread: string;
548
672
  yesterday: string;
549
673
  };
@@ -1,7 +1,8 @@
1
1
  export declare function NotificationDetailPanel({ id, onClose, onMarkUnread, onArchive, onRestore, }: {
2
2
  id: string | null;
3
3
  onClose: () => void;
4
- onMarkUnread: (id: string) => void;
5
- onArchive: (id: string) => void;
6
- onRestore: (id: string) => void;
4
+ /** The person's own inbox: absent in the admins' delivery log, which only reads. */
5
+ onMarkUnread?: (id: string) => void;
6
+ onArchive?: (id: string) => void;
7
+ onRestore?: (id: string) => void;
7
8
  }): import('react').JSX.Element;
@@ -26,7 +26,7 @@ function w({ id: t, onClose: r, onMarkUnread: a, onArchive: o, onRestore: s }) {
26
26
  }) : void 0,
27
27
  closeLabel: l("notifications.v3.panel.close", "Close"),
28
28
  "data-testid": "notification-panel",
29
- footer: p ? /* @__PURE__ */ h("div", {
29
+ footer: p && a && o && s ? /* @__PURE__ */ h("div", {
30
30
  className: "flex w-full flex-wrap gap-2",
31
31
  children: [/* @__PURE__ */ m(g, {
32
32
  variant: "outline",
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationDetailPanel.js","names":["follow","navigateInApp","url","NotificationDetailPanel","tr","useTr","useNotificationDetail","id","ready","state","notification","mapBackendToMfeNotification","DetailPanel","next","onClose","PanelSub","IconTile","KindIcon","Button","onMarkUnread","onRestore","onArchive","Skeleton","LoadError","retry","PanelBody","when","useWhenLabels","needsAction","StatusChip","thing","notificationThing","data","actions","ThingBlock","index","action","ArrowUpRight","Timeline","facts","thingFacts","Workflow","fact","actionUrl","EVENT_ICON","CheckCircle2","XCircle","Clock","EVENT_TEXT","items","timeline","events","Icon","event"],"sources":["../../src/v2/NotificationDetailPanel.tsx"],"sourcesContent":["/**\n * A notification's panel (BOFF-16785, C1; decision 10, BE3): the message, \"the thing\" it is about\n * when the sender said (a workflow, its step, the attempt, how many runs it touched, since when),\n * its actions, and its timeline from the delivery events. Mark as unread and Archive at the foot.\n */\nimport { ArrowUpRight, CheckCircle2, Clock, Workflow, XCircle } from 'lucide-react';\nimport {\n Button,\n DetailPanel,\n IconTile,\n LoadError,\n Skeleton,\n StatusChip,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { navigateInApp } from '../utils/inAppNavigation';\nimport { mapBackendToMfeNotification } from '../hooks/useNotifications';\nimport { needsAction } from './model/inbox';\nimport { KindIcon } from './KindIcon';\nimport { notificationThing, thingFacts } from './model/thing';\nimport { timeline, type EventTone } from './model/events';\nimport { useNotificationDetail, type NotificationDetailData } from './useNotificationDetail';\n\n/** Open an action's address: inside the app when it is one of ours, else in a new tab. */\nfunction follow(url: string) {\n if (!navigateInApp(url)) window.open(url, '_blank', 'noopener,noreferrer');\n}\n\nexport function NotificationDetailPanel({\n id,\n onClose,\n onMarkUnread,\n onArchive,\n onRestore,\n}: {\n id: string | null;\n onClose: () => void;\n onMarkUnread: (id: string) => void;\n onArchive: (id: string) => void;\n onRestore: (id: string) => void;\n}) {\n const tr = useTr();\n const { state, retry } = useNotificationDetail(id);\n const ready = state.status === 'ready' ? state.notification : null;\n const notification = ready ? mapBackendToMfeNotification(ready) : null;\n\n return (\n <DetailPanel\n open={Boolean(id)}\n onOpenChange={(next) => (next ? undefined : onClose())}\n title={notification?.title ?? tr('notifications.v3.panel.loading', 'Notification')}\n sub={notification ? <PanelSub notification={notification} /> : undefined}\n tile={\n notification ? (\n <IconTile size=\"md\">\n <KindIcon notification={notification} />\n </IconTile>\n ) : undefined\n }\n closeLabel={tr('notifications.v3.panel.close', 'Close')}\n data-testid=\"notification-panel\"\n footer={\n notification ? (\n <div className=\"flex w-full flex-wrap gap-2\">\n <Button variant=\"outline\" onClick={() => onMarkUnread(notification.id)}>\n {tr('notifications.v3.markUnread', 'Mark as unread')}\n </Button>\n {notification.archivedAt ? (\n <Button variant=\"ghost\" onClick={() => onRestore(notification.id)}>\n {tr('notifications.v3.restore', 'Move back to the inbox')}\n </Button>\n ) : (\n <Button variant=\"ghost\" onClick={() => onArchive(notification.id)}>\n {tr('notifications.v3.archive', 'Archive')}\n </Button>\n )}\n </div>\n ) : undefined\n }\n >\n {state.status === 'loading' ? (\n <div className=\"flex flex-col gap-3\" aria-busy=\"true\">\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-24 w-full\" />\n </div>\n ) : state.status === 'failed' ? (\n <LoadError\n what={tr('notifications.v3.panel.what', 'This notification')}\n error={state.error}\n onRetry={retry}\n />\n ) : state.status === 'missing' || !ready || !notification ? (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.panel.missing',\n 'This notification isn’t available any more. It may have been deleted.'\n )}\n </p>\n ) : (\n <PanelBody notification={notification} data={ready} />\n )}\n </DetailPanel>\n );\n}\n\nfunction PanelSub({ notification }: { notification: Notification }) {\n const tr = useTr();\n const when = useWhenLabels();\n return (\n <span className=\"flex flex-wrap items-center gap-2\">\n <time dateTime={notification.createdAt}>{when.moment(notification.createdAt)}</time>\n {needsAction(notification) ? (\n <StatusChip status=\"warn\">{tr('notifications.v3.needsYou', 'Needs you')}</StatusChip>\n ) : null}\n </span>\n );\n}\n\nfunction PanelBody({\n notification,\n data,\n}: {\n notification: Notification;\n data: NotificationDetailData;\n}) {\n const tr = useTr();\n const thing = notificationThing(data.metadata);\n const actions = notification.actions;\n return (\n <div className=\"flex flex-col gap-5\">\n <p className=\"m-0 text-sm whitespace-pre-wrap text-text-primary\" data-testid=\"panel-message\">\n {notification.body}\n </p>\n {thing ? <ThingBlock thing={thing} actionUrl={notification.actionUrl} /> : null}\n {actions.length > 0 || (notification.actionUrl && !thing) ? (\n <div className=\"flex flex-wrap gap-2\" data-testid=\"panel-actions\">\n {actions.map((action, index) => (\n <Button\n key={action.id}\n variant={index === 0 ? 'default' : 'outline'}\n onClick={() => follow(action.url)}\n >\n {action.label}\n </Button>\n ))}\n {/* \"Open the run\" in the thing's block already goes there. */}\n {actions.length === 0 && notification.actionUrl && !thing ? (\n <Button onClick={() => follow(notification.actionUrl ?? '')}>\n <ArrowUpRight aria-hidden=\"true\" />\n {tr('notifications.v3.panel.open', 'Open where it happened')}\n </Button>\n ) : null}\n </div>\n ) : null}\n <Timeline events={data.events} />\n </div>\n );\n}\n\nfunction ThingBlock({\n thing,\n actionUrl,\n}: {\n thing: NonNullable<ReturnType<typeof notificationThing>>;\n actionUrl?: string;\n}) {\n const tr = useTr();\n const when = useWhenLabels();\n const facts = thingFacts(thing, tr);\n return (\n <section\n className=\"flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3\"\n aria-label={tr('notifications.v3.thing.label', 'What it’s about')}\n data-testid=\"panel-thing\"\n >\n <div className=\"flex items-center gap-2\">\n <Workflow className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"text-sm font-semibold text-text-primary\">{thing.workflowName}</span>\n </div>\n {facts.length > 0 ? (\n <dl className=\"m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm\">\n {facts.map((fact) => (\n <div key={fact.id} className=\"contents\">\n <dt className=\"text-text-secondary\">{fact.label}</dt>\n <dd className=\"m-0 text-text-primary\">{fact.value}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n {thing.firstSeenAt ? (\n <p className=\"m-0 text-xs text-text-muted\">\n {tr('notifications.v3.thing.firstSeen', 'First seen {{when}}', {\n when: when.moment(thing.firstSeenAt),\n })}\n </p>\n ) : null}\n {actionUrl ? (\n <div>\n <Button size=\"sm\" variant=\"outline\" onClick={() => follow(actionUrl)}>\n {tr('notifications.v3.thing.openRun', 'Open the run')}\n </Button>\n </div>\n ) : null}\n </section>\n );\n}\n\nconst EVENT_ICON: Record<EventTone, typeof Clock> = {\n ok: CheckCircle2,\n bad: XCircle,\n waiting: Clock,\n neutral: Clock,\n};\nconst EVENT_TEXT: Record<EventTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n neutral: 'text-text-muted',\n};\n\nfunction Timeline({ events }: { events: NotificationDetailData['events'] }) {\n const tr = useTr();\n const when = useWhenLabels();\n const items = timeline(events, tr);\n if (items.length === 0) return null;\n return (\n <section\n className=\"flex flex-col gap-2\"\n aria-label={tr('notifications.v3.timeline', 'What happened')}\n >\n <h3 className=\"m-0 text-xs font-medium text-text-muted\">\n {tr('notifications.v3.timeline', 'What happened')}\n </h3>\n <ol className=\"m-0 flex list-none flex-col gap-2 p-0\" data-testid=\"panel-timeline\">\n {items.map((event) => {\n const Icon = EVENT_ICON[event.tone];\n return (\n <li key={event.id} className=\"flex items-center gap-2 text-sm\">\n <Icon className={`size-4 ${EVENT_TEXT[event.tone]}`} aria-hidden=\"true\" />\n <span className=\"flex-1 text-text-primary\">{event.words}</span>\n <time className=\"text-xs text-text-muted\" dateTime={event.at}>\n {when.moment(event.at)}\n </time>\n </li>\n );\n })}\n </ol>\n </section>\n );\n}\n"],"mappings":";;;;;;;;;;;;AA0BA,SAASA,EAAO,GAAa;CAC3B,AAAKC,EAAcC,CAAG,KAAG,OAAO,KAAKA,GAAK,UAAU,qBAAqB;AAC3E;AAEA,SAAgBC,EAAwB,EACtC,OACA,YACA,iBACA,cACA,gBAOC;CACD,IAAMC,IAAKC,EAAM,GACX,EAAE,UAAO,aAAUC,EAAsBC,CAAE,GAC3CC,IAAQC,EAAM,WAAW,UAAUA,EAAM,eAAe,MACxDC,IAAeF,IAAQG,EAA4BH,CAAK,IAAI;CAElE,OACE,kBAACI,GAAD;EACE,MAAM,EAAQL;EACd,eAAe,MAAUM,IAAO,KAAA,IAAYC,EAAQ;EACpD,OAAOJ,GAAc,SAASN,EAAG,kCAAkC,cAAc;EACjF,KAAKM,IAAe,kBAACK,GAAD,EAAwB,gBAAe,CAAA,IAAI,KAAA;EAC/D,MACEL,IACE,kBAACM,GAAD;GAAU,MAAK;GACb,UAAA,kBAACC,GAAD,EAAwB,gBAAe,CAAA;EAC/B,CAAA,IACR,KAAA;EAEN,YAAYb,EAAG,gCAAgC,OAAO;EACtD,eAAY;EACZ,QACEM,IACE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACQ,GAAD;IAAQ,SAAQ;IAAU,eAAeC,EAAaT,EAAa,EAAE;IAClE,UAAAN,EAAG,+BAA+B,gBAAgB;GAC7C,CAAA,GACPM,EAAa,aACZ,kBAACQ,GAAD;IAAQ,SAAQ;IAAQ,eAAeE,EAAUV,EAAa,EAAE;IAC7D,UAAAN,EAAG,4BAA4B,wBAAwB;GAClD,CAAA,IAER,kBAACc,GAAD;IAAQ,SAAQ;IAAQ,eAAeG,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AK,OAAO2B,EAAM,EAAE;MACjB,CAAA;KACJ;IANK,GAAAA,EAAM,EAMX;GAER,CAAC;EACC,CAAA,CACG;;AAEb"}
1
+ {"version":3,"file":"NotificationDetailPanel.js","names":["follow","navigateInApp","url","NotificationDetailPanel","tr","useTr","useNotificationDetail","id","ready","state","notification","mapBackendToMfeNotification","DetailPanel","next","onClose","PanelSub","IconTile","KindIcon","onMarkUnread","onArchive","onRestore","Button","Skeleton","LoadError","retry","PanelBody","when","useWhenLabels","needsAction","StatusChip","thing","notificationThing","data","actions","ThingBlock","index","action","ArrowUpRight","Timeline","facts","thingFacts","Workflow","fact","actionUrl","EVENT_ICON","CheckCircle2","XCircle","Clock","EVENT_TEXT","items","timeline","events","Icon","event"],"sources":["../../src/v2/NotificationDetailPanel.tsx"],"sourcesContent":["/**\n * A notification's panel (BOFF-16785, C1; decision 10, BE3): the message, \"the thing\" it is about\n * when the sender said (a workflow, its step, the attempt, how many runs it touched, since when),\n * its actions, and its timeline from the delivery events. Mark as unread and Archive at the foot.\n */\nimport { ArrowUpRight, CheckCircle2, Clock, Workflow, XCircle } from 'lucide-react';\nimport {\n Button,\n DetailPanel,\n IconTile,\n LoadError,\n Skeleton,\n StatusChip,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport type { Notification } from '../types';\nimport { useTr } from '../shared/hooks/useTr';\nimport { navigateInApp } from '../utils/inAppNavigation';\nimport { mapBackendToMfeNotification } from '../hooks/useNotifications';\nimport { needsAction } from './model/inbox';\nimport { KindIcon } from './KindIcon';\nimport { notificationThing, thingFacts } from './model/thing';\nimport { timeline, type EventTone } from './model/events';\nimport { useNotificationDetail, type NotificationDetailData } from './useNotificationDetail';\n\n/** Open an action's address: inside the app when it is one of ours, else in a new tab. */\nfunction follow(url: string) {\n if (!navigateInApp(url)) window.open(url, '_blank', 'noopener,noreferrer');\n}\n\nexport function NotificationDetailPanel({\n id,\n onClose,\n onMarkUnread,\n onArchive,\n onRestore,\n}: {\n id: string | null;\n onClose: () => void;\n /** The person's own inbox: absent in the admins' delivery log, which only reads. */\n onMarkUnread?: (id: string) => void;\n onArchive?: (id: string) => void;\n onRestore?: (id: string) => void;\n}) {\n const tr = useTr();\n const { state, retry } = useNotificationDetail(id);\n const ready = state.status === 'ready' ? state.notification : null;\n const notification = ready ? mapBackendToMfeNotification(ready) : null;\n\n return (\n <DetailPanel\n open={Boolean(id)}\n onOpenChange={(next) => (next ? undefined : onClose())}\n title={notification?.title ?? tr('notifications.v3.panel.loading', 'Notification')}\n sub={notification ? <PanelSub notification={notification} /> : undefined}\n tile={\n notification ? (\n <IconTile size=\"md\">\n <KindIcon notification={notification} />\n </IconTile>\n ) : undefined\n }\n closeLabel={tr('notifications.v3.panel.close', 'Close')}\n data-testid=\"notification-panel\"\n footer={\n notification && onMarkUnread && onArchive && onRestore ? (\n <div className=\"flex w-full flex-wrap gap-2\">\n <Button variant=\"outline\" onClick={() => onMarkUnread(notification.id)}>\n {tr('notifications.v3.markUnread', 'Mark as unread')}\n </Button>\n {notification.archivedAt ? (\n <Button variant=\"ghost\" onClick={() => onRestore(notification.id)}>\n {tr('notifications.v3.restore', 'Move back to the inbox')}\n </Button>\n ) : (\n <Button variant=\"ghost\" onClick={() => onArchive(notification.id)}>\n {tr('notifications.v3.archive', 'Archive')}\n </Button>\n )}\n </div>\n ) : undefined\n }\n >\n {state.status === 'loading' ? (\n <div className=\"flex flex-col gap-3\" aria-busy=\"true\">\n <Skeleton className=\"h-4 w-3/4\" />\n <Skeleton className=\"h-4 w-2/3\" />\n <Skeleton className=\"h-24 w-full\" />\n </div>\n ) : state.status === 'failed' ? (\n <LoadError\n what={tr('notifications.v3.panel.what', 'This notification')}\n error={state.error}\n onRetry={retry}\n />\n ) : state.status === 'missing' || !ready || !notification ? (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.panel.missing',\n 'This notification isn’t available any more. It may have been deleted.'\n )}\n </p>\n ) : (\n <PanelBody notification={notification} data={ready} />\n )}\n </DetailPanel>\n );\n}\n\nfunction PanelSub({ notification }: { notification: Notification }) {\n const tr = useTr();\n const when = useWhenLabels();\n return (\n <span className=\"flex flex-wrap items-center gap-2\">\n <time dateTime={notification.createdAt}>{when.moment(notification.createdAt)}</time>\n {needsAction(notification) ? (\n <StatusChip status=\"warn\">{tr('notifications.v3.needsYou', 'Needs you')}</StatusChip>\n ) : null}\n </span>\n );\n}\n\nfunction PanelBody({\n notification,\n data,\n}: {\n notification: Notification;\n data: NotificationDetailData;\n}) {\n const tr = useTr();\n const thing = notificationThing(data.metadata);\n const actions = notification.actions;\n return (\n <div className=\"flex flex-col gap-5\">\n <p className=\"m-0 text-sm whitespace-pre-wrap text-text-primary\" data-testid=\"panel-message\">\n {notification.body}\n </p>\n {thing ? <ThingBlock thing={thing} actionUrl={notification.actionUrl} /> : null}\n {actions.length > 0 || (notification.actionUrl && !thing) ? (\n <div className=\"flex flex-wrap gap-2\" data-testid=\"panel-actions\">\n {actions.map((action, index) => (\n <Button\n key={action.id}\n variant={index === 0 ? 'default' : 'outline'}\n onClick={() => follow(action.url)}\n >\n {action.label}\n </Button>\n ))}\n {/* \"Open the run\" in the thing's block already goes there. */}\n {actions.length === 0 && notification.actionUrl && !thing ? (\n <Button onClick={() => follow(notification.actionUrl ?? '')}>\n <ArrowUpRight aria-hidden=\"true\" />\n {tr('notifications.v3.panel.open', 'Open where it happened')}\n </Button>\n ) : null}\n </div>\n ) : null}\n <Timeline events={data.events} />\n </div>\n );\n}\n\nfunction ThingBlock({\n thing,\n actionUrl,\n}: {\n thing: NonNullable<ReturnType<typeof notificationThing>>;\n actionUrl?: string;\n}) {\n const tr = useTr();\n const when = useWhenLabels();\n const facts = thingFacts(thing, tr);\n return (\n <section\n className=\"flex flex-col gap-2 rounded-lg border border-border-subtle bg-bg-sunken p-3\"\n aria-label={tr('notifications.v3.thing.label', 'What it’s about')}\n data-testid=\"panel-thing\"\n >\n <div className=\"flex items-center gap-2\">\n <Workflow className=\"size-4 text-text-secondary\" aria-hidden=\"true\" />\n <span className=\"text-sm font-semibold text-text-primary\">{thing.workflowName}</span>\n </div>\n {facts.length > 0 ? (\n <dl className=\"m-0 grid grid-cols-[auto_1fr] gap-x-4 gap-y-1 text-sm\">\n {facts.map((fact) => (\n <div key={fact.id} className=\"contents\">\n <dt className=\"text-text-secondary\">{fact.label}</dt>\n <dd className=\"m-0 text-text-primary\">{fact.value}</dd>\n </div>\n ))}\n </dl>\n ) : null}\n {thing.firstSeenAt ? (\n <p className=\"m-0 text-xs text-text-muted\">\n {tr('notifications.v3.thing.firstSeen', 'First seen {{when}}', {\n when: when.moment(thing.firstSeenAt),\n })}\n </p>\n ) : null}\n {actionUrl ? (\n <div>\n <Button size=\"sm\" variant=\"outline\" onClick={() => follow(actionUrl)}>\n {tr('notifications.v3.thing.openRun', 'Open the run')}\n </Button>\n </div>\n ) : null}\n </section>\n );\n}\n\nconst EVENT_ICON: Record<EventTone, typeof Clock> = {\n ok: CheckCircle2,\n bad: XCircle,\n waiting: Clock,\n neutral: Clock,\n};\nconst EVENT_TEXT: Record<EventTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n neutral: 'text-text-muted',\n};\n\nfunction Timeline({ events }: { events: NotificationDetailData['events'] }) {\n const tr = useTr();\n const when = useWhenLabels();\n const items = timeline(events, tr);\n if (items.length === 0) return null;\n return (\n <section\n className=\"flex flex-col gap-2\"\n aria-label={tr('notifications.v3.timeline', 'What happened')}\n >\n <h3 className=\"m-0 text-xs font-medium text-text-muted\">\n {tr('notifications.v3.timeline', 'What happened')}\n </h3>\n <ol className=\"m-0 flex list-none flex-col gap-2 p-0\" data-testid=\"panel-timeline\">\n {items.map((event) => {\n const Icon = EVENT_ICON[event.tone];\n return (\n <li key={event.id} className=\"flex items-center gap-2 text-sm\">\n <Icon className={`size-4 ${EVENT_TEXT[event.tone]}`} aria-hidden=\"true\" />\n <span className=\"flex-1 text-text-primary\">{event.words}</span>\n <time className=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A,CACG;;AAEb"}
@@ -0,0 +1,9 @@
1
+ export declare function ChoiceSelect<T extends string>({ id, value, options, word, onChange, disabled, className, }: {
2
+ id: string;
3
+ value: T;
4
+ options: readonly T[];
5
+ word: (option: T) => string;
6
+ onChange: (option: T) => void;
7
+ disabled?: boolean;
8
+ className?: string;
9
+ }): import('react').JSX.Element;
@@ -0,0 +1,24 @@
1
+ import { jsx as e, jsxs as t } from "react/jsx-runtime";
2
+ import { Select as n, SelectContent as r, SelectItem as i, SelectTrigger as a, SelectValue as o } from "@burdenoff/fe-libs/ui";
3
+ // src/v2/admin/ChoiceSelect.tsx
4
+ function s({ id: s, value: c, options: l, word: u, onChange: d, disabled: f, className: p }) {
5
+ return /* @__PURE__ */ t(n, {
6
+ value: c,
7
+ disabled: f,
8
+ onValueChange: (e) => {
9
+ let t = l.find((t) => t === e);
10
+ t && d(t);
11
+ },
12
+ children: [/* @__PURE__ */ e(a, {
13
+ id: s,
14
+ className: p,
15
+ children: /* @__PURE__ */ e(o, {})
16
+ }), /* @__PURE__ */ e(r, { children: l.map((t) => /* @__PURE__ */ e(i, {
17
+ value: t,
18
+ children: u(t)
19
+ }, t)) })]
20
+ });
21
+ }
22
+ export { s as ChoiceSelect };
23
+
24
+ //# sourceMappingURL=ChoiceSelect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChoiceSelect.js","names":["ChoiceSelect","Select","picked","options","option","next","onChange","SelectTrigger","SelectValue","SelectContent","SelectItem","word"],"sources":["../../../src/v2/admin/ChoiceSelect.tsx"],"sourcesContent":["/**\n * One choice from a short fixed list (BOFF-16785, C2): what a template or topic is about, and\n * which channel a template is sent by. Shows each option's word, never its stored value.\n */\nimport {\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\n\nexport function ChoiceSelect<T extends string>({\n id,\n value,\n options,\n word,\n onChange,\n disabled,\n className,\n}: {\n id: string;\n value: T;\n options: readonly T[];\n word: (option: T) => string;\n onChange: (option: T) => void;\n disabled?: boolean;\n className?: string;\n}) {\n return (\n <Select\n value={value}\n disabled={disabled}\n onValueChange={(next) => {\n const picked = options.find((option) => option === next);\n if (picked) onChange(picked);\n }}\n >\n <SelectTrigger id={id} className={className}>\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {options.map((option) => (\n <SelectItem key={option} value={option}>\n {word(option)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n );\n}\n"],"mappings":";;;AAYA,SAAgBA,EAA+B,EAC7C,OACA,UACA,YACA,SACA,aACA,aACA,gBASC;CACD,OACE,kBAACC,GAAD;EACS;EACG;EACV,gBAAgB,MAAS;GACvB,IAAMC,IAASC,EAAQ,MAAM,MAAWC,MAAWC,CAAI;GACvD,AAAIH,KAAQI,EAASJ,CAAM;EAC7B;EANF,UAAA,CAQE,kBAACK,GAAD;GAAmB;GAAe;GAChC,UAAA,kBAACC,GAAD,CAAc,CAAA;EACD,CAAA,GACf,kBAACC,GAAD,EAAA,UACGN,EAAQ,KAAK,MACZ,kBAACO,GAAD;GAAyB,OAAON;GAC7B,UAAAO,EAAKP,CAAM;EACF,GAFKA,CAEL,CACb,EACY,CAAA,CACT;;AAEZ"}
@@ -0,0 +1 @@
1
+ export declare function DeliveryLogPage(): import('react').JSX.Element;
@@ -0,0 +1,207 @@
1
+ import { useNotificationAdmin as e } from "../../hooks/useNotificationAdmin.js";
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 { NotificationCenterPage as i } from "../../pages/NotificationCenterPage.js";
6
+ import { NotificationDetailPanel as a } from "../NotificationDetailPanel.js";
7
+ import { groupByDay as o } from "../model/days.js";
8
+ import { channelWord as s, deliveryState as c } from "./words.js";
9
+ import { useMemo as l, useState as u } from "react";
10
+ import { useFeatureFlagDetails as d } from "@burdenoff/fe-libs/shared/feature-flags";
11
+ import { CheckCircle2 as f, Clock as p, XCircle as m } from "lucide-react";
12
+ import { jsx as h, jsxs as g } from "react/jsx-runtime";
13
+ import { PageHeader as _ } from "@burdenoff/fe-libs/chrome";
14
+ import { EmptyState as v, LoadError as y, Segmented as b, Skeleton as x, StatusChip as S, useWhenLabels as C } from "@burdenoff/fe-libs/ui";
15
+ // src/v2/admin/DeliveryLogPage.tsx
16
+ var w = {
17
+ ok: f,
18
+ bad: m,
19
+ waiting: p
20
+ }, T = new Intl.NumberFormat(), E = {
21
+ ok: "text-status-success-text",
22
+ bad: "text-status-error-text",
23
+ waiting: "text-status-warning-text"
24
+ };
25
+ function D() {
26
+ let e = d("notification.history");
27
+ return e && e.value ? /* @__PURE__ */ h(r, {
28
+ tool: "deliveryLog",
29
+ back: !1,
30
+ children: /* @__PURE__ */ h(P, {})
31
+ }) : /* @__PURE__ */ h(i, {});
32
+ }
33
+ function O(e, t) {
34
+ return e.recipientEmail || e.recipientPhone || t("notifications.v3.log.inApp", "someone in the app");
35
+ }
36
+ function k({ counts: e, tone: n, onTone: r }) {
37
+ let i = t();
38
+ return /* @__PURE__ */ g("div", {
39
+ className: "flex flex-wrap items-center gap-2",
40
+ "data-testid": "log-counts",
41
+ children: [
42
+ /* @__PURE__ */ h(S, {
43
+ status: "ok",
44
+ children: i("notifications.v3.log.delivered", "{{count}} delivered", { count: T.format(e.ok) })
45
+ }),
46
+ /* @__PURE__ */ h(S, {
47
+ status: "bad",
48
+ children: i("notifications.v3.log.failed", "{{count}} didn’t arrive", { count: T.format(e.bad) })
49
+ }),
50
+ /* @__PURE__ */ h(S, {
51
+ status: "waiting",
52
+ children: i("notifications.v3.log.waiting", "{{count}} waiting", { count: T.format(e.waiting) })
53
+ }),
54
+ /* @__PURE__ */ h("span", { className: "flex-1" }),
55
+ /* @__PURE__ */ h(b, {
56
+ "aria-label": i("notifications.v3.log.show", "Show"),
57
+ value: n,
58
+ onValueChange: r,
59
+ options: [
60
+ {
61
+ value: "any",
62
+ label: i("notifications.v3.log.any", "All")
63
+ },
64
+ {
65
+ value: "ok",
66
+ label: i("notifications.v3.delivery.delivered", "Delivered")
67
+ },
68
+ {
69
+ value: "bad",
70
+ label: i("notifications.v3.delivery.failed", "Didn’t arrive")
71
+ },
72
+ {
73
+ value: "waiting",
74
+ label: i("notifications.v3.log.waitingShort", "Waiting")
75
+ }
76
+ ]
77
+ })
78
+ ]
79
+ });
80
+ }
81
+ function A({ item: e, onOpen: n }) {
82
+ let r = t(), i = C(), { notification: a, state: o } = e, c = w[o.tone];
83
+ return /* @__PURE__ */ h("li", {
84
+ "data-row-id": a.id,
85
+ children: /* @__PURE__ */ g("button", {
86
+ type: "button",
87
+ className: "flex w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-3 py-2.5 text-left",
88
+ onClick: () => n(a.id),
89
+ children: [
90
+ /* @__PURE__ */ h(c, {
91
+ className: `size-4 shrink-0 ${E[o.tone]}`,
92
+ "aria-hidden": "true"
93
+ }),
94
+ /* @__PURE__ */ g("span", {
95
+ className: "min-w-0 flex-1",
96
+ children: [/* @__PURE__ */ h("span", {
97
+ className: "block truncate text-sm text-text-primary",
98
+ children: r("notifications.v3.log.line", "{{title}} → {{who}}", {
99
+ title: a.title,
100
+ who: O(a, r)
101
+ })
102
+ }), /* @__PURE__ */ g("span", {
103
+ className: "block truncate text-xs text-text-secondary",
104
+ children: [
105
+ s(a.channel, r),
106
+ " · ",
107
+ o.word
108
+ ]
109
+ })]
110
+ }),
111
+ /* @__PURE__ */ h("time", {
112
+ className: "shrink-0 text-xs text-text-muted",
113
+ dateTime: a.createdAt,
114
+ children: i.moment(a.createdAt)
115
+ })
116
+ ]
117
+ })
118
+ });
119
+ }
120
+ function j({ items: e, onOpen: n }) {
121
+ let r = t();
122
+ return /* @__PURE__ */ h("div", {
123
+ className: "flex flex-col gap-4",
124
+ "data-testid": "log-rows",
125
+ children: o(e, r).map((e) => /* @__PURE__ */ g("section", {
126
+ "aria-label": e.label,
127
+ className: "flex flex-col gap-1",
128
+ children: [/* @__PURE__ */ h("h2", {
129
+ className: "m-0 px-1 text-xs font-medium text-text-muted",
130
+ children: e.label
131
+ }), /* @__PURE__ */ h("ul", {
132
+ 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",
133
+ children: e.items.map((e) => /* @__PURE__ */ h(A, {
134
+ item: e,
135
+ onOpen: n
136
+ }, e.notification.id))
137
+ })]
138
+ }, e.key))
139
+ });
140
+ }
141
+ function M({ filtered: e }) {
142
+ let n = t();
143
+ return /* @__PURE__ */ h(v, {
144
+ kind: e ? "filtered" : "first-use",
145
+ title: e ? n("notifications.v3.log.noneTitle", "Nothing here") : n("notifications.v3.log.emptyTitle", "Nothing sent yet"),
146
+ description: n("notifications.v3.log.emptyBody", "Each notification sent is listed here with what happened to it.")
147
+ });
148
+ }
149
+ function N() {
150
+ return /* @__PURE__ */ h("div", {
151
+ className: "flex flex-col gap-2",
152
+ "aria-busy": "true",
153
+ children: Array.from({ length: 6 }, (e, t) => /* @__PURE__ */ h(x, { className: "h-12 w-full rounded-lg" }, t))
154
+ });
155
+ }
156
+ function P() {
157
+ let r = t(), i = n(), o = e(), [s, d] = u("any"), [f, p] = u(null), m = l(() => o.notifications.map((e) => ({
158
+ notification: e,
159
+ state: c(e.deliveryStatus, r),
160
+ createdAt: e.createdAt
161
+ })), [o.notifications, r]), v = l(() => {
162
+ let e = {
163
+ ok: 0,
164
+ bad: 0,
165
+ waiting: 0
166
+ };
167
+ for (let t of m) e[t.state.tone] += 1;
168
+ return e;
169
+ }, [m]), b = s === "any" ? m : m.filter((e) => e.state.tone === s), x = m.length === 0, S = /* @__PURE__ */ h(j, {
170
+ items: b,
171
+ onOpen: p
172
+ });
173
+ return o.error && x ? S = /* @__PURE__ */ h(y, {
174
+ what: r("notifications.v3.log.title", "Delivery log"),
175
+ error: o.error,
176
+ onRetry: () => void o.refetch()
177
+ }) : o.isLoading && x ? S = /* @__PURE__ */ h(N, {}) : b.length === 0 && (S = /* @__PURE__ */ h(M, { filtered: s !== "any" })), /* @__PURE__ */ g("div", {
178
+ "data-account-pages-v2": "notification-delivery-log",
179
+ className: "flex w-full min-w-0 flex-col",
180
+ children: [
181
+ /* @__PURE__ */ h(_, {
182
+ variant: "compact",
183
+ title: r("notifications.v3.log.title", "Delivery log"),
184
+ description: r("notifications.v3.log.purpose", "Every notification sent, and whether it arrived."),
185
+ back: {
186
+ label: r("notifications.v3.title", "Notifications"),
187
+ to: i.inbox
188
+ }
189
+ }),
190
+ /* @__PURE__ */ g("div", {
191
+ className: "flex flex-col gap-3",
192
+ children: [/* @__PURE__ */ h(k, {
193
+ counts: v,
194
+ tone: s,
195
+ onTone: d
196
+ }), S]
197
+ }),
198
+ /* @__PURE__ */ h(a, {
199
+ id: f,
200
+ onClose: () => p(null)
201
+ })
202
+ ]
203
+ });
204
+ }
205
+ export { D as DeliveryLogPage };
206
+
207
+ //# sourceMappingURL=DeliveryLogPage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DeliveryLogPage.js","names":["TONE_ICON","CheckCircle2","XCircle","Clock","COUNT","TONE_TEXT","DeliveryLogPage","details","useFeatureFlagDetails","AdminPageV2","DeliveryLog","NotificationCenterPage","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","paths","useNotificationPaths","admin","useNotificationAdmin","setTone","useState","openId","setOpenId","withState","useMemo","deliveryState","out","shown","empty","body","LoadError","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 { 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 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 { NotificationCenterPage } from '../../pages/NotificationCenterPage';\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 // As today: only while `notification.history` is on; otherwise the inbox shows in its place.\n if (!(details ? Boolean(details.value) : false)) return <NotificationCenterPage />;\n return (\n <AdminPageV2 tool=\"deliveryLog\" back={false}>\n <DeliveryLog />\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 <div data-account-pages-v2=\"notification-delivery-log\" className=\"flex w-full min-w-0 flex-col\">\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 </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA+BA,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;CAG5D,OADMD,KAAkBA,EAAQ,QAE9B,kBAACE,GAAD;EAAa,MAAK;EAAc,MAAM;EACpC,UAAA,kBAACC,GAAD,CAAc,CAAA;CACH,CAAA,IAJyC,kBAACC,GAAD,CAAyB,CAAA;AAMnF;AAEA,SAASC,EACP,GACA,GACQ;CACR,OACEC,EAAa,kBACbA,EAAa,kBACbC,EAAG,8BAA8B,oBAAoB;AAEzD;AAQA,SAASC,EAAe,EACtB,WACA,SACA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AAO1C,EAAG,8BAA8B,cAAc;IACtD,aAAaA,EACX,gCACA,kDACF;IACA,MAAM;KAAE,OAAOA,EAAG,0BAA0B,eAAe;KAAG,IAAI0B,EAAM;IAAM;GAC/E,CAAA;GACD,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAACzB,GAAD;KAAwB;KAAc;KAAM,QAAQ6B;IAAU,CAAA,GAC7DU,CACE;;GACL,kBAACG,GAAD;IAAyB,IAAIX;IAAQ,eAAeC,EAAU,IAAI;GAAI,CAAA;EACnE;;AAET"}
@@ -0,0 +1,6 @@
1
+ import { TemplateDetail } from './templateText';
2
+ export declare function InsertDetail({ details, onInsert, testId, }: {
3
+ details: readonly TemplateDetail[];
4
+ onInsert: (detail: TemplateDetail) => void;
5
+ testId?: string;
6
+ }): import('react').JSX.Element;
@@ -0,0 +1,77 @@
1
+ import { useTr as e } from "../../shared/hooks/useTr.js";
2
+ import { COMMON_DETAILS as t, detailLabel as n, detailName as r } from "./templateText.js";
3
+ import { useId as i, useState as a } from "react";
4
+ import { Plus as o } from "lucide-react";
5
+ import { Fragment as s, jsx as c, jsxs as l } from "react/jsx-runtime";
6
+ import { Button as u, DropdownMenu as d, DropdownMenuContent as f, DropdownMenuItem as p, DropdownMenuSeparator as m, DropdownMenuTrigger as h, Input as g, Label as _, ResponsiveDialog as v, ResponsiveDialogContent as y, ResponsiveDialogDescription as b, ResponsiveDialogFooter as x, ResponsiveDialogHeader as S, ResponsiveDialogTitle as C } from "@burdenoff/fe-libs/ui";
7
+ // src/v2/admin/InsertDetail.tsx
8
+ function w({ details: w, onInsert: T, testId: E }) {
9
+ let D = e(), O = i(), [k, A] = a(!1), [j, M] = a(""), N = new Set(w.map((e) => e.name)), P = t.filter((e) => !N.has(e.name)), F = r(j), I = () => {
10
+ F && (T(w.find((e) => e.name === F) ?? {
11
+ name: F,
12
+ type: "string",
13
+ defaultValue: ""
14
+ }), A(!1), M(""));
15
+ };
16
+ return /* @__PURE__ */ l(s, { children: [/* @__PURE__ */ l(d, { children: [/* @__PURE__ */ c(h, {
17
+ asChild: !0,
18
+ children: /* @__PURE__ */ l(u, {
19
+ size: "sm",
20
+ variant: "outline",
21
+ "data-testid": E,
22
+ children: [/* @__PURE__ */ c(o, { "aria-hidden": "true" }), D("notifications.v3.template.insert", "Insert")]
23
+ })
24
+ }), /* @__PURE__ */ l(f, {
25
+ align: "end",
26
+ children: [
27
+ w.map((e) => /* @__PURE__ */ c(p, {
28
+ onSelect: () => T(e),
29
+ children: n(e.name)
30
+ }, e.name)),
31
+ w.length > 0 && P.length > 0 ? /* @__PURE__ */ c(m, {}) : null,
32
+ P.map((e) => /* @__PURE__ */ c(p, {
33
+ onSelect: () => T(e),
34
+ children: n(e.name)
35
+ }, e.name)),
36
+ /* @__PURE__ */ c(m, {}),
37
+ /* @__PURE__ */ c(p, {
38
+ onSelect: () => A(!0),
39
+ children: D("notifications.v3.template.anotherDetail", "Another detail…")
40
+ })
41
+ ]
42
+ })] }), /* @__PURE__ */ c(v, {
43
+ open: k,
44
+ onOpenChange: A,
45
+ children: /* @__PURE__ */ l(y, { children: [/* @__PURE__ */ l(S, { children: [/* @__PURE__ */ c(C, { children: D("notifications.v3.template.newDetail", "Add a detail") }), /* @__PURE__ */ c(b, { children: D("notifications.v3.template.newDetailHelp", "Something filled in for each person when it’s sent, like their plan or a date.") })] }), /* @__PURE__ */ l("form", {
46
+ className: "flex flex-col gap-4",
47
+ onSubmit: (e) => {
48
+ e.preventDefault(), I();
49
+ },
50
+ children: [/* @__PURE__ */ l("div", {
51
+ className: "flex flex-col gap-1.5",
52
+ children: [/* @__PURE__ */ c(_, {
53
+ htmlFor: `${O}-detail`,
54
+ children: D("notifications.v3.template.detailName", "Name")
55
+ }), /* @__PURE__ */ c(g, {
56
+ id: `${O}-detail`,
57
+ autoFocus: !0,
58
+ value: j,
59
+ placeholder: D("notifications.v3.template.detailPlaceholder", "For example: Plan name"),
60
+ onChange: (e) => M(e.target.value)
61
+ })]
62
+ }), /* @__PURE__ */ l(x, { children: [/* @__PURE__ */ c(u, {
63
+ type: "button",
64
+ variant: "ghost",
65
+ onClick: () => A(!1),
66
+ children: D("notifications.v3.cancel", "Cancel")
67
+ }), /* @__PURE__ */ c(u, {
68
+ type: "submit",
69
+ disabled: !F,
70
+ children: D("notifications.v3.template.insert", "Insert")
71
+ })] })]
72
+ })] })
73
+ })] });
74
+ }
75
+ export { w as InsertDetail };
76
+
77
+ //# sourceMappingURL=InsertDetail.js.map