@burdenoff/microfe-notification 2026.1129.3 → 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.
@@ -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, useConfirm as T, useNotify as E, useWhenLabels as D } from "@burdenoff/fe-libs/ui";
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 O() {
14
+ function k() {
15
15
  return /* @__PURE__ */ m(r, {
16
16
  tool: "templates",
17
17
  back: !1,
18
- children: /* @__PURE__ */ m(k, {})
18
+ children: /* @__PURE__ */ m(A, {})
19
19
  });
20
20
  }
21
- function k() {
22
- let r = t(), O = p(), k = n(), A = T(), j = E(), M = D(), N = e(), [P, F] = l(""), I = c(() => {
23
- let e = P.trim().toLowerCase(), t = N.allTemplates;
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
- }, [P, N.allTemplates]), L = async (e) => {
25
+ }, [F, P.allTemplates]), R = async (e) => {
26
26
  try {
27
- await N.updateTemplate(e.id, { enabled: !e.enabled }), j({
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 N.refetch();
30
+ }), await P.refetch();
31
31
  } catch {
32
- j({
32
+ M({
33
33
  title: r("notifications.v3.templates.saveFailed", "Couldn’t save. Try again."),
34
34
  tone: "error"
35
35
  });
36
36
  }
37
- }, R = async (e) => {
38
- if (await A({
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 N.deleteTemplate(e.id), j({
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 N.refetch();
48
+ }), await P.refetch();
49
49
  } catch {
50
- j({
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("div", {
57
- "data-account-pages-v2": "notification-templates",
58
- className: "flex w-full min-w-0 flex-col",
59
- children: [/* @__PURE__ */ m(g, {
60
- variant: "compact",
61
- title: r("notifications.v3.templates.title", "Templates"),
62
- description: r("notifications.v3.templates.purpose", "Messages written once and sent many times: what they say, and how they’re sent."),
63
- back: {
64
- label: r("notifications.v3.title", "Notifications"),
65
- to: k.inbox
66
- },
67
- primary: /* @__PURE__ */ h(v, {
68
- onClick: () => O(k.newTemplate),
69
- "data-testid": "templates-new",
70
- children: [/* @__PURE__ */ m(d, { "aria-hidden": "true" }), r("notifications.v3.templates.new", "New template")]
71
- })
72
- }), /* @__PURE__ */ h("div", {
73
- className: "flex flex-col gap-3",
74
- children: [/* @__PURE__ */ h("label", {
75
- className: "relative block max-w-md",
76
- children: [
77
- /* @__PURE__ */ m("span", {
78
- className: "sr-only",
79
- children: r("notifications.v3.templates.search", "Search templates")
80
- }),
81
- /* @__PURE__ */ m(f, {
82
- className: "pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted",
83
- "aria-hidden": "true"
84
- }),
85
- /* @__PURE__ */ m(S, {
86
- type: "search",
87
- className: "pl-9",
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
- }) : /* @__PURE__ */ m(y, {
110
- items: I,
111
- loading: N.isLoading && I.length === 0,
112
- skeletonRows: 5,
113
- getId: (e) => e.id,
114
- label: r("notifications.v3.templates.title", "Templates"),
115
- lead: {
116
- header: r("notifications.v3.templates.template", "Template"),
117
- media: () => /* @__PURE__ */ m(x, {
118
- size: "sm",
119
- children: /* @__PURE__ */ m(u, { "aria-hidden": "true" })
120
- }),
121
- title: (e) => e.name,
122
- subtitle: (e) => e.subject ? s(e.subject, o(e.variables)) : void 0,
123
- onOpen: (e) => O(k.template(e.slug))
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
- columns: [
126
- {
127
- id: "kind",
128
- header: r("notifications.v3.templates.kind", "About"),
129
- cell: (e) => a(e.type, r)
130
- },
131
- {
132
- id: "channel",
133
- header: r("notifications.v3.templates.channel", "Sent by"),
134
- cell: (e) => i(e.channel, r)
135
- },
136
- {
137
- id: "edited",
138
- header: r("notifications.v3.templates.edited", "Edited"),
139
- cell: (e) => M.moment(e.updatedAt)
140
- },
141
- {
142
- id: "status",
143
- header: r("notifications.v3.templates.status", "Status"),
144
- cell: (e) => e.enabled ? /* @__PURE__ */ m(w, {
145
- status: "ok",
146
- children: r("notifications.v3.on", "On")
147
- }) : /* @__PURE__ */ m(w, {
148
- status: "paused",
149
- children: r("notifications.v3.off", "Off")
150
- })
151
- }
152
- ],
153
- actions: (e) => /* @__PURE__ */ m(_, {
154
- placement: "row",
155
- label: r("notifications.v3.templates.actionsFor", "Actions for {{name}}", { name: e.name }),
156
- items: [{
157
- id: "toggle",
158
- label: e.enabled ? r("notifications.v3.templates.turnOff", "Turn off") : r("notifications.v3.templates.turnOn", "Turn on"),
159
- onSelect: () => void L(e)
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 { O as TemplatesPage };
167
+ export { k as TemplatesPage };
172
168
 
173
169
  //# sourceMappingURL=TemplatesPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TemplatesPage.js","names":["TemplatesPage","AdminPageV2","TemplatesList","tr","useTr","navigate","useNavigate","paths","useNotificationPaths","confirm","useConfirm","notify","useNotify","when","useWhenLabels","templates","useNotificationTemplates","search","setSearch","useState","shown","useMemo","query","all","template","toggle","remove","PageHeader","Button","Plus","Search","Input","event","LoadError","EmptyState","DataRows","IconTile","Mail","toReadable","readDetails","kindWord","channelWord","StatusChip","ActionMenu"],"sources":["../../../src/v2/admin/TemplatesPage.tsx"],"sourcesContent":["/**\n * Templates (BOFF-16785, C2; the mockup's `ntemplates`), under fe-libs' `accountPagesV2`: the\n * messages this product sends, at the list width. A row each (what it's about, how it's sent,\n * when it was edited, on or off), search, New template, and ⋯ (turn off or on, delete). Admins\n * only: anyone else sees who to ask (`AdminPageV2`). Today's hook and storage.\n */\nimport { useMemo, useState } from 'react';\nimport { useNavigate } from 'react-router';\nimport { Mail, Plus, Search } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport {\n ActionMenu,\n Button,\n DataRows,\n EmptyState,\n IconTile,\n Input,\n LoadError,\n StatusChip,\n useConfirm,\n useNotify,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport {\n useNotificationTemplates,\n type BackendNotificationTemplate,\n} from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { channelWord, kindWord } from './words';\nimport { readDetails, toReadable } from './templateText';\n\nexport function TemplatesPage() {\n return (\n <AdminPageV2 tool=\"templates\" back={false}>\n <TemplatesList />\n </AdminPageV2>\n );\n}\n\nfunction TemplatesList() {\n const tr = useTr();\n const navigate = useNavigate();\n const paths = useNotificationPaths();\n const confirm = useConfirm();\n const notify = useNotify();\n const when = useWhenLabels();\n const templates = useNotificationTemplates();\n const [search, setSearch] = useState('');\n const shown = useMemo(() => {\n const query = search.trim().toLowerCase();\n const all = templates.allTemplates;\n if (!query) return all;\n return all.filter(\n (template) =>\n template.name.toLowerCase().includes(query) ||\n (template.subject ?? '').toLowerCase().includes(query)\n );\n }, [search, templates.allTemplates]);\n\n const toggle = async (template: BackendNotificationTemplate) => {\n try {\n await templates.updateTemplate(template.id, { enabled: !template.enabled });\n notify({\n title: template.enabled\n ? tr('notifications.v3.templates.turnedOff', '{{name}} is off', { name: template.name })\n : tr('notifications.v3.templates.turnedOn', '{{name}} is on', { name: template.name }),\n tone: 'success',\n });\n await templates.refetch();\n } catch {\n notify({\n title: tr('notifications.v3.templates.saveFailed', 'Couldn’t save. Try again.'),\n tone: 'error',\n });\n }\n };\n\n const remove = async (template: BackendNotificationTemplate) => {\n const yes = await confirm({\n title: tr('notifications.v3.templates.deleteTitle', 'Delete {{name}}?', {\n name: template.name,\n }),\n description: tr(\n 'notifications.v3.templates.deleteBody',\n 'Anything that sends this template stops sending it. Messages already sent stay as they are.'\n ),\n confirmLabel: tr('notifications.v3.templates.delete', 'Delete'),\n tone: 'danger',\n typeToConfirm: template.name,\n });\n if (!yes) return;\n try {\n await templates.deleteTemplate(template.id);\n notify({\n title: tr('notifications.v3.templates.deleted', 'Deleted {{name}}', {\n name: template.name,\n }),\n tone: 'success',\n });\n await templates.refetch();\n } catch {\n notify({\n title: tr('notifications.v3.templates.deleteFailed', 'Couldn’t delete it. Try again.'),\n tone: 'error',\n });\n }\n };\n\n return (\n <div data-account-pages-v2=\"notification-templates\" className=\"flex w-full min-w-0 flex-col\">\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.templates.title', 'Templates')}\n description={tr(\n 'notifications.v3.templates.purpose',\n 'Messages written once and sent many times: what they say, and how they’re sent.'\n )}\n back={{ label: tr('notifications.v3.title', 'Notifications'), to: paths.inbox }}\n primary={\n <Button onClick={() => navigate(paths.newTemplate)} data-testid=\"templates-new\">\n <Plus aria-hidden=\"true\" />\n {tr('notifications.v3.templates.new', 'New template')}\n </Button>\n }\n />\n <div className=\"flex flex-col gap-3\">\n <label className=\"relative block max-w-md\">\n <span className=\"sr-only\">\n {tr('notifications.v3.templates.search', 'Search templates')}\n </span>\n <Search\n className=\"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n type=\"search\"\n className=\"pl-9\"\n value={search}\n placeholder={tr('notifications.v3.templates.search', 'Search templates')}\n onChange={(event) => setSearch(event.target.value)}\n />\n </label>\n {templates.error && shown.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.templates.title', 'Templates')}\n error={templates.error}\n onRetry={() => void templates.refetch()}\n />\n ) : !templates.isLoading && shown.length === 0 ? (\n search.trim() ? (\n <EmptyState\n kind=\"no-results\"\n title={tr('notifications.v3.templates.noMatch', 'No templates match')}\n description={tr('notifications.v3.empty.searchBody', 'Try other words.')}\n />\n ) : (\n <EmptyState\n kind=\"first-use\"\n title={tr('notifications.v3.templates.emptyTitle', 'No templates yet')}\n description={tr(\n 'notifications.v3.templates.emptyBody',\n 'A template is a message you write once, like a welcome email, and send many times.'\n )}\n action={\n <Button onClick={() => navigate(paths.newTemplate)}>\n {tr('notifications.v3.templates.new', 'New template')}\n </Button>\n }\n />\n )\n ) : (\n <DataRows\n items={shown}\n loading={templates.isLoading && shown.length === 0}\n skeletonRows={5}\n getId={(template) => template.id}\n label={tr('notifications.v3.templates.title', 'Templates')}\n lead={{\n header: tr('notifications.v3.templates.template', 'Template'),\n media: () => (\n <IconTile size=\"sm\">\n <Mail aria-hidden=\"true\" />\n </IconTile>\n ),\n title: (template) => template.name,\n subtitle: (template) =>\n template.subject\n ? toReadable(template.subject, readDetails(template.variables))\n : undefined,\n onOpen: (template) => navigate(paths.template(template.slug)),\n }}\n columns={[\n {\n id: 'kind',\n header: tr('notifications.v3.templates.kind', 'About'),\n cell: (template) => kindWord(template.type, tr),\n },\n {\n id: 'channel',\n header: tr('notifications.v3.templates.channel', 'Sent by'),\n cell: (template) => channelWord(template.channel, tr),\n },\n {\n id: 'edited',\n header: tr('notifications.v3.templates.edited', 'Edited'),\n cell: (template) => when.moment(template.updatedAt),\n },\n {\n id: 'status',\n header: tr('notifications.v3.templates.status', 'Status'),\n cell: (template) =>\n 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 },\n ]}\n actions={(template) => (\n <ActionMenu\n placement=\"row\"\n label={tr('notifications.v3.templates.actionsFor', 'Actions for {{name}}', {\n name: template.name,\n })}\n items={[\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 toggle(template),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n onSelect: () => void remove(template),\n },\n ]}\n />\n )}\n />\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAiCA,SAAgBA,IAAgB;CAC9B,OACE,kBAACC,GAAD;EAAa,MAAK;EAAY,MAAM;EAClC,UAAA,kBAACC,GAAD,CAAgB,CAAA;CACL,CAAA;AAEjB;AAEA,SAASA,IAAgB;CACvB,IAAMC,IAAKC,EAAM,GACXC,IAAWC,EAAY,GACvBC,IAAQC,EAAqB,GAC7BC,IAAUC,EAAW,GACrBC,IAASC,EAAU,GACnBC,IAAOC,EAAc,GACrBC,IAAYC,EAAyB,GACrC,CAACC,GAAQC,KAAaC,EAAS,EAAE,GACjCC,IAAQC,QAAc;EAC1B,IAAMC,IAAQL,EAAO,KAAK,CAAC,CAAC,YAAY,GAClCM,IAAMR,EAAU;EAEtB,OADKO,IACEC,EAAI,QACR,MACCC,EAAS,KAAK,YAAY,CAAC,CAAC,SAASF,CAAK,MACzCE,EAAS,WAAW,GAAA,CAAI,YAAY,CAAC,CAAC,SAASF,CAAK,CACzD,IALmBC;CAMrB,GAAG,CAACN,GAAQF,EAAU,YAAY,CAAC,GAE7BU,IAAS,OAAO,MAA0C;EAC9D,IAAI;GAQF,AAPA,MAAMV,EAAU,eAAeS,EAAS,IAAI,EAAE,SAAS,CAACA,EAAS,QAAQ,CAAC,GAC1Eb,EAAO;IACL,OAAOa,EAAS,UACZrB,EAAG,wCAAwC,mBAAmB,EAAE,MAAMqB,EAAS,KAAK,CAAC,IACrFrB,EAAG,uCAAuC,kBAAkB,EAAE,MAAMqB,EAAS,KAAK,CAAC;IACvF,MAAM;GACR,CAAC,GACD,MAAMT,EAAU,QAAQ;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qC,EAAShB,EAAS,MAAMrB,CAAE;KAChD;KACA;MACE,IAAI;MACJ,QAAQA,EAAG,sCAAsC,SAAS;MAC1D,OAAO,MAAasC,EAAYjB,EAAS,SAASrB,CAAE;KACtD;KACA;MACE,IAAI;MACJ,QAAQA,EAAG,qCAAqC,QAAQ;MACxD,OAAO,MAAaU,EAAK,OAAOW,EAAS,SAAS;KACpD;KACA;MACE,IAAI;MACJ,QAAQrB,EAAG,qCAAqC,QAAQ;MACxD,OAAO,MACLqB,EAAS,UACP,kBAACkB,GAAD;OAAY,QAAO;OAAM,UAAAvC,EAAG,uBAAuB,IAAI;MAAc,CAAA,IAErE,kBAACuC,GAAD;OAAY,QAAO;OAAU,UAAAvC,EAAG,wBAAwB,KAAK;MAAc,CAAA;KAEjF;IACF;IACA,UAAU,MACR,kBAACwC,GAAD;KACE,WAAU;KACV,OAAOxC,EAAG,yCAAyC,wBAAwB,EACzE,MAAMqB,EAAS,KACjB,CAAC;KACD,OAAO,CACL;MACE,IAAI;MACJ,OAAOA,EAAS,UACZrB,EAAG,sCAAsC,UAAU,IACnDA,EAAG,qCAAqC,SAAS;MACrD,gBAAgB,KAAKsB,EAAOD,CAAQ;KACtC,GACA;MACE,IAAI;MACJ,OAAOrB,EAAG,qCAAqC,QAAQ;MACvD,QAAQ;MACR,gBAAgB,KAAKuB,EAAOF,CAAQ;KACtC,CACF;IACD,CAAA;GAEJ,CAAA,CAEA;EACF,CAAA,CAAA;;AAET"}
1
+ {"version":3,"file":"TemplatesPage.js","names":["TemplatesPage","AdminPageV2","TemplatesList","tr","useTr","navigate","useNavigate","paths","useNotificationPaths","confirm","useConfirm","notify","useNotify","when","useWhenLabels","templates","useNotificationTemplates","search","setSearch","useState","shown","useMemo","query","all","template","toggle","remove","WorkspacePage","PageHeader","Button","Plus","Search","Input","event","LoadError","EmptyState","DataRows","IconTile","Mail","toReadable","readDetails","kindWord","channelWord","StatusChip","ActionMenu"],"sources":["../../../src/v2/admin/TemplatesPage.tsx"],"sourcesContent":["/**\n * Templates (BOFF-16785, C2; the mockup's `ntemplates`), under fe-libs' `accountPagesV2`: the\n * messages this product sends, at the list width. A row each (what it's about, how it's sent,\n * when it was edited, on or off), search, New template, and ⋯ (turn off or on, delete). Admins\n * only: anyone else sees who to ask (`AdminPageV2`). Today's hook and storage.\n */\nimport { useMemo, useState } from 'react';\nimport { useNavigate } from 'react-router';\nimport { Mail, Plus, Search } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport {\n ActionMenu,\n Button,\n DataRows,\n EmptyState,\n IconTile,\n Input,\n LoadError,\n StatusChip,\n WorkspacePage,\n useConfirm,\n useNotify,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport {\n useNotificationTemplates,\n type BackendNotificationTemplate,\n} from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { channelWord, kindWord } from './words';\nimport { readDetails, toReadable } from './templateText';\n\nexport function TemplatesPage() {\n return (\n <AdminPageV2 tool=\"templates\" back={false}>\n <TemplatesList />\n </AdminPageV2>\n );\n}\n\nfunction TemplatesList() {\n const tr = useTr();\n const navigate = useNavigate();\n const paths = useNotificationPaths();\n const confirm = useConfirm();\n const notify = useNotify();\n const when = useWhenLabels();\n const templates = useNotificationTemplates();\n const [search, setSearch] = useState('');\n const shown = useMemo(() => {\n const query = search.trim().toLowerCase();\n const all = templates.allTemplates;\n if (!query) return all;\n return all.filter(\n (template) =>\n template.name.toLowerCase().includes(query) ||\n (template.subject ?? '').toLowerCase().includes(query)\n );\n }, [search, templates.allTemplates]);\n\n const toggle = async (template: BackendNotificationTemplate) => {\n try {\n await templates.updateTemplate(template.id, { enabled: !template.enabled });\n notify({\n title: template.enabled\n ? tr('notifications.v3.templates.turnedOff', '{{name}} is off', { name: template.name })\n : tr('notifications.v3.templates.turnedOn', '{{name}} is on', { name: template.name }),\n tone: 'success',\n });\n await templates.refetch();\n } catch {\n notify({\n title: tr('notifications.v3.templates.saveFailed', 'Couldn’t save. Try again.'),\n tone: 'error',\n });\n }\n };\n\n const remove = async (template: BackendNotificationTemplate) => {\n const yes = await confirm({\n title: tr('notifications.v3.templates.deleteTitle', 'Delete {{name}}?', {\n name: template.name,\n }),\n description: tr(\n 'notifications.v3.templates.deleteBody',\n 'Anything that sends this template stops sending it. Messages already sent stay as they are.'\n ),\n confirmLabel: tr('notifications.v3.templates.delete', 'Delete'),\n tone: 'danger',\n typeToConfirm: template.name,\n });\n if (!yes) return;\n try {\n await templates.deleteTemplate(template.id);\n notify({\n title: tr('notifications.v3.templates.deleted', 'Deleted {{name}}', {\n name: template.name,\n }),\n tone: 'success',\n });\n await templates.refetch();\n } catch {\n notify({\n title: tr('notifications.v3.templates.deleteFailed', 'Couldn’t delete it. Try again.'),\n tone: 'error',\n });\n }\n };\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.templates.title', 'Templates')}\n description={tr(\n 'notifications.v3.templates.purpose',\n 'Messages written once and sent many times: what they say, and how they’re sent.'\n )}\n back={{ label: tr('notifications.v3.title', 'Notifications'), to: paths.inbox }}\n primary={\n <Button onClick={() => navigate(paths.newTemplate)} data-testid=\"templates-new\">\n <Plus aria-hidden=\"true\" />\n {tr('notifications.v3.templates.new', 'New template')}\n </Button>\n }\n />\n <div className=\"flex flex-col gap-3\">\n <label className=\"relative block max-w-md\">\n <span className=\"sr-only\">\n {tr('notifications.v3.templates.search', 'Search templates')}\n </span>\n <Search\n className=\"pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n type=\"search\"\n className=\"pl-9\"\n value={search}\n placeholder={tr('notifications.v3.templates.search', 'Search templates')}\n onChange={(event) => setSearch(event.target.value)}\n />\n </label>\n {templates.error && shown.length === 0 ? (\n <LoadError\n what={tr('notifications.v3.templates.title', 'Templates')}\n error={templates.error}\n onRetry={() => void templates.refetch()}\n />\n ) : !templates.isLoading && shown.length === 0 ? (\n search.trim() ? (\n <EmptyState\n kind=\"no-results\"\n title={tr('notifications.v3.templates.noMatch', 'No templates match')}\n description={tr('notifications.v3.empty.searchBody', 'Try other words.')}\n />\n ) : (\n <EmptyState\n kind=\"first-use\"\n title={tr('notifications.v3.templates.emptyTitle', 'No templates yet')}\n description={tr(\n 'notifications.v3.templates.emptyBody',\n 'A template is a message you write once, like a welcome email, and send many times.'\n )}\n action={\n <Button onClick={() => navigate(paths.newTemplate)}>\n {tr('notifications.v3.templates.new', 'New template')}\n </Button>\n }\n />\n )\n ) : (\n <DataRows\n items={shown}\n loading={templates.isLoading && shown.length === 0}\n skeletonRows={5}\n getId={(template) => template.id}\n label={tr('notifications.v3.templates.title', 'Templates')}\n lead={{\n header: tr('notifications.v3.templates.template', 'Template'),\n media: () => (\n <IconTile size=\"sm\">\n <Mail aria-hidden=\"true\" />\n </IconTile>\n ),\n title: (template) => template.name,\n subtitle: (template) =>\n template.subject\n ? toReadable(template.subject, readDetails(template.variables))\n : undefined,\n onOpen: (template) => navigate(paths.template(template.slug)),\n }}\n columns={[\n {\n id: 'kind',\n header: tr('notifications.v3.templates.kind', 'About'),\n cell: (template) => kindWord(template.type, tr),\n },\n {\n id: 'channel',\n header: tr('notifications.v3.templates.channel', 'Sent by'),\n cell: (template) => channelWord(template.channel, tr),\n },\n {\n id: 'edited',\n header: tr('notifications.v3.templates.edited', 'Edited'),\n cell: (template) => when.moment(template.updatedAt),\n },\n {\n id: 'status',\n header: tr('notifications.v3.templates.status', 'Status'),\n cell: (template) =>\n 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 },\n ]}\n actions={(template) => (\n <ActionMenu\n placement=\"row\"\n label={tr('notifications.v3.templates.actionsFor', 'Actions for {{name}}', {\n name: template.name,\n })}\n items={[\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 toggle(template),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n onSelect: () => void remove(template),\n },\n ]}\n />\n )}\n />\n )}\n </div>\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAkCA,SAAgBA,IAAgB;CAC9B,OACE,kBAACC,GAAD;EAAa,MAAK;EAAY,MAAM;EAClC,UAAA,kBAACC,GAAD,CAAgB,CAAA;CACL,CAAA;AAEjB;AAEA,SAASA,IAAgB;CACvB,IAAMC,IAAKC,EAAM,GACXC,IAAWC,EAAY,GACvBC,IAAQC,EAAqB,GAC7BC,IAAUC,EAAW,GACrBC,IAASC,EAAU,GACnBC,IAAOC,EAAc,GACrBC,IAAYC,EAAyB,GACrC,CAACC,GAAQC,KAAaC,EAAS,EAAE,GACjCC,IAAQC,QAAc;EAC1B,IAAMC,IAAQL,EAAO,KAAK,CAAC,CAAC,YAAY,GAClCM,IAAMR,EAAU;EAEtB,OADKO,IACEC,EAAI,QACR,MACCC,EAAS,KAAK,YAAY,CAAC,CAAC,SAASF,CAAK,MACzCE,EAAS,WAAW,GAAA,CAAI,YAAY,CAAC,CAAC,SAASF,CAAK,CACzD,IALmBC;CAMrB,GAAG,CAACN,GAAQF,EAAU,YAAY,CAAC,GAE7BU,IAAS,OAAO,MAA0C;EAC9D,IAAI;GAQF,AAPA,MAAMV,EAAU,eAAeS,EAAS,IAAI,EAAE,SAAS,CAACA,EAAS,QAAQ,CAAC,GAC1Eb,EAAO;IACL,OAAOa,EAAS,UACZrB,EAAG,wCAAwC,mBAAmB,EAAE,MAAMqB,EAAS,KAAK,CAAC,IACrFrB,EAAG,uCAAuC,kBAAkB,EAAE,MAAMqB,EAAS,KAAK,CAAC;IACvF,MAAM;GACR,CAAC,GACD,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ASjB,EAAS,MAAMrB,CAAE;IAChD;IACA;KACE,IAAI;KACJ,QAAQA,EAAG,sCAAsC,SAAS;KAC1D,OAAO,MAAauC,EAAYlB,EAAS,SAASrB,CAAE;IACtD;IACA;KACE,IAAI;KACJ,QAAQA,EAAG,qCAAqC,QAAQ;KACxD,OAAO,MAAaU,EAAK,OAAOW,EAAS,SAAS;IACpD;IACA;KACE,IAAI;KACJ,QAAQrB,EAAG,qCAAqC,QAAQ;KACxD,OAAO,MACLqB,EAAS,UACP,kBAACmB,GAAD;MAAY,QAAO;MAAM,UAAAxC,EAAG,uBAAuB,IAAI;KAAc,CAAA,IAErE,kBAACwC,GAAD;MAAY,QAAO;MAAU,UAAAxC,EAAG,wBAAwB,KAAK;KAAc,CAAA;IAEjF;GACF;GACA,UAAU,MACR,kBAACyC,GAAD;IACE,WAAU;IACV,OAAOzC,EAAG,yCAAyC,wBAAwB,EACzE,MAAMqB,EAAS,KACjB,CAAC;IACD,OAAO,CACL;KACE,IAAI;KACJ,OAAOA,EAAS,UACZrB,EAAG,sCAAsC,UAAU,IACnDA,EAAG,qCAAqC,SAAS;KACrD,gBAAgB,KAAKsB,EAAOD,CAAQ;IACtC,GACA;KACE,IAAI;KACJ,OAAOrB,EAAG,qCAAqC,QAAQ;KACvD,QAAQ;KACR,gBAAgB,KAAKuB,EAAOF,CAAQ;IACtC,CACF;GACD,CAAA;EAEJ,CAAA,CAEA;CACQ,CAAA,CAAA,EAAA,CAAA;AAEnB"}
@@ -8,36 +8,36 @@ import { useState as o } from "react";
8
8
  import { Plus as s, Tag as c } from "lucide-react";
9
9
  import { jsx as l, jsxs as u } from "react/jsx-runtime";
10
10
  import { PageHeader as d } from "@burdenoff/fe-libs/chrome";
11
- import { ActionMenu as f, Button as p, DataRows as m, EmptyState as h, IconTile as g, LoadError as _, StatusChip as v, useConfirm as y, useNotify as b } from "@burdenoff/fe-libs/ui";
11
+ import { ActionMenu as f, Button as p, DataRows as m, EmptyState as h, IconTile as g, LoadError as _, StatusChip as v, WorkspacePage as y, useConfirm as b, useNotify as x } from "@burdenoff/fe-libs/ui";
12
12
  // src/v2/admin/TopicsPage.tsx
13
- var x = new Intl.NumberFormat();
14
- function S() {
13
+ var S = new Intl.NumberFormat();
14
+ function C() {
15
15
  return /* @__PURE__ */ l(r, {
16
16
  tool: "topics",
17
17
  back: !1,
18
- children: /* @__PURE__ */ l(C, {})
18
+ children: /* @__PURE__ */ l(w, {})
19
19
  });
20
20
  }
21
- function C() {
22
- let r = t(), S = n(), C = y(), w = b(), T = e(), [E, D] = o(null), O = async (e) => {
23
- let t = await T.updateTopic(e.id, { isActive: !e.isActive });
24
- w(t ? {
21
+ function w() {
22
+ let r = t(), C = n(), w = b(), T = x(), E = e(), [D, O] = o(null), k = async (e) => {
23
+ let t = await E.updateTopic(e.id, { isActive: !e.isActive });
24
+ T(t ? {
25
25
  title: e.isActive ? r("notifications.v3.topics.turnedOff", "{{name}} is off", { name: e.name }) : r("notifications.v3.topics.turnedOn", "{{name}} is on", { name: e.name }),
26
26
  tone: "success"
27
27
  } : {
28
28
  title: r("notifications.v3.templates.saveFailed", "Couldn’t save. Try again."),
29
29
  tone: "error"
30
30
  });
31
- }, k = async (e) => {
32
- if (!await C({
31
+ }, A = async (e) => {
32
+ if (!await w({
33
33
  title: r("notifications.v3.topics.deleteTitle", "Delete {{name}}?", { name: e.name }),
34
34
  description: r("notifications.v3.topics.deleteBody", "People stop being able to choose it in their settings."),
35
35
  confirmLabel: r("notifications.v3.templates.delete", "Delete"),
36
36
  tone: "danger",
37
37
  typeToConfirm: e.name
38
38
  })) return;
39
- let t = await T.deleteTopic(e.id);
40
- w(t ? {
39
+ let t = await E.deleteTopic(e.id);
40
+ T(t ? {
41
41
  title: r("notifications.v3.templates.deleted", "Deleted {{name}}", { name: e.name }),
42
42
  tone: "success"
43
43
  } : {
@@ -45,108 +45,104 @@ function C() {
45
45
  tone: "error"
46
46
  });
47
47
  };
48
- return /* @__PURE__ */ u("div", {
49
- "data-account-pages-v2": "notification-topics",
50
- className: "flex w-full min-w-0 flex-col",
51
- children: [
52
- /* @__PURE__ */ l(d, {
53
- variant: "compact",
54
- title: r("notifications.v3.topics.title", "Topics"),
55
- description: r("notifications.v3.topics.purpose", "Groups of notifications people can turn on or off."),
56
- back: {
57
- label: r("notifications.v3.title", "Notifications"),
58
- to: S.inbox
48
+ return /* @__PURE__ */ u(y, { children: [
49
+ /* @__PURE__ */ l(d, {
50
+ variant: "compact",
51
+ title: r("notifications.v3.topics.title", "Topics"),
52
+ description: r("notifications.v3.topics.purpose", "Groups of notifications people can turn on or off."),
53
+ back: {
54
+ label: r("notifications.v3.title", "Notifications"),
55
+ to: C.inbox
56
+ },
57
+ primary: /* @__PURE__ */ u(p, {
58
+ onClick: () => O("new"),
59
+ "data-testid": "topics-new",
60
+ children: [/* @__PURE__ */ l(s, { "aria-hidden": "true" }), r("notifications.v3.topics.new", "New topic")]
61
+ })
62
+ }),
63
+ E.error && E.topics.length === 0 ? /* @__PURE__ */ l(_, {
64
+ what: r("notifications.v3.topics.title", "Topics"),
65
+ error: E.error,
66
+ onRetry: () => void E.refetch()
67
+ }) : !E.isLoading && E.topics.length === 0 ? /* @__PURE__ */ l(h, {
68
+ kind: "first-use",
69
+ title: r("notifications.v3.topics.emptyTitle", "No topics yet"),
70
+ description: r("notifications.v3.topics.emptyBody", "Topics let people choose what they hear about, like “Billing” or “Product news”."),
71
+ action: /* @__PURE__ */ l(p, {
72
+ onClick: () => O("new"),
73
+ children: r("notifications.v3.topics.new", "New topic")
74
+ })
75
+ }) : /* @__PURE__ */ l(m, {
76
+ items: E.topics,
77
+ loading: E.isLoading && E.topics.length === 0,
78
+ skeletonRows: 4,
79
+ getId: (e) => e.id,
80
+ label: r("notifications.v3.topics.title", "Topics"),
81
+ lead: {
82
+ header: r("notifications.v3.topics.topic", "Topic"),
83
+ media: () => /* @__PURE__ */ l(g, {
84
+ size: "sm",
85
+ children: /* @__PURE__ */ l(c, { "aria-hidden": "true" })
86
+ }),
87
+ title: (e) => e.name,
88
+ subtitle: (e) => e.description || void 0,
89
+ onOpen: (e) => O(e)
90
+ },
91
+ columns: [
92
+ {
93
+ id: "people",
94
+ header: r("notifications.v3.topics.people", "Following"),
95
+ cell: (e) => S.format(e.subscriberCount ?? 0)
59
96
  },
60
- primary: /* @__PURE__ */ u(p, {
61
- onClick: () => D("new"),
62
- "data-testid": "topics-new",
63
- children: [/* @__PURE__ */ l(s, { "aria-hidden": "true" }), r("notifications.v3.topics.new", "New topic")]
64
- })
65
- }),
66
- T.error && T.topics.length === 0 ? /* @__PURE__ */ l(_, {
67
- what: r("notifications.v3.topics.title", "Topics"),
68
- error: T.error,
69
- onRetry: () => void T.refetch()
70
- }) : !T.isLoading && T.topics.length === 0 ? /* @__PURE__ */ l(h, {
71
- kind: "first-use",
72
- title: r("notifications.v3.topics.emptyTitle", "No topics yet"),
73
- description: r("notifications.v3.topics.emptyBody", "Topics let people choose what they hear about, like “Billing” or “Product news”."),
74
- action: /* @__PURE__ */ l(p, {
75
- onClick: () => D("new"),
76
- children: r("notifications.v3.topics.new", "New topic")
77
- })
78
- }) : /* @__PURE__ */ l(m, {
79
- items: T.topics,
80
- loading: T.isLoading && T.topics.length === 0,
81
- skeletonRows: 4,
82
- getId: (e) => e.id,
83
- label: r("notifications.v3.topics.title", "Topics"),
84
- lead: {
85
- header: r("notifications.v3.topics.topic", "Topic"),
86
- media: () => /* @__PURE__ */ l(g, {
87
- size: "sm",
88
- children: /* @__PURE__ */ l(c, { "aria-hidden": "true" })
89
- }),
90
- title: (e) => e.name,
91
- subtitle: (e) => e.description || void 0,
92
- onOpen: (e) => D(e)
97
+ {
98
+ id: "kind",
99
+ header: r("notifications.v3.templates.kind", "About"),
100
+ cell: (e) => i(e.type, r)
93
101
  },
94
- columns: [
102
+ {
103
+ id: "status",
104
+ header: r("notifications.v3.templates.status", "Status"),
105
+ cell: (e) => e.isActive ? /* @__PURE__ */ l(v, {
106
+ status: "ok",
107
+ children: r("notifications.v3.on", "On")
108
+ }) : /* @__PURE__ */ l(v, {
109
+ status: "paused",
110
+ children: r("notifications.v3.off", "Off")
111
+ })
112
+ }
113
+ ],
114
+ actions: (e) => /* @__PURE__ */ l(f, {
115
+ placement: "row",
116
+ label: r("notifications.v3.templates.actionsFor", "Actions for {{name}}", { name: e.name }),
117
+ items: [
95
118
  {
96
- id: "people",
97
- header: r("notifications.v3.topics.people", "Following"),
98
- cell: (e) => x.format(e.subscriberCount ?? 0)
119
+ id: "edit",
120
+ label: r("notifications.v3.topics.edit", "Edit"),
121
+ onSelect: () => O(e)
99
122
  },
100
123
  {
101
- id: "kind",
102
- header: r("notifications.v3.templates.kind", "About"),
103
- cell: (e) => i(e.type, r)
124
+ id: "toggle",
125
+ label: e.isActive ? r("notifications.v3.templates.turnOff", "Turn off") : r("notifications.v3.templates.turnOn", "Turn on"),
126
+ onSelect: () => void k(e)
104
127
  },
105
128
  {
106
- id: "status",
107
- header: r("notifications.v3.templates.status", "Status"),
108
- cell: (e) => e.isActive ? /* @__PURE__ */ l(v, {
109
- status: "ok",
110
- children: r("notifications.v3.on", "On")
111
- }) : /* @__PURE__ */ l(v, {
112
- status: "paused",
113
- children: r("notifications.v3.off", "Off")
114
- })
129
+ id: "delete",
130
+ label: r("notifications.v3.templates.delete", "Delete"),
131
+ danger: !0,
132
+ onSelect: () => void A(e)
115
133
  }
116
- ],
117
- actions: (e) => /* @__PURE__ */ l(f, {
118
- placement: "row",
119
- label: r("notifications.v3.templates.actionsFor", "Actions for {{name}}", { name: e.name }),
120
- items: [
121
- {
122
- id: "edit",
123
- label: r("notifications.v3.topics.edit", "Edit"),
124
- onSelect: () => D(e)
125
- },
126
- {
127
- id: "toggle",
128
- label: e.isActive ? r("notifications.v3.templates.turnOff", "Turn off") : r("notifications.v3.templates.turnOn", "Turn on"),
129
- onSelect: () => void O(e)
130
- },
131
- {
132
- id: "delete",
133
- label: r("notifications.v3.templates.delete", "Delete"),
134
- danger: !0,
135
- onSelect: () => void k(e)
136
- }
137
- ]
138
- })
139
- }),
140
- /* @__PURE__ */ l(a, {
141
- open: E !== null,
142
- topic: E === "new" ? null : E,
143
- onClose: () => D(null),
144
- onCreate: T.createTopic,
145
- onUpdate: T.updateTopic
134
+ ]
146
135
  })
147
- ]
148
- });
136
+ }),
137
+ /* @__PURE__ */ l(a, {
138
+ open: D !== null,
139
+ topic: D === "new" ? null : D,
140
+ onClose: () => O(null),
141
+ onCreate: E.createTopic,
142
+ onUpdate: E.updateTopic
143
+ })
144
+ ] });
149
145
  }
150
- export { S as TopicsPage };
146
+ export { C as TopicsPage };
151
147
 
152
148
  //# sourceMappingURL=TopicsPage.js.map