@burdenoff/microfe-notification 2026.1129.1 → 2026.1129.3

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 (75) hide show
  1. package/dist/NotificationRoutes.js +73 -72
  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/hooks/useSendNotification.d.ts +1 -1
  8. package/dist/hooks/useSendNotification.js.map +1 -1
  9. package/dist/translations/en.d.ts +179 -0
  10. package/dist/v2/InboxPage.js +113 -97
  11. package/dist/v2/InboxPage.js.map +1 -1
  12. package/dist/v2/NotificationDetailPanel.d.ts +9 -4
  13. package/dist/v2/NotificationDetailPanel.js +66 -51
  14. package/dist/v2/NotificationDetailPanel.js.map +1 -1
  15. package/dist/v2/admin/ChoiceSelect.d.ts +9 -0
  16. package/dist/v2/admin/ChoiceSelect.js +24 -0
  17. package/dist/v2/admin/ChoiceSelect.js.map +1 -0
  18. package/dist/v2/admin/DeliveryLogPage.d.ts +1 -0
  19. package/dist/v2/admin/DeliveryLogPage.js +207 -0
  20. package/dist/v2/admin/DeliveryLogPage.js.map +1 -0
  21. package/dist/v2/admin/InsertDetail.d.ts +6 -0
  22. package/dist/v2/admin/InsertDetail.js +77 -0
  23. package/dist/v2/admin/InsertDetail.js.map +1 -0
  24. package/dist/v2/admin/TemplateEditor.d.ts +6 -0
  25. package/dist/v2/admin/TemplateEditor.js +92 -0
  26. package/dist/v2/admin/TemplateEditor.js.map +1 -0
  27. package/dist/v2/admin/TemplateFields.d.ts +9 -0
  28. package/dist/v2/admin/TemplateFields.js +130 -0
  29. package/dist/v2/admin/TemplateFields.js.map +1 -0
  30. package/dist/v2/admin/TemplatePage.d.ts +1 -0
  31. package/dist/v2/admin/TemplatePage.js +62 -0
  32. package/dist/v2/admin/TemplatePage.js.map +1 -0
  33. package/dist/v2/admin/TemplatePreview.d.ts +8 -0
  34. package/dist/v2/admin/TemplatePreview.js +112 -0
  35. package/dist/v2/admin/TemplatePreview.js.map +1 -0
  36. package/dist/v2/admin/TemplatesPage.d.ts +1 -0
  37. package/dist/v2/admin/TemplatesPage.js +173 -0
  38. package/dist/v2/admin/TemplatesPage.js.map +1 -0
  39. package/dist/v2/admin/TopicDialog.d.ts +11 -0
  40. package/dist/v2/admin/TopicDialog.js +113 -0
  41. package/dist/v2/admin/TopicDialog.js.map +1 -0
  42. package/dist/v2/admin/TopicsPage.d.ts +1 -0
  43. package/dist/v2/admin/TopicsPage.js +152 -0
  44. package/dist/v2/admin/TopicsPage.js.map +1 -0
  45. package/dist/v2/admin/templateText.d.ts +35 -0
  46. package/dist/v2/admin/templateText.js +114 -0
  47. package/dist/v2/admin/templateText.js.map +1 -0
  48. package/dist/v2/admin/useTemplateDraft.d.ts +32 -0
  49. package/dist/v2/admin/useTemplateDraft.js +117 -0
  50. package/dist/v2/admin/useTemplateDraft.js.map +1 -0
  51. package/dist/v2/admin/words.d.ts +15 -0
  52. package/dist/v2/admin/words.js +67 -0
  53. package/dist/v2/admin/words.js.map +1 -0
  54. package/dist/v2/send/MessageTab.d.ts +4 -0
  55. package/dist/v2/send/MessageTab.js +152 -0
  56. package/dist/v2/send/MessageTab.js.map +1 -0
  57. package/dist/v2/send/PeopleTab.d.ts +4 -0
  58. package/dist/v2/send/PeopleTab.js +156 -0
  59. package/dist/v2/send/PeopleTab.js.map +1 -0
  60. package/dist/v2/send/SendNotificationDialog.d.ts +4 -0
  61. package/dist/v2/send/SendNotificationDialog.js +98 -0
  62. package/dist/v2/send/SendNotificationDialog.js.map +1 -0
  63. package/dist/v2/send/SendRedirect.d.ts +1 -0
  64. package/dist/v2/send/SendRedirect.js +20 -0
  65. package/dist/v2/send/SendRedirect.js.map +1 -0
  66. package/dist/v2/send/WhenTab.d.ts +4 -0
  67. package/dist/v2/send/WhenTab.js +64 -0
  68. package/dist/v2/send/WhenTab.js.map +1 -0
  69. package/dist/v2/send/sendModel.d.ts +47 -0
  70. package/dist/v2/send/sendModel.js +90 -0
  71. package/dist/v2/send/sendModel.js.map +1 -0
  72. package/dist/v2/send/useSendDraft.d.ts +24 -0
  73. package/dist/v2/send/useSendDraft.js +120 -0
  74. package/dist/v2/send/useSendDraft.js.map +1 -0
  75. package/package.json +1 -1
