@burdenoff/microfe-notification 2026.1129.2 → 2026.1130.1
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.
- package/dist/NotificationRoutes.js +73 -72
- package/dist/NotificationRoutes.js.map +1 -1
- package/dist/hooks/useSendNotification.d.ts +1 -1
- package/dist/hooks/useSendNotification.js.map +1 -1
- package/dist/translations/en.d.ts +55 -0
- package/dist/v2/InboxPage.js +150 -138
- package/dist/v2/InboxPage.js.map +1 -1
- package/dist/v2/NotificationDetailPanel.d.ts +9 -5
- package/dist/v2/NotificationDetailPanel.js +66 -51
- package/dist/v2/NotificationDetailPanel.js.map +1 -1
- package/dist/v2/PreferencesPage.js +80 -84
- package/dist/v2/PreferencesPage.js.map +1 -1
- package/dist/v2/admin/DeliveryLogPage.js +44 -48
- package/dist/v2/admin/DeliveryLogPage.js.map +1 -1
- package/dist/v2/admin/TemplateEditor.js +28 -33
- package/dist/v2/admin/TemplateEditor.js.map +1 -1
- package/dist/v2/admin/TemplateFields.js +1 -1
- package/dist/v2/admin/TemplateFields.js.map +1 -1
- package/dist/v2/admin/TemplatePage.js +19 -19
- package/dist/v2/admin/TemplatePage.js.map +1 -1
- package/dist/v2/admin/TemplatesPage.js +123 -127
- package/dist/v2/admin/TemplatesPage.js.map +1 -1
- package/dist/v2/admin/TopicsPage.js +101 -105
- package/dist/v2/admin/TopicsPage.js.map +1 -1
- package/dist/v2/admin/templateText.js +22 -17
- package/dist/v2/admin/templateText.js.map +1 -1
- package/dist/v2/send/MessageTab.d.ts +4 -0
- package/dist/v2/send/MessageTab.js +152 -0
- package/dist/v2/send/MessageTab.js.map +1 -0
- package/dist/v2/send/PeopleTab.d.ts +4 -0
- package/dist/v2/send/PeopleTab.js +156 -0
- package/dist/v2/send/PeopleTab.js.map +1 -0
- package/dist/v2/send/SendNotificationDialog.d.ts +4 -0
- package/dist/v2/send/SendNotificationDialog.js +98 -0
- package/dist/v2/send/SendNotificationDialog.js.map +1 -0
- package/dist/v2/send/SendRedirect.d.ts +1 -0
- package/dist/v2/send/SendRedirect.js +20 -0
- package/dist/v2/send/SendRedirect.js.map +1 -0
- package/dist/v2/send/WhenTab.d.ts +4 -0
- package/dist/v2/send/WhenTab.js +64 -0
- package/dist/v2/send/WhenTab.js.map +1 -0
- package/dist/v2/send/sendModel.d.ts +47 -0
- package/dist/v2/send/sendModel.js +90 -0
- package/dist/v2/send/sendModel.js.map +1 -0
- package/dist/v2/send/useSendDraft.d.ts +24 -0
- package/dist/v2/send/useSendDraft.js +120 -0
- package/dist/v2/send/useSendDraft.js.map +1 -0
- package/package.json +1 -1
|
@@ -9,9 +9,9 @@ import { useAppShell as c } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
|
9
9
|
import { Mail as l } from "lucide-react";
|
|
10
10
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
11
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";
|
|
12
|
+
import { Button as p, IconTile as m, Notice as h, StatusChip as g, WorkspacePage as _ } from "@burdenoff/fe-libs/ui";
|
|
13
13
|
// src/v2/admin/TemplateEditor.tsx
|
|
14
|
-
function
|
|
14
|
+
function v({ template: n, draft: r }) {
|
|
15
15
|
let i = e(), s = t(), c = n?.enabled ? /* @__PURE__ */ u(g, {
|
|
16
16
|
status: "ok",
|
|
17
17
|
children: i("notifications.v3.on", "On")
|
|
@@ -54,39 +54,34 @@ function _({ template: n, draft: r }) {
|
|
|
54
54
|
}] : void 0
|
|
55
55
|
});
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function y({ template: t, onChanged: a }) {
|
|
58
58
|
let o = e(), { productName: l } = c(), f = s(null), p = s(null), m = i(t, f, p, a);
|
|
59
|
-
return /* @__PURE__ */ d(
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
59
|
+
return /* @__PURE__ */ d(_, { children: [
|
|
60
|
+
/* @__PURE__ */ u(v, {
|
|
61
|
+
template: t,
|
|
62
|
+
draft: m
|
|
63
|
+
}),
|
|
64
|
+
m.problem ? /* @__PURE__ */ u(h, {
|
|
65
|
+
tone: "bad",
|
|
66
|
+
role: "alert",
|
|
67
|
+
children: m.problem
|
|
68
|
+
}) : null,
|
|
69
|
+
/* @__PURE__ */ d("div", {
|
|
70
|
+
className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-6 max-lg:grid-cols-1",
|
|
71
|
+
children: [/* @__PURE__ */ u(n, {
|
|
64
72
|
template: t,
|
|
65
|
-
draft: m
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
-
});
|
|
73
|
+
draft: m,
|
|
74
|
+
titleRef: f,
|
|
75
|
+
messageRef: p
|
|
76
|
+
}), /* @__PURE__ */ u(r, {
|
|
77
|
+
productName: l || o("notifications.v3.template.productFallback", "Your product"),
|
|
78
|
+
title: m.stored.title,
|
|
79
|
+
message: m.stored.message,
|
|
80
|
+
details: m.details
|
|
81
|
+
})]
|
|
82
|
+
})
|
|
83
|
+
] });
|
|
89
84
|
}
|
|
90
|
-
export {
|
|
85
|
+
export { y as TemplateEditor };
|
|
91
86
|
|
|
92
87
|
//# sourceMappingURL=TemplateEditor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemplateEditor.js","names":["TemplateHeader","tr","useTr","paths","useNotificationPaths","onOff","template","StatusChip","PageHeader","draft","kindWord","channelWord","IconTile","Mail","Button","TemplateEditor","useAppShell","titleRef","useRef","messageRef","useTemplateDraft","onChanged","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 <
|
|
1
|
+
{"version":3,"file":"TemplateEditor.js","names":["TemplateHeader","tr","useTr","paths","useNotificationPaths","onOff","template","StatusChip","PageHeader","draft","kindWord","channelWord","IconTile","Mail","Button","TemplateEditor","useAppShell","titleRef","useRef","messageRef","useTemplateDraft","onChanged","WorkspacePage","Notice","TemplateFields","TemplatePreview","productName"],"sources":["../../../src/v2/admin/TemplateEditor.tsx"],"sourcesContent":["/**\n * The template editor (BOFF-16785, C2): the header, the form and the live preview. Title and\n * message are edited as people read them (`[First name]`); saving stores today's text\n * (`{{firstName}}`) and the details as today's `variables`.\n */\nimport { useRef } from 'react';\nimport { Mail } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { Button, IconTile, Notice, StatusChip, WorkspacePage } from '@burdenoff/fe-libs/ui';\nimport { useAppShell } from '@burdenoff/fe-libs/shared/providers/shell';\nimport type { BackendNotificationTemplate } from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { TemplateFields } from './TemplateFields';\nimport { TemplatePreview } from './TemplatePreview';\nimport { useTemplateDraft, type TemplateDraft } from './useTemplateDraft';\nimport { channelWord, kindWord } from './words';\n\nfunction TemplateHeader({\n template,\n draft,\n}: {\n template: BackendNotificationTemplate | null;\n draft: TemplateDraft;\n}) {\n const tr = useTr();\n const paths = useNotificationPaths();\n const onOff = template?.enabled ? (\n <StatusChip status=\"ok\">{tr('notifications.v3.on', 'On')}</StatusChip>\n ) : (\n <StatusChip status=\"paused\">{tr('notifications.v3.off', 'Off')}</StatusChip>\n );\n return (\n <PageHeader\n variant=\"compact\"\n title={\n template?.name || draft.name.trim() || tr('notifications.v3.template.new', 'New template')\n }\n description={\n template\n ? tr('notifications.v3.template.purpose', '{{kind}} · sent by {{channel}}', {\n kind: kindWord(template.type, tr),\n channel: channelWord(template.channel, tr).toLowerCase(),\n })\n : tr(\n 'notifications.v3.template.newPurpose',\n 'Write it once; it’s filled in for each person when it’s sent.'\n )\n }\n icon={\n <IconTile size=\"md\">\n <Mail aria-hidden=\"true\" />\n </IconTile>\n }\n back={{ label: tr('notifications.v3.templates.title', 'Templates'), to: paths.templates }}\n badge={template ? onOff : undefined}\n primary={\n <Button\n busy={draft.saving}\n disabled={!draft.ready}\n onClick={() => void draft.save()}\n data-testid=\"template-save\"\n >\n {template\n ? tr('notifications.v3.template.save', 'Save')\n : tr('notifications.v3.template.create', 'Create template')}\n </Button>\n }\n more={\n template\n ? [\n {\n id: 'toggle',\n label: template.enabled\n ? tr('notifications.v3.templates.turnOff', 'Turn off')\n : tr('notifications.v3.templates.turnOn', 'Turn on'),\n onSelect: () => void draft.toggle(),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n onSelect: () => void draft.remove(),\n },\n ]\n : undefined\n }\n />\n );\n}\n\nexport function TemplateEditor({\n template,\n onChanged,\n}: {\n template: BackendNotificationTemplate | null;\n /** Read the template again after turning it on or off. */\n onChanged?: () => void;\n}) {\n const tr = useTr();\n const { productName } = useAppShell();\n const titleRef = useRef<HTMLInputElement>(null);\n const messageRef = useRef<HTMLTextAreaElement>(null);\n const draft = useTemplateDraft(template, titleRef, messageRef, onChanged);\n return (\n <WorkspacePage>\n <TemplateHeader template={template} draft={draft} />\n {draft.problem ? (\n <Notice tone=\"bad\" role=\"alert\">\n {draft.problem}\n </Notice>\n ) : null}\n <div className=\"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-6 max-lg:grid-cols-1\">\n <TemplateFields\n template={template}\n draft={draft}\n titleRef={titleRef}\n messageRef={messageRef}\n />\n <TemplatePreview\n productName={\n productName || tr('notifications.v3.template.productFallback', 'Your product')\n }\n title={draft.stored.title}\n message={draft.stored.message}\n details={draft.details}\n />\n </div>\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAASA,EAAe,EACtB,aACA,YAIC;CACD,IAAMC,IAAKC,EAAM,GACXC,IAAQC,EAAqB,GAC7BC,IAAQC,GAAU,UACtB,kBAACC,GAAD;EAAY,QAAO;EAAM,UAAAN,EAAG,uBAAuB,IAAI;CAAc,CAAA,IAErE,kBAACM,GAAD;EAAY,QAAO;EAAU,UAAAN,EAAG,wBAAwB,KAAK;CAAc,CAAA;CAE7E,OACE,kBAACO,GAAD;EACE,SAAQ;EACR,OACEF,GAAU,QAAQG,EAAM,KAAK,KAAK,KAAKR,EAAG,iCAAiC,cAAc;EAE3F,aACEK,IACIL,EAAG,qCAAqC,kCAAkC;GACxE,MAAMS,EAASJ,EAAS,MAAML,CAAE;GAChC,SAASU,EAAYL,EAAS,SAASL,CAAE,CAAC,CAAC,YAAY;EACzD,CAAC,IACDA,EACE,wCACA,+DACF;EAEN,MACE,kBAACW,GAAD;GAAU,MAAK;GACb,UAAA,kBAACC,GAAD,EAAM,eAAY,OAAQ,CAAA;EAClB,CAAA;EAEZ,MAAM;GAAE,OAAOZ,EAAG,oCAAoC,WAAW;GAAG,IAAIE,EAAM;EAAU;EACxF,OAAOG,IAAWD,IAAQ,KAAA;EAC1B,SACE,kBAACS,GAAD;GACE,MAAML,EAAM;GACZ,UAAU,CAACA,EAAM;GACjB,eAAe,KAAKA,EAAM,KAAK;GAC/B,eAAY;GAEX,UAAAH,IACGL,EAAG,kCAAkC,MAAM,IAC3CA,EAAG,oCAAoC,iBAAiB;EACtD,CAAA;EAEV,MACEK,IACI,CACE;GACE,IAAI;GACJ,OAAOA,EAAS,UACZL,EAAG,sCAAsC,UAAU,IACnDA,EAAG,qCAAqC,SAAS;GACrD,gBAAgB,KAAKQ,EAAM,OAAO;EACpC,GACA;GACE,IAAI;GACJ,OAAOR,EAAG,qCAAqC,QAAQ;GACvD,QAAQ;GACR,gBAAgB,KAAKQ,EAAM,OAAO;EACpC,CACF,IACA,KAAA;CAEP,CAAA;AAEL;AAEA,SAAgBM,EAAe,EAC7B,aACA,gBAKC;CACD,IAAMd,IAAKC,EAAM,GACX,EAAE,mBAAgBc,EAAY,GAC9BC,IAAWC,EAAyB,IAAI,GACxCC,IAAaD,EAA4B,IAAI,GAC7CT,IAAQW,EAAiBd,GAAUW,GAAUE,GAAYE,CAAS;CACxE,OACE,kBAACC,GAAD,EAAA,UAAA;EACE,kBAACtB,GAAD;GAA0B;GAAiB;EAAQ,CAAA;EAClDS,EAAM,UACL,kBAACc,GAAD;GAAQ,MAAK;GAAM,MAAK;GACrB,UAAAd,EAAM;EACD,CAAA,IACN;EACJ,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACe,GAAD;IACY;IACH;IACG;IACE;GACb,CAAA,GACD,kBAACC,GAAD;IACE,aACEC,KAAezB,EAAG,6CAA6C,cAAc;IAE/E,OAAOQ,EAAM,OAAO;IACpB,SAASA,EAAM,OAAO;IACtB,SAASA,EAAM;GAChB,CAAA,CACE;;CACQ,EAAA,CAAA;AAEnB"}
|
|
@@ -115,7 +115,7 @@ function g({ template: n, draft: r, titleRef: a, messageRef: g }) {
|
|
|
115
115
|
"data-testid": "template-message"
|
|
116
116
|
}), /* @__PURE__ */ c("p", {
|
|
117
117
|
className: "m-0 text-xs text-text-muted",
|
|
118
|
-
children: _("notifications.v3.template.detailsHelp", "Details in brackets, like [First name], are filled in
|
|
118
|
+
children: _("notifications.v3.template.detailsHelp", "Details in brackets, like [First name], are filled in when it’s sent.")
|
|
119
119
|
})]
|
|
120
120
|
}),
|
|
121
121
|
n?.htmlTemplate ? /* @__PURE__ */ c(f, {
|
|
@@ -1 +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
|
|
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":"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"}
|
|
@@ -7,56 +7,56 @@ import { Mail as a } from "lucide-react";
|
|
|
7
7
|
import { useParams as o } from "react-router";
|
|
8
8
|
import { jsx as s, jsxs as c } from "react/jsx-runtime";
|
|
9
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";
|
|
10
|
+
import { EmptyState as u, IconTile as d, LoadError as f, Skeleton as p, WorkspacePage as m } from "@burdenoff/fe-libs/ui";
|
|
11
11
|
// src/v2/admin/TemplatePage.tsx
|
|
12
|
-
function
|
|
12
|
+
function h() {
|
|
13
13
|
return /* @__PURE__ */ s(r, {
|
|
14
14
|
tool: "templates",
|
|
15
15
|
back: !1,
|
|
16
|
-
children: /* @__PURE__ */ s(
|
|
16
|
+
children: /* @__PURE__ */ s(g, {})
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
|
-
function
|
|
20
|
-
let r = t(),
|
|
19
|
+
function g() {
|
|
20
|
+
let r = t(), h = n(), { templateId: g } = o(), _ = e(g), v = {
|
|
21
21
|
label: r("notifications.v3.templates.title", "Templates"),
|
|
22
|
-
to:
|
|
22
|
+
to: h.templates
|
|
23
23
|
};
|
|
24
|
-
return
|
|
24
|
+
return g ? _.isLoading && !_.template ? /* @__PURE__ */ s(m, { children: /* @__PURE__ */ c("div", {
|
|
25
25
|
className: "flex flex-col gap-4",
|
|
26
26
|
"aria-busy": "true",
|
|
27
27
|
children: [/* @__PURE__ */ s(l, {
|
|
28
28
|
variant: "compact",
|
|
29
29
|
title: r("notifications.v3.template.loading", "Template"),
|
|
30
|
-
back:
|
|
30
|
+
back: v
|
|
31
31
|
}), /* @__PURE__ */ s(p, { className: "h-64 w-full rounded-lg" })]
|
|
32
|
-
}) :
|
|
32
|
+
}) }) : _.error && !_.template ? /* @__PURE__ */ s(m, { children: /* @__PURE__ */ c("div", {
|
|
33
33
|
className: "flex flex-col gap-4",
|
|
34
34
|
children: [/* @__PURE__ */ s(l, {
|
|
35
35
|
variant: "compact",
|
|
36
36
|
title: r("notifications.v3.template.loading", "Template"),
|
|
37
|
-
back:
|
|
37
|
+
back: v
|
|
38
38
|
}), /* @__PURE__ */ s(f, {
|
|
39
39
|
what: r("notifications.v3.template.what", "This template"),
|
|
40
|
-
error:
|
|
41
|
-
onRetry: () => void
|
|
40
|
+
error: _.error,
|
|
41
|
+
onRetry: () => void _.refetch()
|
|
42
42
|
})]
|
|
43
|
-
}) :
|
|
44
|
-
template:
|
|
45
|
-
onChanged: () => void
|
|
46
|
-
},
|
|
43
|
+
}) }) : _.template ? /* @__PURE__ */ s(i, {
|
|
44
|
+
template: _.template,
|
|
45
|
+
onChanged: () => void _.refetch()
|
|
46
|
+
}, _.template.id) : /* @__PURE__ */ s(m, { children: /* @__PURE__ */ c("div", {
|
|
47
47
|
className: "flex flex-col gap-4",
|
|
48
48
|
children: [/* @__PURE__ */ s(l, {
|
|
49
49
|
variant: "compact",
|
|
50
50
|
title: r("notifications.v3.template.loading", "Template"),
|
|
51
|
-
back:
|
|
51
|
+
back: v
|
|
52
52
|
}), /* @__PURE__ */ s(u, {
|
|
53
53
|
kind: "not-found",
|
|
54
54
|
icon: /* @__PURE__ */ s(d, { children: /* @__PURE__ */ s(a, { "aria-hidden": "true" }) }),
|
|
55
55
|
title: r("notifications.v3.template.missingTitle", "This template isn’t here"),
|
|
56
56
|
description: r("notifications.v3.template.missingBody", "It may have been deleted.")
|
|
57
57
|
})]
|
|
58
|
-
}) : /* @__PURE__ */ s(i, { template: null });
|
|
58
|
+
}) }) : /* @__PURE__ */ s(i, { template: null });
|
|
59
59
|
}
|
|
60
|
-
export {
|
|
60
|
+
export { h as TemplatePage };
|
|
61
61
|
|
|
62
62
|
//# sourceMappingURL=TemplatePage.js.map
|
|
@@ -1 +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
|
|
1
|
+
{"version":3,"file":"TemplatePage.js","names":["TemplatePage","AdminPageV2","TemplateLoader","tr","useTr","paths","useNotificationPaths","useParams","existing","useNotificationTemplate","templateId","back","WorkspacePage","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, WorkspacePage } 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 <WorkspacePage>\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 </WorkspacePage>\n );\n }\n if (existing.error && !existing.template) {\n return (\n <WorkspacePage>\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 </WorkspacePage>\n );\n }\n if (!existing.template) {\n return (\n <WorkspacePage>\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 </WorkspacePage>\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;CA0D/F,OAxDKK,IACDF,EAAS,aAAa,CAACA,EAAS,WAEhC,kBAACI,GAAD,EAAA,UACE,kBAAC,OAAD;EAAK,WAAU;EAAsB,aAAU;EAA/C,UAAA,CACE,kBAACC,GAAD;GACE,SAAQ;GACR,OAAOV,EAAG,qCAAqC,UAAU;GACnD;EACP,CAAA,GACD,kBAACW,GAAD,EAAU,WAAU,yBAA0B,CAAA,CAC3C;CACQ,CAAA,EAAA,CAAA,IAGfN,EAAS,SAAS,CAACA,EAAS,WAE5B,kBAACI,GAAD,EAAA,UACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACC,GAAD;GACE,SAAQ;GACR,OAAOV,EAAG,qCAAqC,UAAU;GACnD;EACP,CAAA,GACD,kBAACY,GAAD;GACE,MAAMZ,EAAG,kCAAkC,eAAe;GAC1D,OAAOK,EAAS;GAChB,eAAe,KAAKA,EAAS,QAAQ;EACtC,CAAA,CACE;CACQ,CAAA,EAAA,CAAA,IAGdA,EAAS,WAwBZ,kBAACQ,GAAD;EAEE,UAAUR,EAAS;EACnB,iBAAiB,KAAKA,EAAS,QAAQ;CACxC,GAHMA,EAAS,SAAS,EAGxB,IA1BC,kBAACI,GAAD,EAAA,UACE,kBAAC,OAAD;EAAK,WAAU;EAAf,UAAA,CACE,kBAACC,GAAD;GACE,SAAQ;GACR,OAAOV,EAAG,qCAAqC,UAAU;GACnD;EACP,CAAA,GACD,kBAACc,GAAD;GACE,MAAK;GACL,MACE,kBAACC,GAAD,EAAA,UACE,kBAACC,GAAD,EAAM,eAAY,OAAQ,CAAA,EAClB,CAAA;GAEZ,OAAOhB,EAAG,0CAA0C,0BAA0B;GAC9E,aAAaA,EAAG,yCAAyC,2BAA2B;EACrF,CAAA,CACE;CACQ,CAAA,EAAA,CAAA,IArDK,kBAACa,GAAD,EAAgB,UAAU,KAAO,CAAA;AA+D3D"}
|
|
@@ -9,165 +9,161 @@ import { Mail as u, Plus as d, Search as f } from "lucide-react";
|
|
|
9
9
|
import { useNavigate as p } from "react-router";
|
|
10
10
|
import { jsx as m, jsxs as h } from "react/jsx-runtime";
|
|
11
11
|
import { PageHeader as g } from "@burdenoff/fe-libs/chrome";
|
|
12
|
-
import { ActionMenu as _, Button as v, DataRows as y, EmptyState as b, IconTile as x, Input as S, LoadError as C, StatusChip as w,
|
|
12
|
+
import { ActionMenu as _, Button as v, DataRows as y, EmptyState as b, IconTile as x, Input as S, LoadError as C, StatusChip as w, WorkspacePage as T, useConfirm as E, useNotify as D, useWhenLabels as O } from "@burdenoff/fe-libs/ui";
|
|
13
13
|
// src/v2/admin/TemplatesPage.tsx
|
|
14
|
-
function
|
|
14
|
+
function k() {
|
|
15
15
|
return /* @__PURE__ */ m(r, {
|
|
16
16
|
tool: "templates",
|
|
17
17
|
back: !1,
|
|
18
|
-
children: /* @__PURE__ */ m(
|
|
18
|
+
children: /* @__PURE__ */ m(A, {})
|
|
19
19
|
});
|
|
20
20
|
}
|
|
21
|
-
function
|
|
22
|
-
let r = t(),
|
|
23
|
-
let e =
|
|
21
|
+
function A() {
|
|
22
|
+
let r = t(), k = p(), A = n(), j = E(), M = D(), N = O(), P = e(), [F, I] = l(""), L = c(() => {
|
|
23
|
+
let e = F.trim().toLowerCase(), t = P.allTemplates;
|
|
24
24
|
return e ? t.filter((t) => t.name.toLowerCase().includes(e) || (t.subject ?? "").toLowerCase().includes(e)) : t;
|
|
25
|
-
}, [
|
|
25
|
+
}, [F, P.allTemplates]), R = async (e) => {
|
|
26
26
|
try {
|
|
27
|
-
await
|
|
27
|
+
await P.updateTemplate(e.id, { enabled: !e.enabled }), M({
|
|
28
28
|
title: e.enabled ? r("notifications.v3.templates.turnedOff", "{{name}} is off", { name: e.name }) : r("notifications.v3.templates.turnedOn", "{{name}} is on", { name: e.name }),
|
|
29
29
|
tone: "success"
|
|
30
|
-
}), await
|
|
30
|
+
}), await P.refetch();
|
|
31
31
|
} catch {
|
|
32
|
-
|
|
32
|
+
M({
|
|
33
33
|
title: r("notifications.v3.templates.saveFailed", "Couldn’t save. Try again."),
|
|
34
34
|
tone: "error"
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
|
-
},
|
|
38
|
-
if (await
|
|
37
|
+
}, z = async (e) => {
|
|
38
|
+
if (await j({
|
|
39
39
|
title: r("notifications.v3.templates.deleteTitle", "Delete {{name}}?", { name: e.name }),
|
|
40
40
|
description: r("notifications.v3.templates.deleteBody", "Anything that sends this template stops sending it. Messages already sent stay as they are."),
|
|
41
41
|
confirmLabel: r("notifications.v3.templates.delete", "Delete"),
|
|
42
42
|
tone: "danger",
|
|
43
43
|
typeToConfirm: e.name
|
|
44
44
|
})) try {
|
|
45
|
-
await
|
|
45
|
+
await P.deleteTemplate(e.id), M({
|
|
46
46
|
title: r("notifications.v3.templates.deleted", "Deleted {{name}}", { name: e.name }),
|
|
47
47
|
tone: "success"
|
|
48
|
-
}), await
|
|
48
|
+
}), await P.refetch();
|
|
49
49
|
} catch {
|
|
50
|
-
|
|
50
|
+
M({
|
|
51
51
|
title: r("notifications.v3.templates.deleteFailed", "Couldn’t delete it. Try again."),
|
|
52
52
|
tone: "error"
|
|
53
53
|
});
|
|
54
54
|
}
|
|
55
55
|
};
|
|
56
|
-
return /* @__PURE__ */ h(
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
value: P,
|
|
89
|
-
placeholder: r("notifications.v3.templates.search", "Search templates"),
|
|
90
|
-
onChange: (e) => F(e.target.value)
|
|
91
|
-
})
|
|
92
|
-
]
|
|
93
|
-
}), N.error && I.length === 0 ? /* @__PURE__ */ m(C, {
|
|
94
|
-
what: r("notifications.v3.templates.title", "Templates"),
|
|
95
|
-
error: N.error,
|
|
96
|
-
onRetry: () => void N.refetch()
|
|
97
|
-
}) : !N.isLoading && I.length === 0 ? P.trim() ? /* @__PURE__ */ m(b, {
|
|
98
|
-
kind: "no-results",
|
|
99
|
-
title: r("notifications.v3.templates.noMatch", "No templates match"),
|
|
100
|
-
description: r("notifications.v3.empty.searchBody", "Try other words.")
|
|
101
|
-
}) : /* @__PURE__ */ m(b, {
|
|
102
|
-
kind: "first-use",
|
|
103
|
-
title: r("notifications.v3.templates.emptyTitle", "No templates yet"),
|
|
104
|
-
description: r("notifications.v3.templates.emptyBody", "A template is a message you write once, like a welcome email, and send many times."),
|
|
105
|
-
action: /* @__PURE__ */ m(v, {
|
|
106
|
-
onClick: () => O(k.newTemplate),
|
|
107
|
-
children: r("notifications.v3.templates.new", "New template")
|
|
56
|
+
return /* @__PURE__ */ h(T, { children: [/* @__PURE__ */ m(g, {
|
|
57
|
+
variant: "compact",
|
|
58
|
+
title: r("notifications.v3.templates.title", "Templates"),
|
|
59
|
+
description: r("notifications.v3.templates.purpose", "Messages written once and sent many times: what they say, and how they’re sent."),
|
|
60
|
+
back: {
|
|
61
|
+
label: r("notifications.v3.title", "Notifications"),
|
|
62
|
+
to: A.inbox
|
|
63
|
+
},
|
|
64
|
+
primary: /* @__PURE__ */ h(v, {
|
|
65
|
+
onClick: () => k(A.newTemplate),
|
|
66
|
+
"data-testid": "templates-new",
|
|
67
|
+
children: [/* @__PURE__ */ m(d, { "aria-hidden": "true" }), r("notifications.v3.templates.new", "New template")]
|
|
68
|
+
})
|
|
69
|
+
}), /* @__PURE__ */ h("div", {
|
|
70
|
+
className: "flex flex-col gap-3",
|
|
71
|
+
children: [/* @__PURE__ */ h("label", {
|
|
72
|
+
className: "relative block max-w-md",
|
|
73
|
+
children: [
|
|
74
|
+
/* @__PURE__ */ m("span", {
|
|
75
|
+
className: "sr-only",
|
|
76
|
+
children: r("notifications.v3.templates.search", "Search templates")
|
|
77
|
+
}),
|
|
78
|
+
/* @__PURE__ */ m(f, {
|
|
79
|
+
className: "pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted",
|
|
80
|
+
"aria-hidden": "true"
|
|
81
|
+
}),
|
|
82
|
+
/* @__PURE__ */ m(S, {
|
|
83
|
+
type: "search",
|
|
84
|
+
className: "pl-9",
|
|
85
|
+
value: F,
|
|
86
|
+
placeholder: r("notifications.v3.templates.search", "Search templates"),
|
|
87
|
+
onChange: (e) => I(e.target.value)
|
|
108
88
|
})
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
89
|
+
]
|
|
90
|
+
}), P.error && L.length === 0 ? /* @__PURE__ */ m(C, {
|
|
91
|
+
what: r("notifications.v3.templates.title", "Templates"),
|
|
92
|
+
error: P.error,
|
|
93
|
+
onRetry: () => void P.refetch()
|
|
94
|
+
}) : !P.isLoading && L.length === 0 ? F.trim() ? /* @__PURE__ */ m(b, {
|
|
95
|
+
kind: "no-results",
|
|
96
|
+
title: r("notifications.v3.templates.noMatch", "No templates match"),
|
|
97
|
+
description: r("notifications.v3.empty.searchBody", "Try other words.")
|
|
98
|
+
}) : /* @__PURE__ */ m(b, {
|
|
99
|
+
kind: "first-use",
|
|
100
|
+
title: r("notifications.v3.templates.emptyTitle", "No templates yet"),
|
|
101
|
+
description: r("notifications.v3.templates.emptyBody", "A template is a message you write once, like a welcome email, and send many times."),
|
|
102
|
+
action: /* @__PURE__ */ m(v, {
|
|
103
|
+
onClick: () => k(A.newTemplate),
|
|
104
|
+
children: r("notifications.v3.templates.new", "New template")
|
|
105
|
+
})
|
|
106
|
+
}) : /* @__PURE__ */ m(y, {
|
|
107
|
+
items: L,
|
|
108
|
+
loading: P.isLoading && L.length === 0,
|
|
109
|
+
skeletonRows: 5,
|
|
110
|
+
getId: (e) => e.id,
|
|
111
|
+
label: r("notifications.v3.templates.title", "Templates"),
|
|
112
|
+
lead: {
|
|
113
|
+
header: r("notifications.v3.templates.template", "Template"),
|
|
114
|
+
media: () => /* @__PURE__ */ m(x, {
|
|
115
|
+
size: "sm",
|
|
116
|
+
children: /* @__PURE__ */ m(u, { "aria-hidden": "true" })
|
|
117
|
+
}),
|
|
118
|
+
title: (e) => e.name,
|
|
119
|
+
subtitle: (e) => e.subject ? s(e.subject, o(e.variables)) : void 0,
|
|
120
|
+
onOpen: (e) => k(A.template(e.slug))
|
|
121
|
+
},
|
|
122
|
+
columns: [
|
|
123
|
+
{
|
|
124
|
+
id: "kind",
|
|
125
|
+
header: r("notifications.v3.templates.kind", "About"),
|
|
126
|
+
cell: (e) => a(e.type, r)
|
|
124
127
|
},
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
{
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
id: "delete",
|
|
162
|
-
label: r("notifications.v3.templates.delete", "Delete"),
|
|
163
|
-
danger: !0,
|
|
164
|
-
onSelect: () => void R(e)
|
|
165
|
-
}]
|
|
166
|
-
})
|
|
167
|
-
})]
|
|
128
|
+
{
|
|
129
|
+
id: "channel",
|
|
130
|
+
header: r("notifications.v3.templates.channel", "Sent by"),
|
|
131
|
+
cell: (e) => i(e.channel, r)
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: "edited",
|
|
135
|
+
header: r("notifications.v3.templates.edited", "Edited"),
|
|
136
|
+
cell: (e) => N.moment(e.updatedAt)
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: "status",
|
|
140
|
+
header: r("notifications.v3.templates.status", "Status"),
|
|
141
|
+
cell: (e) => e.enabled ? /* @__PURE__ */ m(w, {
|
|
142
|
+
status: "ok",
|
|
143
|
+
children: r("notifications.v3.on", "On")
|
|
144
|
+
}) : /* @__PURE__ */ m(w, {
|
|
145
|
+
status: "paused",
|
|
146
|
+
children: r("notifications.v3.off", "Off")
|
|
147
|
+
})
|
|
148
|
+
}
|
|
149
|
+
],
|
|
150
|
+
actions: (e) => /* @__PURE__ */ m(_, {
|
|
151
|
+
placement: "row",
|
|
152
|
+
label: r("notifications.v3.templates.actionsFor", "Actions for {{name}}", { name: e.name }),
|
|
153
|
+
items: [{
|
|
154
|
+
id: "toggle",
|
|
155
|
+
label: e.enabled ? r("notifications.v3.templates.turnOff", "Turn off") : r("notifications.v3.templates.turnOn", "Turn on"),
|
|
156
|
+
onSelect: () => void R(e)
|
|
157
|
+
}, {
|
|
158
|
+
id: "delete",
|
|
159
|
+
label: r("notifications.v3.templates.delete", "Delete"),
|
|
160
|
+
danger: !0,
|
|
161
|
+
onSelect: () => void z(e)
|
|
162
|
+
}]
|
|
163
|
+
})
|
|
168
164
|
})]
|
|
169
|
-
});
|
|
165
|
+
})] });
|
|
170
166
|
}
|
|
171
|
-
export {
|
|
167
|
+
export { k as TemplatesPage };
|
|
172
168
|
|
|
173
169
|
//# sourceMappingURL=TemplatesPage.js.map
|