@@ -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,aAKC;CACD,IAAMD,IAAKE,EAAM;CACjB,OACE,kBAAC,OAAD;EAAK,WAAU;EAAoC,eAAY;EAA/D,UAAA;GACE,kBAACC,GAAD;IAAY,QAAO;IAChB,UAAAH,EAAG,kCAAkC,uBAAuB,EAC3D,OAAOV,EAAM,OAAOc,EAAO,EAAE,EAC/B,CAAC;GACS,CAAA;GACZ,kBAACD,GAAD;IAAY,QAAO;IAChB,UAAAH,EAAG,+BAA+B,2BAA2B,EAC5D,OAAOV,EAAM,OAAOc,EAAO,GAAG,EAChC,CAAC;G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@ -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
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InsertDetail.js","names":["_Fragment","InsertDetail","tr","useTr","id","useId","naming","setNaming","useState","label","setLabel","known","details","detail","common","COMMON_DETAILS","name","detailName","add","onInsert","Fragment","DropdownMenu","DropdownMenuTrigger","Button","testId","Plus","DropdownMenuContent","DropdownMenuItem","detailLabel","DropdownMenuSeparator","ResponsiveDialog","ResponsiveDialogContent","ResponsiveDialogHeader","ResponsiveDialogTitle","ResponsiveDialogDescription","event","Label","Input","ResponsiveDialogFooter"],"sources":["../../../src/v2/admin/InsertDetail.tsx"],"sourcesContent":["/**\n * Insert a detail (BOFF-16785, C2): the template's own details, a few common ones (first name, the\n * workflow, the step, a link), and \"Another detail…\", which names a new one. People never type\n * `{{variables}}`.\n */\nimport { useId, useState } from 'react';\nimport { Plus } from 'lucide-react';\nimport {\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuSeparator,\n DropdownMenuTrigger,\n Input,\n Label,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n} from '@burdenoff/fe-libs/ui';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { COMMON_DETAILS, detailLabel, detailName, type TemplateDetail } from './templateText';\n\nexport function InsertDetail({\n details,\n onInsert,\n testId,\n}: {\n details: readonly TemplateDetail[];\n onInsert: (detail: TemplateDetail) => void;\n testId?: string;\n}) {\n const tr = useTr();\n const id = useId();\n const [naming, setNaming] = useState(false);\n const [label, setLabel] = useState('');\n const known = new Set(details.map((detail) => detail.name));\n const common = COMMON_DETAILS.filter((detail) => !known.has(detail.name));\n const name = detailName(label);\n\n const add = () => {\n if (!name) return;\n onInsert(\n details.find((detail) => detail.name === name) ?? { name, type: 'string', defaultValue: '' }\n );\n setNaming(false);\n setLabel('');\n };\n\n return (\n <>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button size=\"sm\" variant=\"outline\" data-testid={testId}>\n <Plus aria-hidden=\"true\" />\n {tr('notifications.v3.template.insert', 'Insert')}\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n {details.map((detail) => (\n <DropdownMenuItem key={detail.name} onSelect={() => onInsert(detail)}>\n {detailLabel(detail.name)}\n </DropdownMenuItem>\n ))}\n {details.length > 0 && common.length > 0 ? <DropdownMenuSeparator /> : null}\n {common.map((detail) => (\n <DropdownMenuItem key={detail.name} onSelect={() => onInsert(detail)}>\n {detailLabel(detail.name)}\n </DropdownMenuItem>\n ))}\n <DropdownMenuSeparator />\n <DropdownMenuItem onSelect={() => setNaming(true)}>\n {tr('notifications.v3.template.anotherDetail', 'Another detail…')}\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n <ResponsiveDialog open={naming} onOpenChange={setNaming}>\n <ResponsiveDialogContent>\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>\n {tr('notifications.v3.template.newDetail', 'Add a detail')}\n </ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {tr(\n 'notifications.v3.template.newDetailHelp',\n 'Something filled in for each person when it’s sent, like their plan or a date.'\n )}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n <form\n className=\"flex flex-col gap-4\"\n onSubmit={(event) => {\n event.preventDefault();\n add();\n }}\n >\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-detail`}>\n {tr('notifications.v3.template.detailName', 'Name')}\n </Label>\n <Input\n id={`${id}-detail`}\n autoFocus\n value={label}\n placeholder={tr(\n 'notifications.v3.template.detailPlaceholder',\n 'For example: Plan name'\n )}\n onChange={(event) => setLabel(event.target.value)}\n />\n </div>\n <ResponsiveDialogFooter>\n <Button type=\"button\" variant=\"ghost\" onClick={() => setNaming(false)}>\n {tr('notifications.v3.cancel', 'Cancel')}\n </Button>\n <Button type=\"submit\" disabled={!name}>\n {tr('notifications.v3.template.insert', 'Insert')}\n </Button>\n </ResponsiveDialogFooter>\n </form>\n </ResponsiveDialogContent>\n </Res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B,kBAACF,GAAD;IAAkB,gBAAgBpB,EAAU,EAAI;IAC7C,UAAAL,EAAG,2CAA2C,iBAAiB;GAChD,CAAA;EACC;CACT,CAAA,CAAA,EAAA,CAAA,GACd,kBAAC4B,GAAD;EAAkB,MAAMxB;EAAQ,cAAcC;EAC5C,UAAA,kBAACwB,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UAAA,CACE,kBAACC,GAAD,EAAA,UACG/B,EAAG,uCAAuC,cAAc,EACpC,CAAA,GACvB,kBAACgC,GAAD,EAAA,UACGhC,EACC,2CACA,gFACF,EAC2B,CAAA,CACP,EAAA,CAAA,GACxB,kBAAC,QAAD;GACE,WAAU;GACV,WAAW,MAAU;IAEnB,AADAiC,EAAM,eAAe,GACrBjB,EAAI;GACN;GALF,UAAA,CAOE,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAACkB,GAAD;KAAO,SAAS,GAAGhC,EAAG;KACnB,UAAAF,EAAG,wCAAwC,MAAM;IAC7C,CAAA,GACP,kBAACmC,GAAD;KACE,IAAI,GAAGjC,EAAG;KACV,WAAA;KACA,OAAOK;KACP,aAAaP,EACX,+CACA,wBACF;KACA,WAAW,MAAUQ,EAASyB,EAAM,OAAO,KAAK;IACjD,CAAA,CACE;GACL,CAAA,GAAA,kBAACG,GAAD,EAAA,UAAA,CACE,kBAACf,GAAD;IAAQ,MAAK;IAAS,SAAQ;IAAQ,eAAehB,EAAU,EAAK;IACjE,UAAAL,EAAG,2BAA2B,QAAQ;GACjC,CAAA,GACR,kBAACqB,GAAD;IAAQ,MAAK;IAAS,UAAU,CAACP;IAC9B,UAAAd,EAAG,oCAAoC,QAAQ;GAC1C,CAAA,CACc,EAAA,CAAA,CACpB;EACiB,CAAA,CAAA,EAAA,CAAA;CACT,CAAA,CAClB,EAAA,CAAA;AAEN"}
@@ -0,0 +1,6 @@
1
+ import { BackendNotificationTemplate } from '../../hooks/useNotificationTemplates';
2
+ export declare function TemplateEditor({ template, onChanged, }: {
3
+ template: BackendNotificationTemplate | null;
4
+ /** Read the template again after turning it on or off. */
5
+ onChanged?: () => void;
6
+ }): import('react').JSX.Element;
@@ -0,0 +1,92 @@
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 } from "@burdenoff/fe-libs/ui";
13
+ // src/v2/admin/TemplateEditor.tsx
14
+ function _({ template: n, draft: r }) {
15
+ let i = e(), s = t(), c = n?.enabled ? /* @__PURE__ */ u(g, {
16
+ status: "ok",
17
+ children: i("notifications.v3.on", "On")
18
+ }) : /* @__PURE__ */ u(g, {
19
+ status: "paused",
20
+ children: i("notifications.v3.off", "Off")
21
+ });
22
+ return /* @__PURE__ */ u(f, {
23
+ 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, {
30
+ size: "md",
31
+ children: /* @__PURE__ */ u(l, { "aria-hidden": "true" })
32
+ }),
33
+ back: {
34
+ label: i("notifications.v3.templates.title", "Templates"),
35
+ to: s.templates
36
+ },
37
+ badge: n ? c : void 0,
38
+ primary: /* @__PURE__ */ u(p, {
39
+ busy: r.saving,
40
+ disabled: !r.ready,
41
+ onClick: () => void r.save(),
42
+ "data-testid": "template-save",
43
+ children: n ? i("notifications.v3.template.save", "Save") : i("notifications.v3.template.create", "Create template")
44
+ }),
45
+ more: n ? [{
46
+ 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()
49
+ }, {
50
+ id: "delete",
51
+ label: i("notifications.v3.templates.delete", "Delete"),
52
+ danger: !0,
53
+ onSelect: () => void r.remove()
54
+ }] : void 0
55
+ });
56
+ }
57
+ function v({ 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("div", {
60
+ "data-account-pages-v2": "notification-template",
61
+ className: "flex w-full min-w-0 flex-col",
62
+ children: [
63
+ /* @__PURE__ */ u(_, {
64
+ template: t,
65
+ draft: m
66
+ }),
67
+ m.problem ? /* @__PURE__ */ u(h, {
68
+ tone: "bad",
69
+ role: "alert",
70
+ className: "mb-4",
71
+ children: m.problem
72
+ }) : null,
73
+ /* @__PURE__ */ d("div", {
74
+ className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-6 max-lg:grid-cols-1",
75
+ children: [/* @__PURE__ */ u(n, {
76
+ template: t,
77
+ draft: m,
78
+ titleRef: f,
79
+ messageRef: p
80
+ }), /* @__PURE__ */ u(r, {
81
+ productName: l || o("notifications.v3.template.productFallback", "Your product"),
82
+ title: m.stored.title,
83
+ message: m.stored.message,
84
+ details: m.details
85
+ })]
86
+ })
87
+ ]
88
+ });
89
+ }
90
+ export { v as TemplateEditor };
91
+
92
+ //# sourceMappingURL=TemplateEditor.js.map
@@ -0,0 +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","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 } 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 <div data-account-pages-v2=\"notification-template\" className=\"flex w-full min-w-0 flex-col\">\n <TemplateHeader template={template} draft={draft} />\n {draft.problem ? (\n <Notice tone=\"bad\" role=\"alert\" className=\"mb-4\">\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 </div>\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,IAA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AAUE,GAAYE,CAAS;CACxE,OACE,kBAAC,OAAD;EAAK,yBAAsB;EAAwB,WAAU;EAA7D,UAAA;GACE,kBAACrB,GAAD;IAA0B;IAAiB;GAAQ,CAAA;GAClDS,EAAM,UACL,kBAACa,GAAD;IAAQ,MAAK;IAAM,MAAK;IAAQ,WAAU;IACvC,UAAAb,EAAM;GACD,CAAA,IACN;GACJ,kBAAC,OAAD;IAAK,WAAU;IAAf,UAAA,CACE,kBAACc,GAAD;KACY;KACH;KACG;KACE;IACb,CAAA,GACD,kBAACC,GAAD;KACE,aACEC,KAAexB,EAAG,6CAA6C,cAAc;KAE/E,OAAOQ,EAAM,OAAO;KACpB,SAASA,EAAM,OAAO;KACtB,SAASA,EAAM;IAChB,CAAA,CACE;;EACF;;AAET"}
@@ -0,0 +1,9 @@
1
+ import { RefObject } from 'react';
2
+ import { BackendNotificationTemplate } from '../../hooks/useNotificationTemplates';
3
+ import { TemplateDraft } from './useTemplateDraft';
4
+ export declare function TemplateFields({ template, draft, titleRef, messageRef, }: {
5
+ template: BackendNotificationTemplate | null;
6
+ draft: TemplateDraft;
7
+ titleRef: RefObject<HTMLInputElement | null>;
8
+ messageRef: RefObject<HTMLTextAreaElement | null>;
9
+ }): import('react').JSX.Element;
@@ -0,0 +1,130 @@
1
+ import { useTr as e } from "../../shared/hooks/useTr.js";
2
+ import { ChoiceSelect as t } from "./ChoiceSelect.js";
3
+ import { InsertDetail as n } from "./InsertDetail.js";
4
+ import { TEMPLATE_CHANNELS as r, TEMPLATE_KINDS as i, channelWord as a, kindWord as o } from "./words.js";
5
+ import { useId as s } from "react";
6
+ import { jsx as c, jsxs as l } from "react/jsx-runtime";
7
+ import { Input as u, Label as d, Notice as f, Textarea as p } from "@burdenoff/fe-libs/ui";
8
+ // src/v2/admin/TemplateFields.tsx
9
+ function m({ id: e, label: t, field: r, details: i, onInsert: a, children: o }) {
10
+ return /* @__PURE__ */ l("div", {
11
+ className: "flex flex-col gap-1.5",
12
+ children: [/* @__PURE__ */ l("div", {
13
+ className: "flex items-end justify-between gap-2",
14
+ children: [/* @__PURE__ */ c(d, {
15
+ htmlFor: e,
16
+ children: t
17
+ }), /* @__PURE__ */ c(n, {
18
+ details: i,
19
+ onInsert: (e) => a(r, e),
20
+ testId: `insert-${r}`
21
+ })]
22
+ }), o]
23
+ });
24
+ }
25
+ function h({ id: n, template: i, draft: o }) {
26
+ let s = e();
27
+ return /* @__PURE__ */ l("div", {
28
+ className: "flex flex-col gap-1.5",
29
+ children: [/* @__PURE__ */ c(d, {
30
+ htmlFor: n,
31
+ children: s("notifications.v3.template.channel", "Sent by")
32
+ }), i ? /* @__PURE__ */ c("p", {
33
+ className: "m-0 text-sm text-text-secondary",
34
+ children: s("notifications.v3.template.channelFixed", "{{channel}}. A template’s channel is set when it’s made.", { channel: a(i.channel, s) })
35
+ }) : /* @__PURE__ */ c(t, {
36
+ id: n,
37
+ value: o.channel,
38
+ options: r,
39
+ word: (e) => a(e, s),
40
+ onChange: o.setChannel,
41
+ className: "max-w-xs"
42
+ })]
43
+ });
44
+ }
45
+ function g({ template: n, draft: r, titleRef: a, messageRef: g }) {
46
+ let _ = e(), v = s();
47
+ return /* @__PURE__ */ l("section", {
48
+ className: "flex flex-col gap-4",
49
+ "aria-label": _("notifications.v3.template.form", "Message"),
50
+ children: [
51
+ /* @__PURE__ */ l("div", {
52
+ className: "grid grid-cols-2 gap-3 max-sm:grid-cols-1",
53
+ children: [/* @__PURE__ */ l("div", {
54
+ className: "flex flex-col gap-1.5",
55
+ children: [/* @__PURE__ */ c(d, {
56
+ htmlFor: `${v}-name`,
57
+ children: _("notifications.v3.template.name", "Name")
58
+ }), /* @__PURE__ */ c(u, {
59
+ id: `${v}-name`,
60
+ value: r.name,
61
+ placeholder: _("notifications.v3.template.namePlaceholder", "For example: Run failed"),
62
+ onChange: (e) => r.setName(e.target.value),
63
+ "data-testid": "template-name"
64
+ })]
65
+ }), /* @__PURE__ */ l("div", {
66
+ className: "flex flex-col gap-1.5",
67
+ children: [/* @__PURE__ */ c(d, {
68
+ htmlFor: `${v}-kind`,
69
+ children: _("notifications.v3.template.kind", "About")
70
+ }), /* @__PURE__ */ c(t, {
71
+ id: `${v}-kind`,
72
+ value: r.kind,
73
+ options: i,
74
+ word: (e) => o(e, _),
75
+ onChange: r.setKind,
76
+ disabled: !!n
77
+ })]
78
+ })]
79
+ }),
80
+ /* @__PURE__ */ c(h, {
81
+ id: `${v}-channel`,
82
+ template: n,
83
+ draft: r
84
+ }),
85
+ /* @__PURE__ */ c(m, {
86
+ id: `${v}-title`,
87
+ label: _("notifications.v3.template.title", "Title"),
88
+ field: "title",
89
+ details: r.details,
90
+ onInsert: r.insertInto,
91
+ children: /* @__PURE__ */ c(u, {
92
+ ref: a,
93
+ id: `${v}-title`,
94
+ value: r.title,
95
+ placeholder: _("notifications.v3.template.titlePlaceholder", "What people see first"),
96
+ onFocus: () => r.rememberField("title"),
97
+ onChange: (e) => r.setTitle(e.target.value),
98
+ "data-testid": "template-title"
99
+ })
100
+ }),
101
+ /* @__PURE__ */ l(m, {
102
+ id: `${v}-message`,
103
+ label: _("notifications.v3.template.message", "Message"),
104
+ field: "message",
105
+ details: r.details,
106
+ onInsert: r.insertInto,
107
+ children: [/* @__PURE__ */ c(p, {
108
+ ref: g,
109
+ id: `${v}-message`,
110
+ rows: 6,
111
+ value: r.message,
112
+ placeholder: _("notifications.v3.template.messagePlaceholder", "Write the message. Insert adds a person’s name, the workflow or a link."),
113
+ onFocus: () => r.rememberField("message"),
114
+ onChange: (e) => r.setMessage(e.target.value),
115
+ "data-testid": "template-message"
116
+ }), /* @__PURE__ */ c("p", {
117
+ className: "m-0 text-xs text-text-muted",
118
+ children: _("notifications.v3.template.detailsHelp", "Details in brackets, like [First name], are filled in when it’s sent.")
119
+ })]
120
+ }),
121
+ n?.htmlTemplate ? /* @__PURE__ */ c(f, {
122
+ tone: "info",
123
+ children: _("notifications.v3.template.htmlKept", "This template also has a designed email version. It stays as it is.")
124
+ }) : null
125
+ ]
126
+ });
127
+ }
128
+ export { g as TemplateFields };
129
+
130
+ //# sourceMappingURL=TemplateFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplateFields.js","names":["TextField","Label","id","label","InsertDetail","onInsert","field","detail","children","ChannelField","tr","useTr","template","channelWord","ChoiceSelect","draft","TEMPLATE_CHANNELS","option","TemplateFields","useId","Input","event","TEMPLATE_KINDS","kindWord","titleRef","Textarea","messageRef","Notice"],"sources":["../../../src/v2/admin/TemplateFields.tsx"],"sourcesContent":["/**\n * The template form (BOFF-16785, C2): name, what it's about, channel, title and message. Title\n * and message are edited as people read them (`[First name]`); Insert puts a detail at the cursor.\n */\nimport { useId, type ReactNode, type RefObject } from 'react';\nimport { Input, Label, Notice, Textarea } from '@burdenoff/fe-libs/ui';\nimport type { BackendNotificationTemplate } from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { ChoiceSelect } from './ChoiceSelect';\nimport { InsertDetail } from './InsertDetail';\nimport type { TemplateDetail } from './templateText';\nimport type { DraftField, TemplateDraft } from './useTemplateDraft';\nimport { channelWord, kindWord, TEMPLATE_CHANNELS, TEMPLATE_KINDS } from './words';\n\nfunction TextField({\n id,\n label,\n field,\n details,\n onInsert,\n children,\n}: {\n id: string;\n label: string;\n field: DraftField;\n details: TemplateDetail[];\n onInsert: (field: DraftField, detail: TemplateDetail) => void;\n children: ReactNode;\n}) {\n return (\n <div className=\"flex flex-col gap-1.5\">\n <div className=\"flex items-end justify-between gap-2\">\n <Label htmlFor={id}>{label}</Label>\n <InsertDetail\n details={details}\n onInsert={(detail) => onInsert(field, detail)}\n testId={`insert-${field}`}\n />\n </div>\n {children}\n </div>\n );\n}\n\nfunction ChannelField({\n id,\n template,\n draft,\n}: {\n id: string;\n template: BackendNotificationTemplate | null;\n draft: TemplateDraft;\n}) {\n const tr = useTr();\n return (\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={id}>{tr('notifications.v3.template.channel', 'Sent by')}</Label>\n {template ? (\n <p className=\"m-0 text-sm text-text-secondary\">\n {tr(\n 'notifications.v3.template.channelFixed',\n '{{channel}}. A template’s channel is set when it’s made.',\n { channel: channelWord(template.channel, tr) }\n )}\n </p>\n ) : (\n <ChoiceSelect\n id={id}\n value={draft.channel}\n options={TEMPLATE_CHANNELS}\n word={(option) => channelWord(option, tr)}\n onChange={draft.setChannel}\n className=\"max-w-xs\"\n />\n )}\n </div>\n );\n}\n\nexport function TemplateFields({\n template,\n draft,\n titleRef,\n messageRef,\n}: {\n template: BackendNotificationTemplate | null;\n draft: TemplateDraft;\n titleRef: RefObject<HTMLInputElement | null>;\n messageRef: RefObject<HTMLTextAreaElement | null>;\n}) {\n const tr = useTr();\n const id = useId();\n return (\n <section\n className=\"flex flex-col gap-4\"\n aria-label={tr('notifications.v3.template.form', 'Message')}\n >\n <div className=\"grid grid-cols-2 gap-3 max-sm:grid-cols-1\">\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-name`}>{tr('notifications.v3.template.name', 'Name')}</Label>\n <Input\n id={`${id}-name`}\n value={draft.name}\n placeholder={tr('notifications.v3.template.namePlaceholder', 'For example: Run failed')}\n onChange={(event) => draft.setName(event.target.value)}\n data-testid=\"template-name\"\n />\n </div>\n <div className=\"flex flex-col gap-1.5\">\n <Label htmlFor={`${id}-kind`}>{tr('notifications.v3.template.kind', 'About')}</Label>\n <ChoiceSelect\n id={`${id}-kind`}\n value={draft.kind}\n options={TEMPLATE_KINDS}\n word={(option) => kindWord(option, tr)}\n onChange={draft.setKind}\n disabled={Boolean(template)}\n />\n </div>\n </div>\n <ChannelField id={`${id}-channel`} template={template} draft={draft} />\n <TextField\n id={`${id}-title`}\n label={tr('notifications.v3.template.title', 'Title')}\n field=\"title\"\n details={draft.details}\n onInsert={draft.insertInto}\n >\n <Input\n ref={titleRef}\n id={`${id}-title`}\n value={draft.title}\n placeholder={tr('notifications.v3.template.titlePlaceholder', 'What people see first')}\n onFocus={() => draft.rememberField('title')}\n onChange={(event) => draft.setTitle(event.target.value)}\n data-testid=\"template-title\"\n />\n </TextField>\n <TextField\n id={`${id}-message`}\n label={tr('notifications.v3.template.message', 'Message')}\n field=\"message\"\n details={draft.details}\n onInsert={draft.insertInto}\n >\n <Textarea\n ref={messageRef}\n id={`${id}-message`}\n rows={6}\n value={draft.message}\n placeholder={tr(\n 'notifications.v3.template.messagePlaceholder',\n 'Write the message. Insert adds a person’s name, the workflow or a link.'\n )}\n onFocus={() => draft.rememberField('message')}\n onChange={(event) => draft.setMessage(event.target.value)}\n data-testid=\"template-message\"\n />\n <p className=\"m-0 text-xs text-text-muted\">\n {tr(\n 'notifications.v3.template.detailsHelp',\n 'Details in brackets, like [First name], are filled in when it’s sent.'\n )}\n </p>\n </TextField>\n {template?.htmlTemplate ? (\n <Notice tone=\"info\">\n {tr(\n 'notifications.v3.template.htmlKept',\n 'This template also has a designed email version. It stays as it is.'\n )}\n </Notice>\n ) : null}\n </section>\n );\n}\n"],"mappings":";;;;;;;;AAcA,SAASA,EAAU,EACjB,OACA,UACA,UACA,YACA,aACA,eAQC;CACD,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACC,GAAD;IAAO,SAASC;IAAK,UAAAC;GAAa,CAAA,GAClC,kBAACC,GAAD;IACW;IACT,WAAW,MAAWC,EAASC,GAAOC,CAAM;IAC5C,QAAQ,UAAUD;GACnB,CAAA,CACE;EACJ,CAAA,GAAAE,CACE;;AAET;AAEA,SAASC,EAAa,EACpB,OACA,aACA,YAKC;CACD,IAAMC,IAAKC,EAAM;CACjB,OACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACV,GAAD;GAAO,SAASC;GAAK,UAAAQ,EAAG,qCAAqC,SAAS;EAAS,CAAA,GAC9EE,IACC,kBAAC,KAAD;GAAG,WAAU;GACV,UAAAF,EACC,0CACA,4DACA,EAAE,SAASG,EAAYD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UA,EAAM;IAEhB,UAAA,kBAACK,GAAD;KACE,KAAKI;KACL,IAAI,GAAGtB,EAAG;KACV,OAAOa,EAAM;KACb,aAAaL,EAAG,8CAA8C,uBAAuB;KACrF,eAAeK,EAAM,cAAc,OAAO;KAC1C,WAAW,MAAUA,EAAM,SAASM,EAAM,OAAO,KAAK;KACtD,eAAY;IACb,CAAA;GACQ,CAAA;GACX,kBAACrB,GAAD;IACE,IAAI,GAAGE,EAAG;IACV,OAAOQ,EAAG,qCAAqC,SAAS;IACxD,OAAM;IACN,SAASK,EAAM;IACf,UAAUA,EAAM;IALlB,UAAA,CAOE,kBAACU,GAAD;KACE,KAAKC;KACL,IAAI,GAAGxB,EAAG;KACV,MAAM;KACN,OAAOa,EAAM;KACb,aAAaL,EACX,gDACA,yEACF;KACA,eAAeK,EAAM,cAAc,SAAS;KAC5C,WAAW,MAAUA,EAAM,WAAWM,EAAM,OAAO,KAAK;KACxD,eAAY;IACb,CAAA,GACD,kBAAC,KAAD;KAAG,WAAU;KACV,UAAAX,EACC,yCACA,uEACF;IACC,CAAA,CACM;;GACVE,GAAU,eACT,kBAACe,GAAD;IAAQ,MAAK;IACV,UAAAjB,EACC,sCACA,qEACF;GACM,CAAA,IACN;EACG;;AAEb"}
@@ -0,0 +1 @@
1
+ export declare function TemplatePage(): import('react').JSX.Element;
@@ -0,0 +1,62 @@
1
+ import { useNotificationTemplate as e } from "../../hooks/useNotificationTemplates.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 { TemplateEditor as i } from "./TemplateEditor.js";
6
+ import { Mail as a } from "lucide-react";
7
+ import { useParams as o } from "react-router";
8
+ import { jsx as s, jsxs as c } from "react/jsx-runtime";
9
+ import { PageHeader as l } from "@burdenoff/fe-libs/chrome";
10
+ import { EmptyState as u, IconTile as d, LoadError as f, Skeleton as p } from "@burdenoff/fe-libs/ui";
11
+ // src/v2/admin/TemplatePage.tsx
12
+ function m() {
13
+ return /* @__PURE__ */ s(r, {
14
+ tool: "templates",
15
+ back: !1,
16
+ children: /* @__PURE__ */ s(h, {})
17
+ });
18
+ }
19
+ function h() {
20
+ let r = t(), m = n(), { templateId: h } = o(), g = e(h), _ = {
21
+ label: r("notifications.v3.templates.title", "Templates"),
22
+ to: m.templates
23
+ };
24
+ return h ? g.isLoading && !g.template ? /* @__PURE__ */ c("div", {
25
+ className: "flex flex-col gap-4",
26
+ "aria-busy": "true",
27
+ children: [/* @__PURE__ */ s(l, {
28
+ variant: "compact",
29
+ title: r("notifications.v3.template.loading", "Template"),
30
+ back: _
31
+ }), /* @__PURE__ */ s(p, { className: "h-64 w-full rounded-lg" })]
32
+ }) : g.error && !g.template ? /* @__PURE__ */ c("div", {
33
+ className: "flex flex-col gap-4",
34
+ children: [/* @__PURE__ */ s(l, {
35
+ variant: "compact",
36
+ title: r("notifications.v3.template.loading", "Template"),
37
+ back: _
38
+ }), /* @__PURE__ */ s(f, {
39
+ what: r("notifications.v3.template.what", "This template"),
40
+ error: g.error,
41
+ onRetry: () => void g.refetch()
42
+ })]
43
+ }) : g.template ? /* @__PURE__ */ s(i, {
44
+ template: g.template,
45
+ onChanged: () => void g.refetch()
46
+ }, g.template.id) : /* @__PURE__ */ c("div", {
47
+ className: "flex flex-col gap-4",
48
+ children: [/* @__PURE__ */ s(l, {
49
+ variant: "compact",
50
+ title: r("notifications.v3.template.loading", "Template"),
51
+ back: _
52
+ }), /* @__PURE__ */ s(u, {
53
+ kind: "not-found",
54
+ icon: /* @__PURE__ */ s(d, { children: /* @__PURE__ */ s(a, { "aria-hidden": "true" }) }),
55
+ title: r("notifications.v3.template.missingTitle", "This template isn’t here"),
56
+ description: r("notifications.v3.template.missingBody", "It may have been deleted.")
57
+ })]
58
+ }) : /* @__PURE__ */ s(i, { template: null });
59
+ }
60
+ export { m as TemplatePage };
61
+
62
+ //# sourceMappingURL=TemplatePage.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TemplatePage.js","names":["TemplatePage","AdminPageV2","TemplateLoader","tr","useTr","paths","useNotificationPaths","useParams","existing","useNotificationTemplate","templateId","back","PageHeader","Skeleton","LoadError","TemplateEditor","EmptyState","IconTile","Mail"],"sources":["../../../src/v2/admin/TemplatePage.tsx"],"sourcesContent":["/**\n * A template (BOFF-16785, C2; the mockup's `ntemplate`), under fe-libs' `accountPagesV2`: what it's\n * about, how it's sent, its title and message on the left, a live preview with sample details on the\n * right (In app · Email · Push). Insert adds a detail (a name, the workflow, a link), shown as\n * `[First name]` and saved as today's `{{firstName}}`. Admins only (`AdminPageV2`). Today's hooks\n * and storage: a template's channel is set once, when it's made.\n */\nimport { useParams } from 'react-router';\nimport { Mail } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { EmptyState, IconTile, LoadError, Skeleton } from '@burdenoff/fe-libs/ui';\nimport { useNotificationTemplate } from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { TemplateEditor } from './TemplateEditor';\n\nexport function TemplatePage() {\n return (\n <AdminPageV2 tool=\"templates\" back={false}>\n <TemplateLoader />\n </AdminPageV2>\n );\n}\n\nfunction TemplateLoader() {\n const tr = useTr();\n const paths = useNotificationPaths();\n const { templateId } = useParams<{ templateId?: string }>();\n const existing = useNotificationTemplate(templateId);\n const back = { label: tr('notifications.v3.templates.title', 'Templates'), to: paths.templates };\n\n if (!templateId) return <TemplateEditor template={null} />;\n if (existing.isLoading && !existing.template) {\n return (\n <div className=\"flex flex-col gap-4\" aria-busy=\"true\">\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.template.loading', 'Template')}\n back={back}\n />\n <Skeleton className=\"h-64 w-full rounded-lg\" />\n </div>\n );\n }\n if (existing.error && !existing.template) {\n return (\n <div className=\"flex flex-col gap-4\">\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.template.loading', 'Template')}\n back={back}\n />\n <LoadError\n what={tr('notifications.v3.template.what', 'This template')}\n error={existing.error}\n onRetry={() => void existing.refetch()}\n />\n </div>\n );\n }\n if (!existing.template) {\n return (\n <div className=\"flex flex-col gap-4\">\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.template.loading', 'Template')}\n back={back}\n />\n <EmptyState\n kind=\"not-found\"\n icon={\n <IconTile>\n <Mail aria-hidden=\"true\" />\n </IconTile>\n }\n title={tr('notifications.v3.template.missingTitle', 'This template isn’t here')}\n description={tr('notifications.v3.template.missingBody', 'It may have been deleted.')}\n />\n </div>\n );\n }\n return (\n <TemplateEditor\n key={existing.template.id}\n template={existing.template}\n onChanged={() => void existing.refetch()}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;AAiBA,SAAgBA,IAAe;CAC7B,OACE,kBAACC,GAAD;EAAa,MAAK;EAAY,MAAM;EAClC,UAAA,kBAACC,GAAD,CAAiB,CAAA;CACN,CAAA;AAEjB;AAEA,SAASA,IAAiB;CACxB,IAAMC,IAAKC,EAAM,GACXC,IAAQC,EAAqB,GAC7B,EAAE,kBAAeC,EAAmC,GACpDC,IAAWC,EAAwBC,CAAU,GAC7CC,IAAO;EAAE,OAAOR,EAAG,oCAAoC,WAAW;EAAG,IAAIE,EAAM;CAAU;CAoD/F,OAlDKK,IACDF,EAAS,aAAa,CAACA,EAAS,WAEhC,kBAAC,OAAD;EAAK,WAAU;EAAsB,aAAU;EAA/C,UAAA,CACE,kBAACI,GAAD;GACE,SAAQ;GACR,OAAOT,EAAG,qCAAqC,UAAU;GACnD;EACP,CAAA,GACD,kBAACU,GAAD,EAAU,WAAU,yBAA0B,CAAA,CAC3C;C,KAGLL,EAAS,SAAS,CAACA,EAAS,WAE5B,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACI,GAAD;GACE,SAAQ;GACR,OAAOT,EAAG,qCAAqC,UAAU;GACnD;EACP,CAAA,GACD,kBAACW,GAAD;GACE,MAAMX,EAAG,kCAAkC,eAAe;GAC1D,OAAOK,EAAS;GAChB,eAAe,KAAKA,EAAS,QAAQ;EACtC,CAAA,CACE;C,KAGJA,EAAS,WAsBZ,kBAACO,GAAD;EAEE,UAAUP,EAAS;EACnB,iBAAiB,KAAKA,EAAS,QAAQ;CACxC,GAHMA,EAAS,SAAS,EAGxB,IAxBC,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACI,GAAD;GACE,SAAQ;GACR,OAAOT,EAAG,qCAAqC,UAAU;GACnD;EACP,CAAA,GACD,kBAACa,GAAD;GACE,MAAK;GACL,MACE,kBAACC,GAAD,EAAA,UACE,kBAACC,GAAD,EAAM,eAAY,OAAQ,CAAA,EAClB,CAAA;GAEZ,OAAOf,EAAG,0CAA0C,0BAA0B;GAC9E,aAAaA,EAAG,yCAAyC,2BAA2B;EACrF,CAAA,CACE;C,KA/Ce,kBAACY,GAAD,EAAgB,UAAU,KAAO,CAAA;AAyD3D"}
@@ -0,0 +1,8 @@
1
+ import { TemplateDetail } from './templateText';
2
+ export declare function TemplatePreview({ productName, title, message, details, }: {
3
+ productName: string;
4
+ /** Stored text (`{{name}}`). */
5
+ title: string;
6
+ message: string;
7
+ details: readonly TemplateDetail[];
8
+ }): import('react').JSX.Element;
@@ -0,0 +1,112 @@
1
+ import { useTr as e } from "../../shared/hooks/useTr.js";
2
+ import { fillSamples as t } from "./templateText.js";
3
+ import { useState as n } from "react";
4
+ import { Bell as r, Eye as i } from "lucide-react";
5
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
6
+ import { IconTile as s, Segmented as c } from "@burdenoff/fe-libs/ui";
7
+ // src/v2/admin/TemplatePreview.tsx
8
+ function l({ productName: l, title: u, message: d, details: f }) {
9
+ let p = e(), [m, h] = n("inApp"), g = t(u, f) || p("notifications.v3.template.previewTitle", "Your title"), _ = t(d, f) || p("notifications.v3.template.previewMessage", "Your message shows here.");
10
+ return /* @__PURE__ */ o("section", {
11
+ className: "flex flex-col gap-3 self-start rounded-lg border border-border-subtle bg-bg-sunken p-4",
12
+ "aria-label": p("notifications.v3.template.preview", "Preview"),
13
+ "data-testid": "template-preview",
14
+ children: [/* @__PURE__ */ o("div", {
15
+ className: "flex flex-wrap items-center justify-between gap-2",
16
+ children: [/* @__PURE__ */ o("span", {
17
+ className: "inline-flex items-center gap-1.5 text-xs font-medium text-text-secondary",
18
+ children: [/* @__PURE__ */ a(i, {
19
+ className: "size-3.5",
20
+ "aria-hidden": "true"
21
+ }), p("notifications.v3.template.previewWith", "Preview, with sample details")]
22
+ }), /* @__PURE__ */ a(c, {
23
+ "aria-label": p("notifications.v3.template.preview", "Preview"),
24
+ value: m,
25
+ onValueChange: h,
26
+ options: [
27
+ {
28
+ value: "inApp",
29
+ label: p("notifications.v3.channel.inApp", "In app")
30
+ },
31
+ {
32
+ value: "email",
33
+ label: p("notifications.v3.channel.email", "Email")
34
+ },
35
+ {
36
+ value: "push",
37
+ label: p("notifications.v3.channel.push", "Push")
38
+ }
39
+ ]
40
+ })]
41
+ }), m === "email" ? /* @__PURE__ */ o("div", {
42
+ className: "flex flex-col gap-2 rounded-md border border-border-subtle bg-bg-surface p-4",
43
+ children: [
44
+ /* @__PURE__ */ a("span", {
45
+ className: "text-xs text-text-muted",
46
+ children: p("notifications.v3.template.previewFrom", "From {{product}} · to maya@northwind.example", { product: l })
47
+ }),
48
+ /* @__PURE__ */ a("b", {
49
+ className: "text-sm text-text-primary",
50
+ children: g
51
+ }),
52
+ /* @__PURE__ */ a("p", {
53
+ className: "m-0 text-sm whitespace-pre-wrap text-text-primary",
54
+ children: _
55
+ })
56
+ ]
57
+ }) : m === "push" ? /* @__PURE__ */ o("div", {
58
+ className: "flex items-start gap-3 rounded-xl border border-border-subtle bg-bg-surface p-3",
59
+ children: [/* @__PURE__ */ a(s, {
60
+ size: "sm",
61
+ children: /* @__PURE__ */ a(r, { "aria-hidden": "true" })
62
+ }), /* @__PURE__ */ o("div", {
63
+ className: "min-w-0 flex-1",
64
+ children: [
65
+ /* @__PURE__ */ o("div", {
66
+ className: "flex items-center justify-between gap-2",
67
+ children: [/* @__PURE__ */ a("b", {
68
+ className: "truncate text-sm text-text-primary",
69
+ children: l
70
+ }), /* @__PURE__ */ a("span", {
71
+ className: "text-xs text-text-muted",
72
+ children: p("notifications.v3.template.now", "now")
73
+ })]
74
+ }),
75
+ /* @__PURE__ */ a("p", {
76
+ className: "m-0 truncate text-sm text-text-primary",
77
+ children: g
78
+ }),
79
+ /* @__PURE__ */ a("p", {
80
+ className: "m-0 line-clamp-2 text-xs text-text-secondary",
81
+ children: _
82
+ })
83
+ ]
84
+ })]
85
+ }) : /* @__PURE__ */ o("div", {
86
+ className: "flex items-start gap-3 rounded-lg border border-border-subtle bg-bg-surface p-3",
87
+ children: [
88
+ /* @__PURE__ */ a(s, {
89
+ size: "sm",
90
+ children: /* @__PURE__ */ a(r, { "aria-hidden": "true" })
91
+ }),
92
+ /* @__PURE__ */ o("div", {
93
+ className: "min-w-0 flex-1",
94
+ children: [/* @__PURE__ */ a("b", {
95
+ className: "block text-sm text-text-primary",
96
+ children: g
97
+ }), /* @__PURE__ */ a("p", {
98
+ className: "m-0 text-xs whitespace-pre-wrap text-text-secondary",
99
+ children: _
100
+ })]
101
+ }),
102
+ /* @__PURE__ */ a("span", {
103
+ className: "text-xs text-text-muted",
104
+ children: p("notifications.v3.template.now", "now")
105
+ })
106
+ ]
107
+ })]
108
+ });
109
+ }
110
+ export { l as TemplatePreview };
111
+
112
+ //# sourceMappingURL=TemplatePreview.js.map