@burdenoff/microfe-notification 2026.1202.1 → 2026.1203.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.
@@ -1 +1 @@
1
- {"version":3,"file":"PreferencesPage.js","names":["PreferencesPage","tr","useTr","navigate","useNavigate","paths","useNotificationPaths","toggles","usePreferenceToggles","topicsLoading","topicsUpdatedAt","useNotificationTopics","search","setSearch","useState","shownTopics","useMemo","query","topics","topic","paused","preferenceKey","row","PreferenceRow","target","WorkspacePage","PageHeader","Button","Inbox","StaleHint","oldestLoad","SettingsSection","BellOff","Bell","EVERYDAY_CHANNELS","MORE_CHANNELS","channel","PushOptInToggle","TYPES","type","isForbidden","Megaphone","Search","Input","event","key","existing","enabled","feedback","description","options","Icon","Check","X","SettingRow","Switch","ids"],"sources":["../../src/v2/PreferencesPage.tsx"],"sourcesContent":["/**\n * Notification settings (BOFF-16785, C1; the mockup's `nprefs`), under fe-libs' `accountPagesV2`:\n * pause everything, where you hear from us, what you hear about, and the updates you can opt into,\n * as settings sections. Every switch makes the same calls as today's settings\n * (`usePreferenceToggles`); a choice you changed can go back to the default.\n */\nimport { useMemo, useState, type ReactNode } from 'react';\nimport { useNavigate } from 'react-router';\nimport { Bell, BellOff, Check, Inbox, Megaphone, Search, X } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { PushOptInToggle } from '@burdenoff/fe-libs/chrome';\nimport {\n Button,\n Input,\n SettingRow,\n SettingsSection,\n Switch,\n WorkspacePage,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationTopics } from '../hooks';\nimport {\n preferenceKey,\n usePreferenceToggles,\n type PreferenceTarget,\n} from '../hooks/usePreferenceToggles';\nimport { useTr } from '../shared/hooks/useTr';\nimport { useNotificationPaths } from '../navigation-v2/paths';\nimport { EVERYDAY_CHANNELS, MORE_CHANNELS, TYPES } from '../navigation-v2/settingsOptions';\nimport { StaleHint } from './StaleHint';\nimport { oldestLoad } from './model/loadedAt';\n\nexport function PreferencesPage() {\n const tr = useTr();\n const navigate = useNavigate();\n const paths = useNotificationPaths();\n const toggles = usePreferenceToggles();\n const {\n topics,\n isLoading: topicsLoading,\n isForbidden,\n dataUpdatedAt: topicsUpdatedAt,\n } = useNotificationTopics({\n type: 'MARKETING',\n isActive: true,\n });\n const [search, setSearch] = useState('');\n const shownTopics = useMemo(() => {\n const query = search.trim().toLowerCase();\n if (!query) return topics;\n return topics.filter(\n (topic) =>\n topic.name.toLowerCase().includes(query) || topic.description?.toLowerCase().includes(query)\n );\n }, [search, topics]);\n const paused =\n toggles.preferencesByKey.get(preferenceKey({ scope: 'GLOBAL' }))?.enabled === false;\n\n const row = (target: PreferenceTarget, label: string, options: RowOptions = {}) => (\n <PreferenceRow\n key={preferenceKey(target)}\n target={target}\n label={label}\n options={options}\n toggles={toggles}\n />\n );\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.title', 'Notifications')}\n description={tr('notifications.v3.prefs.purpose', 'Choose what reaches you, and where.')}\n secondary={\n <Button variant=\"outline\" onClick={() => navigate(paths.inbox)}>\n <Inbox aria-hidden=\"true\" />\n {tr('notifications.v3.prefs.openInbox', 'Open the inbox')}\n </Button>\n }\n />\n {/* Settings and the topics you can opt into are two reads: the earliest of them. */}\n <StaleHint loadedAt={oldestLoad(toggles.preferencesUpdatedAt, topicsUpdatedAt)} />\n <div className=\"flex flex-col gap-4\">\n <SettingsSection\n icon={BellOff}\n title={tr('notifications.v3.prefs.pauseTitle', 'Pause everything')}\n >\n {row({ scope: 'GLOBAL' }, tr('notifications.v3.prefs.pause', 'Pause notifications'), {\n description: paused\n ? tr(\n 'notifications.v3.prefs.pausedNow',\n 'Paused. Nothing reaches you until you turn this off.'\n )\n : tr(\n 'notifications.v3.prefs.pauseHelp',\n 'Stop every notification, everywhere, until you turn this off.'\n ),\n inverted: true,\n })}\n </SettingsSection>\n <SettingsSection\n icon={Bell}\n title={tr('notifications.v3.prefs.whereTitle', 'Where you hear from us')}\n >\n {[...EVERYDAY_CHANNELS, ...MORE_CHANNELS].map((channel) =>\n row({ scope: 'CHANNEL', channel: channel.value }, tr(channel.labelKey, channel.label))\n )}\n <div className=\"px-1 py-2\">\n <PushOptInToggle />\n </div>\n </SettingsSection>\n <SettingsSection\n icon={Inbox}\n title={tr('notifications.v3.prefs.whatTitle', 'What you hear about')}\n >\n {TYPES.map((type) =>\n row({ scope: 'TYPE', type: type.value }, tr(type.labelKey, type.label))\n )}\n </SettingsSection>\n {!topicsLoading && !isForbidden && topics.length > 0 ? (\n <SettingsSection\n icon={Megaphone}\n title={tr('notifications.v3.prefs.topicsTitle', 'Updates you can opt into')}\n >\n {topics.length > 5 ? (\n <label className=\"relative block px-1 py-2\">\n <span className=\"sr-only\">\n {tr('notifications.searchTopics', 'Search topics...')}\n </span>\n <Search\n className=\"pointer-events-none absolute top-1/2 left-4 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.searchTopics', 'Search topics...')}\n onChange={(event) => setSearch(event.target.value)}\n />\n </label>\n ) : null}\n {shownTopics.length === 0 ? (\n <p className=\"m-0 px-1 py-2 text-sm text-text-secondary\">\n {tr('notifications.noTopicsFound', 'No topics match your search')}\n </p>\n ) : (\n shownTopics.map((topic) =>\n row({ scope: 'TOPIC', topicId: topic.id }, topic.name, {\n description: topic.description || undefined,\n })\n )\n )}\n </SettingsSection>\n ) : null}\n </div>\n </WorkspacePage>\n );\n}\n\ninterface RowOptions {\n description?: string;\n /** \"Pause\" reads the other way round: on means delivery is off. */\n inverted?: boolean;\n}\n\nfunction PreferenceRow({\n target,\n label,\n options,\n toggles,\n}: {\n target: PreferenceTarget;\n label: string;\n options: RowOptions;\n toggles: ReturnType<typeof usePreferenceToggles>;\n}) {\n const tr = useTr();\n const key = preferenceKey(target);\n const existing = toggles.preferencesByKey.get(key);\n const enabled = existing?.enabled ?? true;\n const feedback = toggles.saveFeedback?.key === key ? toggles.saveFeedback : null;\n let description: ReactNode = options.description;\n if (feedback) {\n const Icon = feedback.type === 'success' ? Check : X;\n description = (\n <span\n className={`inline-flex items-center gap-1 ${feedback.type === 'success' ? 'text-status-success-text' : 'text-status-error-text'}`}\n role={feedback.type === 'error' ? 'alert' : 'status'}\n >\n <Icon className=\"size-3.5\" aria-hidden=\"true\" />\n {feedback.message}\n </span>\n );\n }\n return (\n <SettingRow\n label={label}\n description={description}\n control={(ids) => (\n <span className=\"flex items-center gap-2\">\n {existing ? (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n disabled={toggles.savingKey === key}\n onClick={() => void toggles.resetPreference(key)}\n >\n {tr('notifications.v3.prefs.useDefault', 'Use default')}\n </Button>\n ) : null}\n <Switch\n checked={options.inverted ? !enabled : enabled}\n disabled={toggles.savingKey === key}\n onCheckedChange={() => void toggles.togglePreference(target)}\n aria-labelledby={ids.labelId}\n aria-describedby={ids.descriptionId}\n data-testid={`pref-${key}`}\n />\n </span>\n )}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AA+BA,SAAgBA,IAAkB;CAChC,IAAMC,IAAKC,EAAM,GACXC,IAAWC,EAAY,GACvBC,IAAQC,EAAqB,GAC7BC,IAAUC,EAAqB,GAC/B,EACJ,WACA,WAAWC,GACX,gBACA,eAAeC,MACbC,EAAsB;EACxB,MAAM;EACN,UAAU;CACZ,CAAC,GACK,CAACC,GAAQC,KAAaC,EAAS,EAAE,GACjCC,IAAcC,QAAc;EAChC,IAAMC,IAAQL,EAAO,KAAK,CAAC,CAAC,YAAY;EAExC,OADKK,IACEC,EAAO,QACX,MACCC,EAAM,KAAK,YAAY,CAAC,CAAC,SAASF,CAAK,KAAKE,EAAM,aAAa,YAAY,CAAC,CAAC,SAASF,CAAK,CAC/F,IAJmBC;CAKrB,GAAG,CAACN,GAAQM,CAAM,CAAC,GACbE,IACJb,EAAQ,iBAAiB,IAAIc,EAAc,EAAE,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AAS,YAAYI,IAAQC;EACnD,IACE,kBAAC,QAAD;GACE,WAAW,kCAAkCL,EAAS,SAAS,YAAY,6BAA6B;GACxG,MAAMA,EAAS,SAAS,UAAU,UAAU;GAF9C,UAAA,CAIE,kBAACG,GAAD;IAAM,WAAU;IAAW,eAAY;GAAQ,CAAA,GAC9CH,EAAS,OACN;;CAEV;CACA,OACE,kBAACM,GAAD;EACS;EACM;EACb,UAAU,MACR,kBAAC,QAAD;GAAM,WAAU;GAAhB,UAAA,CACGR,IACC,kBAACnB,GAAD;IACE,MAAK;IACL,SAAQ;IACR,UAAUpB,EAAQ,cAAcsC;IAChC,eAAe,KAAKtC,EAAQ,gBAAgBsC,CAAG;IAE9C,UAAA5C,EAAG,qCAAqC,aAAa;GAChD,CAAA,IACN,MACJ,kBAACsD,GAAD;IACE,SAASL,EAAQ,WAAW,CAACH,IAAUA;IACvC,UAAUxC,EAAQ,cAAcsC;IAChC,uBAAuB,KAAKtC,EAAQ,iBAAiBiB,CAAM;IAC3D,mBAAiBgC,EAAI;IACrB,oBAAkBA,EAAI;IACtB,eAAa,QAAQX;GACtB,CAAA,CACG;;CAET,CAAA;AAEL"}
1
+ {"version":3,"file":"PreferencesPage.js","names":["PreferencesPage","tr","useTr","navigate","useNavigate","paths","useNotificationPaths","toggles","usePreferenceToggles","topicsLoading","topicsUpdatedAt","useNotificationTopics","search","setSearch","useState","shownTopics","useMemo","query","topics","topic","paused","preferenceKey","row","PreferenceRow","target","WorkspacePage","PageHeader","Button","Inbox","StaleHint","oldestLoad","SettingsSection","BellOff","Bell","EVERYDAY_CHANNELS","MORE_CHANNELS","channel","PushOptInToggle","TYPES","type","isForbidden","Megaphone","Search","Input","event","connection","useNeedsConnection","key","existing","enabled","feedback","description","options","Icon","Check","X","SettingRow","waitingButton","Switch","ids"],"sources":["../../src/v2/PreferencesPage.tsx"],"sourcesContent":["/**\n * Notification settings (BOFF-16785, C1; the mockup's `nprefs`), under fe-libs' `accountPagesV2`:\n * pause everything, where you hear from us, what you hear about, and the updates you can opt into,\n * as settings sections. Every switch makes the same calls as today's settings\n * (`usePreferenceToggles`); a choice you changed can go back to the default.\n */\nimport { useMemo, useState, type ReactNode } from 'react';\nimport { useNavigate } from 'react-router';\nimport { Bell, BellOff, Check, Inbox, Megaphone, Search, X } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { PushOptInToggle } from '@burdenoff/fe-libs/chrome';\nimport {\n Button,\n Input,\n SettingRow,\n SettingsSection,\n Switch,\n WorkspacePage,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationTopics } from '../hooks';\nimport {\n preferenceKey,\n usePreferenceToggles,\n type PreferenceTarget,\n} from '../hooks/usePreferenceToggles';\nimport { useTr } from '../shared/hooks/useTr';\nimport { useNeedsConnection, waitingButton } from './useNeedsConnection';\nimport { useNotificationPaths } from '../navigation-v2/paths';\nimport { EVERYDAY_CHANNELS, MORE_CHANNELS, TYPES } from '../navigation-v2/settingsOptions';\nimport { StaleHint } from './StaleHint';\nimport { oldestLoad } from './model/loadedAt';\n\nexport function PreferencesPage() {\n const tr = useTr();\n const navigate = useNavigate();\n const paths = useNotificationPaths();\n const toggles = usePreferenceToggles();\n const {\n topics,\n isLoading: topicsLoading,\n isForbidden,\n dataUpdatedAt: topicsUpdatedAt,\n } = useNotificationTopics({\n type: 'MARKETING',\n isActive: true,\n });\n const [search, setSearch] = useState('');\n const shownTopics = useMemo(() => {\n const query = search.trim().toLowerCase();\n if (!query) return topics;\n return topics.filter(\n (topic) =>\n topic.name.toLowerCase().includes(query) || topic.description?.toLowerCase().includes(query)\n );\n }, [search, topics]);\n const paused =\n toggles.preferencesByKey.get(preferenceKey({ scope: 'GLOBAL' }))?.enabled === false;\n\n const row = (target: PreferenceTarget, label: string, options: RowOptions = {}) => (\n <PreferenceRow\n key={preferenceKey(target)}\n target={target}\n label={label}\n options={options}\n toggles={toggles}\n />\n );\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.title', 'Notifications')}\n description={tr('notifications.v3.prefs.purpose', 'Choose what reaches you, and where.')}\n secondary={\n <Button variant=\"outline\" onClick={() => navigate(paths.inbox)}>\n <Inbox aria-hidden=\"true\" />\n {tr('notifications.v3.prefs.openInbox', 'Open the inbox')}\n </Button>\n }\n />\n {/* Settings and the topics you can opt into are two reads: the earliest of them. */}\n <StaleHint loadedAt={oldestLoad(toggles.preferencesUpdatedAt, topicsUpdatedAt)} />\n <div className=\"flex flex-col gap-4\">\n <SettingsSection\n icon={BellOff}\n title={tr('notifications.v3.prefs.pauseTitle', 'Pause everything')}\n >\n {row({ scope: 'GLOBAL' }, tr('notifications.v3.prefs.pause', 'Pause notifications'), {\n description: paused\n ? tr(\n 'notifications.v3.prefs.pausedNow',\n 'Paused. Nothing reaches you until you turn this off.'\n )\n : tr(\n 'notifications.v3.prefs.pauseHelp',\n 'Stop every notification, everywhere, until you turn this off.'\n ),\n inverted: true,\n })}\n </SettingsSection>\n <SettingsSection\n icon={Bell}\n title={tr('notifications.v3.prefs.whereTitle', 'Where you hear from us')}\n >\n {[...EVERYDAY_CHANNELS, ...MORE_CHANNELS].map((channel) =>\n row({ scope: 'CHANNEL', channel: channel.value }, tr(channel.labelKey, channel.label))\n )}\n <div className=\"px-1 py-2\">\n <PushOptInToggle />\n </div>\n </SettingsSection>\n <SettingsSection\n icon={Inbox}\n title={tr('notifications.v3.prefs.whatTitle', 'What you hear about')}\n >\n {TYPES.map((type) =>\n row({ scope: 'TYPE', type: type.value }, tr(type.labelKey, type.label))\n )}\n </SettingsSection>\n {!topicsLoading && !isForbidden && topics.length > 0 ? (\n <SettingsSection\n icon={Megaphone}\n title={tr('notifications.v3.prefs.topicsTitle', 'Updates you can opt into')}\n >\n {topics.length > 5 ? (\n <label className=\"relative block px-1 py-2\">\n <span className=\"sr-only\">\n {tr('notifications.searchTopics', 'Search topics...')}\n </span>\n <Search\n className=\"pointer-events-none absolute top-1/2 left-4 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.searchTopics', 'Search topics...')}\n onChange={(event) => setSearch(event.target.value)}\n />\n </label>\n ) : null}\n {shownTopics.length === 0 ? (\n <p className=\"m-0 px-1 py-2 text-sm text-text-secondary\">\n {tr('notifications.noTopicsFound', 'No topics match your search')}\n </p>\n ) : (\n shownTopics.map((topic) =>\n row({ scope: 'TOPIC', topicId: topic.id }, topic.name, {\n description: topic.description || undefined,\n })\n )\n )}\n </SettingsSection>\n ) : null}\n </div>\n </WorkspacePage>\n );\n}\n\ninterface RowOptions {\n description?: string;\n /** \"Pause\" reads the other way round: on means delivery is off. */\n inverted?: boolean;\n}\n\nfunction PreferenceRow({\n target,\n label,\n options,\n toggles,\n}: {\n target: PreferenceTarget;\n label: string;\n options: RowOptions;\n toggles: ReturnType<typeof usePreferenceToggles>;\n}) {\n const tr = useTr();\n const connection = useNeedsConnection();\n const key = preferenceKey(target);\n const existing = toggles.preferencesByKey.get(key);\n const enabled = existing?.enabled ?? true;\n const feedback = toggles.saveFeedback?.key === key ? toggles.saveFeedback : null;\n let description: ReactNode = options.description;\n if (feedback) {\n const Icon = feedback.type === 'success' ? Check : X;\n description = (\n <span\n className={`inline-flex items-center gap-1 ${feedback.type === 'success' ? 'text-status-success-text' : 'text-status-error-text'}`}\n role={feedback.type === 'error' ? 'alert' : 'status'}\n >\n <Icon className=\"size-3.5\" aria-hidden=\"true\" />\n {feedback.message}\n </span>\n );\n }\n return (\n <SettingRow\n label={label}\n description={description}\n control={(ids) => (\n <span className=\"flex items-center gap-2\">\n {existing ? (\n <Button\n size=\"sm\"\n variant=\"ghost\"\n {...waitingButton(connection, toggles.savingKey === key)}\n onClick={() => void toggles.resetPreference(key)}\n >\n {tr('notifications.v3.prefs.useDefault', 'Use default')}\n </Button>\n ) : null}\n <Switch\n checked={options.inverted ? !enabled : enabled}\n {...waitingButton(connection, toggles.savingKey === key)}\n onCheckedChange={() => void toggles.togglePreference(target)}\n aria-labelledby={ids.labelId}\n aria-describedby={ids.descriptionId}\n data-testid={`pref-${key}`}\n />\n </span>\n )}\n />\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgCA,SAAgBA,IAAkB;CAChC,IAAMC,IAAKC,EAAM,GACXC,IAAWC,EAAY,GACvBC,IAAQC,EAAqB,GAC7BC,IAAUC,EAAqB,GAC/B,EACJ,WACA,WAAWC,GACX,gBACA,eAAeC,MACbC,EAAsB;EACxB,MAAM;EACN,UAAU;CACZ,CAAC,GACK,CAACC,GAAQC,KAAaC,EAAS,EAAE,GACjCC,IAAcC,QAAc;EAChC,IAAMC,IAAQL,EAAO,KAAK,CAAC,CAAC,YAAY;EAExC,OADKK,IACEC,EAAO,QACX,MACCC,EAAM,KAAK,YAAY,CAAC,CAAC,SAASF,CAAK,KAAKE,EAAM,aAAa,YAAY,CAAC,CAAC,SAASF,CAAK,CAC/F,IAJmBC;CAKrB,GAAG,CAACN,GAAQM,CAAM,CAAC,GACbE,IACJb,EAAQ,iBAAiB,IAAIc,EAAc,EAAE,OAAO,SAAS,CAAC,CAAC,CAAC,EAAE,YAAY,IAE1EC,KAAO,GAA0B,GAAe,IAAsB,CAAC,MAC3E,kBAACC,GAAD;EAEU;EACD;EACE;EACA;CACV,GALMF,EAAcG,CAAM,CAK1B;CAGH,OACE,kBAACC,GAAD,EAAA,UAAA;EACE,kBAACC,GAAD;GACE,SAAQ;GACR,OAAOzB,EAAG,0BAA0B,eAAe;GACnD,aAAaA,EAAG,kCAAkC,qCAAqC;GACvF,WACE,kBAAC0B,GAAD;IAAQ,SAAQ;IAAU,eAAexB,EAASE,EAAM,KAAK;IAA7D,UAAA,CACE,kBAACuB,GAAD,EAAO,eAAY,OAAQ,CAAA,GAC1B3B,EAAG,oCAAoC,gBAAgB,CAClD;;EAEX,CAAA;EAED,kBAAC4B,GAAD,EAAW,UAAUC,EAAWvB,EAAQ,sBAAsBG,CAAe,EAAI,CAA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D;IACE,SAASN,EAAQ,WAAW,CAACH,IAAUA;IACvC,GAAIQ,EAAcZ,GAAYtC,EAAQ,cAAcwC,CAAG;IACvD,uBAAuB,KAAKxC,EAAQ,iBAAiBiB,CAAM;IAC3D,mBAAiBmC,EAAI;IACrB,oBAAkBA,EAAI;IACtB,eAAa,QAAQZ;GACtB,CAAA,CACG;;CAET,CAAA;AAEL"}
@@ -1,87 +1,90 @@
1
1
  import { useTr as e } from "../../shared/hooks/useTr.js";
2
- import { useNotificationPaths as t } from "../../navigation-v2/paths.js";
3
- import { TemplateFields as n } from "./TemplateFields.js";
4
- import { TemplatePreview as r } from "./TemplatePreview.js";
5
- import { useTemplateDraft as i } from "./useTemplateDraft.js";
6
- import { channelWord as a, kindWord as o } from "./words.js";
7
- import { useRef as s } from "react";
8
- import { useAppShell as c } from "@burdenoff/fe-libs/shared/providers/shell";
9
- import { Mail as l } from "lucide-react";
10
- import { jsx as u, jsxs as d } from "react/jsx-runtime";
11
- import { PageHeader as f } from "@burdenoff/fe-libs/chrome";
12
- import { Button as p, IconTile as m, Notice as h, StatusChip as g, WorkspacePage as _ } from "@burdenoff/fe-libs/ui";
2
+ import { useNeedsConnection as t, waitingButton as n, waitingItem as r } from "../useNeedsConnection.js";
3
+ import { useNotificationPaths as i } from "../../navigation-v2/paths.js";
4
+ import { TemplateFields as a } from "./TemplateFields.js";
5
+ import { TemplatePreview as o } from "./TemplatePreview.js";
6
+ import { useTemplateDraft as s } from "./useTemplateDraft.js";
7
+ import { channelWord as c, kindWord as l } from "./words.js";
8
+ import { useRef as u } from "react";
9
+ import { useAppShell as d } from "@burdenoff/fe-libs/shared/providers/shell";
10
+ import { Mail as f } from "lucide-react";
11
+ import { jsx as p, jsxs as m } from "react/jsx-runtime";
12
+ import { PageHeader as h } from "@burdenoff/fe-libs/chrome";
13
+ import { Button as g, IconTile as _, Notice as v, StatusChip as y, WorkspacePage as b } from "@burdenoff/fe-libs/ui";
13
14
  // src/v2/admin/TemplateEditor.tsx
14
- function v({ template: n, draft: r }) {
15
- let i = e(), s = t(), c = n?.enabled ? /* @__PURE__ */ u(g, {
15
+ function x({ template: a, draft: o }) {
16
+ let s = e(), u = t(), d = i(), m = a?.enabled ? /* @__PURE__ */ p(y, {
16
17
  status: "ok",
17
- children: i("notifications.v3.on", "On")
18
- }) : /* @__PURE__ */ u(g, {
18
+ children: s("notifications.v3.on", "On")
19
+ }) : /* @__PURE__ */ p(y, {
19
20
  status: "paused",
20
- children: i("notifications.v3.off", "Off")
21
+ children: s("notifications.v3.off", "Off")
21
22
  });
22
- return /* @__PURE__ */ u(f, {
23
+ return /* @__PURE__ */ p(h, {
23
24
  variant: "compact",
24
- title: n?.name || r.name.trim() || i("notifications.v3.template.new", "New template"),
25
- description: n ? i("notifications.v3.template.purpose", "{{kind}} · sent by {{channel}}", {
26
- kind: o(n.type, i),
27
- channel: a(n.channel, i).toLowerCase()
28
- }) : i("notifications.v3.template.newPurpose", "Write it once; it’s filled in for each person when it’s sent."),
29
- icon: /* @__PURE__ */ u(m, {
25
+ title: a?.name || o.name.trim() || s("notifications.v3.template.new", "New template"),
26
+ description: a ? s("notifications.v3.template.purpose", "{{kind}} · sent by {{channel}}", {
27
+ kind: l(a.type, s),
28
+ channel: c(a.channel, s).toLowerCase()
29
+ }) : s("notifications.v3.template.newPurpose", "Write it once; it’s filled in for each person when it’s sent."),
30
+ icon: /* @__PURE__ */ p(_, {
30
31
  size: "md",
31
- children: /* @__PURE__ */ u(l, { "aria-hidden": "true" })
32
+ children: /* @__PURE__ */ p(f, { "aria-hidden": "true" })
32
33
  }),
33
34
  back: {
34
- label: i("notifications.v3.templates.title", "Templates"),
35
- to: s.templates
35
+ label: s("notifications.v3.templates.title", "Templates"),
36
+ to: d.templates
36
37
  },
37
- badge: n ? c : void 0,
38
- primary: /* @__PURE__ */ u(p, {
39
- busy: r.saving,
40
- disabled: !r.ready,
41
- onClick: () => void r.save(),
38
+ badge: a ? m : void 0,
39
+ primary: /* @__PURE__ */ p(g, {
40
+ busy: o.saving,
41
+ ...n(u, !o.ready),
42
+ onClick: () => void o.save(),
42
43
  "data-testid": "template-save",
43
- children: n ? i("notifications.v3.template.save", "Save") : i("notifications.v3.template.create", "Create template")
44
+ children: a ? s("notifications.v3.template.save", "Save") : s("notifications.v3.template.create", "Create template")
44
45
  }),
45
- more: n ? [{
46
+ more: a ? [{
46
47
  id: "toggle",
47
- label: n.enabled ? i("notifications.v3.templates.turnOff", "Turn off") : i("notifications.v3.templates.turnOn", "Turn on"),
48
- onSelect: () => void r.toggle()
48
+ label: a.enabled ? s("notifications.v3.templates.turnOff", "Turn off") : s("notifications.v3.templates.turnOn", "Turn on"),
49
+ ...r(u),
50
+ onSelect: () => void o.toggle()
49
51
  }, {
50
52
  id: "delete",
51
- label: i("notifications.v3.templates.delete", "Delete"),
53
+ label: s("notifications.v3.templates.delete", "Delete"),
52
54
  danger: !0,
53
- onSelect: () => void r.remove()
55
+ ...r(u),
56
+ onSelect: () => void o.remove()
54
57
  }] : void 0
55
58
  });
56
59
  }
57
- function y({ template: t, onChanged: a }) {
58
- let o = e(), { productName: l } = c(), f = s(null), p = s(null), m = i(t, f, p, a);
59
- return /* @__PURE__ */ d(_, { children: [
60
- /* @__PURE__ */ u(v, {
60
+ function S({ template: t, onChanged: n }) {
61
+ let r = e(), { productName: i } = d(), c = u(null), l = u(null), f = s(t, c, l, n);
62
+ return /* @__PURE__ */ m(b, { children: [
63
+ /* @__PURE__ */ p(x, {
61
64
  template: t,
62
- draft: m
65
+ draft: f
63
66
  }),
64
- m.problem ? /* @__PURE__ */ u(h, {
67
+ f.problem ? /* @__PURE__ */ p(v, {
65
68
  tone: "bad",
66
69
  role: "alert",
67
- children: m.problem
70
+ children: f.problem
68
71
  }) : null,
69
- /* @__PURE__ */ d("div", {
72
+ /* @__PURE__ */ m("div", {
70
73
  className: "grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-6 max-lg:grid-cols-1",
71
- children: [/* @__PURE__ */ u(n, {
74
+ children: [/* @__PURE__ */ p(a, {
72
75
  template: t,
73
- draft: m,
74
- titleRef: f,
75
- messageRef: p
76
- }), /* @__PURE__ */ u(r, {
77
- productName: l || o("notifications.v3.template.productFallback", "Your product"),
78
- title: m.stored.title,
79
- message: m.stored.message,
80
- details: m.details
76
+ draft: f,
77
+ titleRef: c,
78
+ messageRef: l
79
+ }), /* @__PURE__ */ p(o, {
80
+ productName: i || r("notifications.v3.template.productFallback", "Your product"),
81
+ title: f.stored.title,
82
+ message: f.stored.message,
83
+ details: f.details
81
84
  })]
82
85
  })
83
86
  ] });
84
87
  }
85
- export { y as TemplateEditor };
88
+ export { S as TemplateEditor };
86
89
 
87
90
  //# sourceMappingURL=TemplateEditor.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"TemplateEditor.js","names":["TemplateHeader","tr","useTr","paths","useNotificationPaths","onOff","template","StatusChip","PageHeader","draft","kindWord","channelWord","IconTile","Mail","Button","TemplateEditor","useAppShell","titleRef","useRef","messageRef","useTemplateDraft","onChanged","WorkspacePage","Notice","TemplateFields","TemplatePreview","productName"],"sources":["../../../src/v2/admin/TemplateEditor.tsx"],"sourcesContent":["/**\n * The template editor (BOFF-16785, C2): the header, the form and the live preview. Title and\n * message are edited as people read them (`[First name]`); saving stores today's text\n * (`{{firstName}}`) and the details as today's `variables`.\n */\nimport { useRef } from 'react';\nimport { Mail } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { Button, IconTile, Notice, StatusChip, WorkspacePage } from '@burdenoff/fe-libs/ui';\nimport { useAppShell } from '@burdenoff/fe-libs/shared/providers/shell';\nimport type { BackendNotificationTemplate } from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { TemplateFields } from './TemplateFields';\nimport { TemplatePreview } from './TemplatePreview';\nimport { useTemplateDraft, type TemplateDraft } from './useTemplateDraft';\nimport { channelWord, kindWord } from './words';\n\nfunction TemplateHeader({\n template,\n draft,\n}: {\n template: BackendNotificationTemplate | null;\n draft: TemplateDraft;\n}) {\n const tr = useTr();\n const paths = useNotificationPaths();\n const onOff = template?.enabled ? (\n <StatusChip status=\"ok\">{tr('notifications.v3.on', 'On')}</StatusChip>\n ) : (\n <StatusChip status=\"paused\">{tr('notifications.v3.off', 'Off')}</StatusChip>\n );\n return (\n <PageHeader\n variant=\"compact\"\n title={\n template?.name || draft.name.trim() || tr('notifications.v3.template.new', 'New template')\n }\n description={\n template\n ? tr('notifications.v3.template.purpose', '{{kind}} · sent by {{channel}}', {\n kind: kindWord(template.type, tr),\n channel: channelWord(template.channel, tr).toLowerCase(),\n })\n : tr(\n 'notifications.v3.template.newPurpose',\n 'Write it once; it’s filled in for each person when it’s sent.'\n )\n }\n icon={\n <IconTile size=\"md\">\n <Mail aria-hidden=\"true\" />\n </IconTile>\n }\n back={{ label: tr('notifications.v3.templates.title', 'Templates'), to: paths.templates }}\n badge={template ? onOff : undefined}\n primary={\n <Button\n busy={draft.saving}\n disabled={!draft.ready}\n onClick={() => void draft.save()}\n data-testid=\"template-save\"\n >\n {template\n ? tr('notifications.v3.template.save', 'Save')\n : tr('notifications.v3.template.create', 'Create template')}\n </Button>\n }\n more={\n template\n ? [\n {\n id: 'toggle',\n label: template.enabled\n ? tr('notifications.v3.templates.turnOff', 'Turn off')\n : tr('notifications.v3.templates.turnOn', 'Turn on'),\n onSelect: () => void draft.toggle(),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n onSelect: () => void draft.remove(),\n },\n ]\n : undefined\n }\n />\n );\n}\n\nexport function TemplateEditor({\n template,\n onChanged,\n}: {\n template: BackendNotificationTemplate | null;\n /** Read the template again after turning it on or off. */\n onChanged?: () => void;\n}) {\n const tr = useTr();\n const { productName } = useAppShell();\n const titleRef = useRef<HTMLInputElement>(null);\n const messageRef = useRef<HTMLTextAreaElement>(null);\n const draft = useTemplateDraft(template, titleRef, messageRef, onChanged);\n return (\n <WorkspacePage>\n <TemplateHeader template={template} draft={draft} />\n {draft.problem ? (\n <Notice tone=\"bad\" role=\"alert\">\n {draft.problem}\n </Notice>\n ) : null}\n <div className=\"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-6 max-lg:grid-cols-1\">\n <TemplateFields\n template={template}\n draft={draft}\n titleRef={titleRef}\n messageRef={messageRef}\n />\n <TemplatePreview\n productName={\n productName || tr('notifications.v3.template.productFallback', 'Your product')\n }\n title={draft.stored.title}\n message={draft.stored.message}\n details={draft.details}\n />\n </div>\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAkBA,SAASA,EAAe,EACtB,aACA,YAIC;CACD,IAAMC,IAAKC,EAAM,GACXC,IAAQC,EAAqB,GAC7BC,IAAQC,GAAU,UACtB,kBAACC,GAAD;EAAY,QAAO;EAAM,UAAAN,EAAG,uBAAuB,IAAI;CAAc,CAAA,IAErE,kBAACM,GAAD;EAAY,QAAO;EAAU,UAAAN,EAAG,wBAAwB,KAAK;CAAc,CAAA;CAE7E,OACE,kBAACO,GAAD;EACE,SAAQ;EACR,OACEF,GAAU,QAAQG,EAAM,KAAK,KAAK,KAAKR,EAAG,iCAAiC,cAAc;EAE3F,aACEK,IACIL,EAAG,qCAAqC,kCAAkC;GACxE,MAAMS,EAASJ,EAAS,MAAML,CAAE;GAChC,SAASU,EAAYL,EAAS,SAASL,CAAE,CAAC,CAAC,YAAY;EACzD,CAAC,IACDA,EACE,wCACA,+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"}
1
+ {"version":3,"file":"TemplateEditor.js","names":["TemplateHeader","tr","useTr","connection","useNeedsConnection","paths","useNotificationPaths","onOff","template","StatusChip","PageHeader","draft","kindWord","channelWord","IconTile","Mail","Button","waitingButton","waitingItem","TemplateEditor","useAppShell","titleRef","useRef","messageRef","useTemplateDraft","onChanged","WorkspacePage","Notice","TemplateFields","TemplatePreview","productName"],"sources":["../../../src/v2/admin/TemplateEditor.tsx"],"sourcesContent":["/**\n * The template editor (BOFF-16785, C2): the header, the form and the live preview. Title and\n * message are edited as people read them (`[First name]`); saving stores today's text\n * (`{{firstName}}`) and the details as today's `variables`.\n */\nimport { useRef } from 'react';\nimport { Mail } from 'lucide-react';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport { Button, IconTile, Notice, StatusChip, WorkspacePage } from '@burdenoff/fe-libs/ui';\nimport { useAppShell } from '@burdenoff/fe-libs/shared/providers/shell';\nimport type { BackendNotificationTemplate } from '../../hooks/useNotificationTemplates';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNeedsConnection, waitingButton, waitingItem } from '../useNeedsConnection';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { TemplateFields } from './TemplateFields';\nimport { TemplatePreview } from './TemplatePreview';\nimport { useTemplateDraft, type TemplateDraft } from './useTemplateDraft';\nimport { channelWord, kindWord } from './words';\n\nfunction TemplateHeader({\n template,\n draft,\n}: {\n template: BackendNotificationTemplate | null;\n draft: TemplateDraft;\n}) {\n const tr = useTr();\n const connection = useNeedsConnection();\n const paths = useNotificationPaths();\n const onOff = template?.enabled ? (\n <StatusChip status=\"ok\">{tr('notifications.v3.on', 'On')}</StatusChip>\n ) : (\n <StatusChip status=\"paused\">{tr('notifications.v3.off', 'Off')}</StatusChip>\n );\n return (\n <PageHeader\n variant=\"compact\"\n title={\n template?.name || draft.name.trim() || tr('notifications.v3.template.new', 'New template')\n }\n description={\n template\n ? tr('notifications.v3.template.purpose', '{{kind}} · sent by {{channel}}', {\n kind: kindWord(template.type, tr),\n channel: channelWord(template.channel, tr).toLowerCase(),\n })\n : tr(\n 'notifications.v3.template.newPurpose',\n 'Write it once; it’s filled in for each person when it’s sent.'\n )\n }\n icon={\n <IconTile size=\"md\">\n <Mail aria-hidden=\"true\" />\n </IconTile>\n }\n back={{ label: tr('notifications.v3.templates.title', 'Templates'), to: paths.templates }}\n badge={template ? onOff : undefined}\n primary={\n <Button\n busy={draft.saving}\n {...waitingButton(connection, !draft.ready)}\n onClick={() => void draft.save()}\n data-testid=\"template-save\"\n >\n {template\n ? tr('notifications.v3.template.save', 'Save')\n : tr('notifications.v3.template.create', 'Create template')}\n </Button>\n }\n more={\n template\n ? [\n {\n id: 'toggle',\n label: template.enabled\n ? tr('notifications.v3.templates.turnOff', 'Turn off')\n : tr('notifications.v3.templates.turnOn', 'Turn on'),\n ...waitingItem(connection),\n onSelect: () => void draft.toggle(),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n ...waitingItem(connection),\n onSelect: () => void draft.remove(),\n },\n ]\n : undefined\n }\n />\n );\n}\n\nexport function TemplateEditor({\n template,\n onChanged,\n}: {\n template: BackendNotificationTemplate | null;\n /** Read the template again after turning it on or off. */\n onChanged?: () => void;\n}) {\n const tr = useTr();\n const { productName } = useAppShell();\n const titleRef = useRef<HTMLInputElement>(null);\n const messageRef = useRef<HTMLTextAreaElement>(null);\n const draft = useTemplateDraft(template, titleRef, messageRef, onChanged);\n return (\n <WorkspacePage>\n <TemplateHeader template={template} draft={draft} />\n {draft.problem ? (\n <Notice tone=\"bad\" role=\"alert\">\n {draft.problem}\n </Notice>\n ) : null}\n <div className=\"grid grid-cols-[minmax(0,1fr)_minmax(0,1fr)] gap-6 max-lg:grid-cols-1\">\n <TemplateFields\n template={template}\n draft={draft}\n titleRef={titleRef}\n messageRef={messageRef}\n />\n <TemplatePreview\n productName={\n productName || tr('notifications.v3.template.productFallback', 'Your product')\n }\n title={draft.stored.title}\n message={draft.stored.message}\n details={draft.details}\n />\n </div>\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;AAmBA,SAASA,EAAe,EACtB,aACA,YAIC;CACD,IAAMC,IAAKC,EAAM,GACXC,IAAaC,EAAmB,GAChCC,IAAQC,EAAqB,GAC7BC,IAAQC,GAAU,UACtB,kBAACC,GAAD;EAAY,Q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,GACX,EAAE,mBAAgBkB,EAAY,GAC9BC,IAAWC,EAAyB,IAAI,GACxCC,IAAaD,EAA4B,IAAI,GAC7CX,IAAQa,EAAiBhB,GAAUa,GAAUE,GAAYE,CAAS;CACxE,OACE,kBAACC,GAAD,EAAA,UAAA;EACE,kBAAC1B,GAAD;GAA0B;GAAiB;EAAQ,CAAA;EAClDW,EAAM,UACL,kBAACgB,GAAD;GAAQ,MAAK;GAAM,MAAK;GACrB,UAAAhB,EAAM;EACD,CAAA,IACN;EACJ,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACiB,GAAD;IACY;IACH;IACG;IACE;GACb,CAAA,GACD,kBAACC,GAAD;IACE,aACEC,KAAe7B,EAAG,6CAA6C,cAAc;IAE/E,OAAOU,EAAM,OAAO;IACpB,SAASA,EAAM,OAAO;IACtB,SAASA,EAAM;GAChB,CAAA,CACE;;CACQ,EAAA,CAAA;AAEnB"}
@@ -1,174 +1,177 @@
1
1
  import { useNotificationTemplates as e } from "../../hooks/useNotificationTemplates.js";
2
2
  import { useTr as t } from "../../shared/hooks/useTr.js";
3
- import { useNotificationPaths as n } from "../../navigation-v2/paths.js";
4
- import { AdminPageV2 as r } from "../../navigation-v2/AdminPageV2.js";
5
- import { channelWord as i, kindWord as a } from "./words.js";
6
- import { readDetails as o, toReadable as s } from "./templateText.js";
7
- import { StaleHint as c } from "../StaleHint.js";
8
- import { useMemo as l, useState as u } from "react";
9
- import { Mail as d, Plus as f, Search as p } from "lucide-react";
10
- import { useNavigate as m } from "react-router";
11
- import { jsx as h, jsxs as g } from "react/jsx-runtime";
12
- import { PageHeader as _ } from "@burdenoff/fe-libs/chrome";
13
- import { ActionMenu as v, Button as y, DataRows as b, EmptyState as x, IconTile as S, Input as C, LoadError as w, StatusChip as T, WorkspacePage as E, useConfirm as D, useNotify as O, useWhenLabels as k } from "@burdenoff/fe-libs/ui";
3
+ import { useConnectionGate as n, useNeedsConnection as r, waitingItem as i } from "../useNeedsConnection.js";
4
+ import { useNotificationPaths as a } from "../../navigation-v2/paths.js";
5
+ import { AdminPageV2 as o } from "../../navigation-v2/AdminPageV2.js";
6
+ import { channelWord as s, kindWord as c } from "./words.js";
7
+ import { readDetails as l, toReadable as u } from "./templateText.js";
8
+ import { StaleHint as d } from "../StaleHint.js";
9
+ import { useMemo as f, useState as p } from "react";
10
+ import { Mail as m, Plus as h, Search as g } from "lucide-react";
11
+ import { useNavigate as _ } from "react-router";
12
+ import { jsx as v, jsxs as y } from "react/jsx-runtime";
13
+ import { PageHeader as b } from "@burdenoff/fe-libs/chrome";
14
+ import { ActionMenu as x, Button as S, DataRows as C, EmptyState as w, IconTile as T, Input as E, LoadError as D, StatusChip as O, WorkspacePage as k, useConfirm as A, useNotify as j, useWhenLabels as M } from "@burdenoff/fe-libs/ui";
14
15
  // src/v2/admin/TemplatesPage.tsx
15
- function A() {
16
- return /* @__PURE__ */ h(r, {
16
+ function N() {
17
+ return /* @__PURE__ */ v(o, {
17
18
  tool: "templates",
18
19
  back: !1,
19
- children: /* @__PURE__ */ h(j, {})
20
+ children: /* @__PURE__ */ v(P, {})
20
21
  });
21
22
  }
22
- function j() {
23
- let r = t(), A = m(), j = n(), M = D(), N = O(), P = k(), F = e(), [I, L] = u(""), R = l(() => {
24
- let e = I.trim().toLowerCase(), t = F.allTemplates;
23
+ function P() {
24
+ let o = t(), N = r(), P = _(), F = a(), I = A(), L = n(), R = j(), z = M(), B = e(), [V, H] = p(""), U = f(() => {
25
+ let e = V.trim().toLowerCase(), t = B.allTemplates;
25
26
  return e ? t.filter((t) => t.name.toLowerCase().includes(e) || (t.subject ?? "").toLowerCase().includes(e)) : t;
26
- }, [I, F.allTemplates]), z = async (e) => {
27
+ }, [V, B.allTemplates]), W = async (e) => {
27
28
  try {
28
- await F.updateTemplate(e.id, { enabled: !e.enabled }), N({
29
- title: e.enabled ? r("notifications.v3.templates.turnedOff", "{{name}} is off", { name: e.name }) : r("notifications.v3.templates.turnedOn", "{{name}} is on", { name: e.name }),
29
+ await B.updateTemplate(e.id, { enabled: !e.enabled }), R({
30
+ title: e.enabled ? o("notifications.v3.templates.turnedOff", "{{name}} is off", { name: e.name }) : o("notifications.v3.templates.turnedOn", "{{name}} is on", { name: e.name }),
30
31
  tone: "success"
31
- }), await F.refetch();
32
+ }), await B.refetch();
32
33
  } catch {
33
- N({
34
- title: r("notifications.v3.templates.saveFailed", "Couldn’t save. Try again."),
34
+ R({
35
+ title: o("notifications.v3.templates.saveFailed", "Couldn’t save. Try again."),
35
36
  tone: "error"
36
37
  });
37
38
  }
38
- }, B = async (e) => {
39
- if (await M({
40
- title: r("notifications.v3.templates.deleteTitle", "Delete {{name}}?", { name: e.name }),
41
- description: r("notifications.v3.templates.deleteBody", "Anything that sends this template stops sending it. Messages already sent stay as they are."),
42
- confirmLabel: r("notifications.v3.templates.delete", "Delete"),
39
+ }, G = async (e) => {
40
+ if (await I({
41
+ title: o("notifications.v3.templates.deleteTitle", "Delete {{name}}?", { name: e.name }),
42
+ description: o("notifications.v3.templates.deleteBody", "Anything that sends this template stops sending it. Messages already sent stay as they are."),
43
+ confirmLabel: o("notifications.v3.templates.delete", "Delete"),
43
44
  tone: "danger",
44
45
  typeToConfirm: e.name
45
- })) try {
46
- await F.deleteTemplate(e.id), N({
47
- title: r("notifications.v3.templates.deleted", "Deleted {{name}}", { name: e.name }),
46
+ }) && !L()) try {
47
+ await B.deleteTemplate(e.id), R({
48
+ title: o("notifications.v3.templates.deleted", "Deleted {{name}}", { name: e.name }),
48
49
  tone: "success"
49
- }), await F.refetch();
50
+ }), await B.refetch();
50
51
  } catch {
51
- N({
52
- title: r("notifications.v3.templates.deleteFailed", "Couldn’t delete it. Try again."),
52
+ R({
53
+ title: o("notifications.v3.templates.deleteFailed", "Couldn’t delete it. Try again."),
53
54
  tone: "error"
54
55
  });
55
56
  }
56
57
  };
57
- return /* @__PURE__ */ g(E, { children: [
58
- /* @__PURE__ */ h(_, {
58
+ return /* @__PURE__ */ y(k, { children: [
59
+ /* @__PURE__ */ v(b, {
59
60
  variant: "compact",
60
- title: r("notifications.v3.templates.title", "Templates"),
61
- description: r("notifications.v3.templates.purpose", "Messages written once and sent many times: what they say, and how they’re sent."),
61
+ title: o("notifications.v3.templates.title", "Templates"),
62
+ description: o("notifications.v3.templates.purpose", "Messages written once and sent many times: what they say, and how they’re sent."),
62
63
  back: {
63
- label: r("notifications.v3.title", "Notifications"),
64
- to: j.inbox
64
+ label: o("notifications.v3.title", "Notifications"),
65
+ to: F.inbox
65
66
  },
66
- primary: /* @__PURE__ */ g(y, {
67
- onClick: () => A(j.newTemplate),
67
+ primary: /* @__PURE__ */ y(S, {
68
+ onClick: () => P(F.newTemplate),
68
69
  "data-testid": "templates-new",
69
- children: [/* @__PURE__ */ h(f, { "aria-hidden": "true" }), r("notifications.v3.templates.new", "New template")]
70
+ children: [/* @__PURE__ */ v(h, { "aria-hidden": "true" }), o("notifications.v3.templates.new", "New template")]
70
71
  })
71
72
  }),
72
- /* @__PURE__ */ h(c, { loadedAt: F.dataUpdatedAt }),
73
- /* @__PURE__ */ g("div", {
73
+ /* @__PURE__ */ v(d, { loadedAt: B.dataUpdatedAt }),
74
+ /* @__PURE__ */ y("div", {
74
75
  className: "flex flex-col gap-3",
75
- children: [/* @__PURE__ */ g("label", {
76
+ children: [/* @__PURE__ */ y("label", {
76
77
  className: "relative block max-w-md",
77
78
  children: [
78
- /* @__PURE__ */ h("span", {
79
+ /* @__PURE__ */ v("span", {
79
80
  className: "sr-only",
80
- children: r("notifications.v3.templates.search", "Search templates")
81
+ children: o("notifications.v3.templates.search", "Search templates")
81
82
  }),
82
- /* @__PURE__ */ h(p, {
83
+ /* @__PURE__ */ v(g, {
83
84
  className: "pointer-events-none absolute top-1/2 left-3 size-4 -translate-y-1/2 text-text-muted",
84
85
  "aria-hidden": "true"
85
86
  }),
86
- /* @__PURE__ */ h(C, {
87
+ /* @__PURE__ */ v(E, {
87
88
  type: "search",
88
89
  className: "pl-9",
89
- value: I,
90
- placeholder: r("notifications.v3.templates.search", "Search templates"),
91
- onChange: (e) => L(e.target.value)
90
+ value: V,
91
+ placeholder: o("notifications.v3.templates.search", "Search templates"),
92
+ onChange: (e) => H(e.target.value)
92
93
  })
93
94
  ]
94
- }), F.error && R.length === 0 ? /* @__PURE__ */ h(w, {
95
- what: r("notifications.v3.templates.title", "Templates"),
96
- error: F.error,
97
- onRetry: () => void F.refetch()
98
- }) : !F.isLoading && R.length === 0 ? I.trim() ? /* @__PURE__ */ h(x, {
95
+ }), B.error && U.length === 0 ? /* @__PURE__ */ v(D, {
96
+ what: o("notifications.v3.templates.title", "Templates"),
97
+ error: B.error,
98
+ onRetry: () => void B.refetch()
99
+ }) : !B.isLoading && U.length === 0 ? V.trim() ? /* @__PURE__ */ v(w, {
99
100
  kind: "no-results",
100
- title: r("notifications.v3.templates.noMatch", "No templates match"),
101
- description: r("notifications.v3.empty.searchBody", "Try other words.")
102
- }) : /* @__PURE__ */ h(x, {
101
+ title: o("notifications.v3.templates.noMatch", "No templates match"),
102
+ description: o("notifications.v3.empty.searchBody", "Try other words.")
103
+ }) : /* @__PURE__ */ v(w, {
103
104
  kind: "first-use",
104
- title: r("notifications.v3.templates.emptyTitle", "No templates yet"),
105
- description: r("notifications.v3.templates.emptyBody", "A template is a message you write once, like a welcome email, and send many times."),
106
- action: /* @__PURE__ */ h(y, {
107
- onClick: () => A(j.newTemplate),
108
- children: r("notifications.v3.templates.new", "New template")
105
+ title: o("notifications.v3.templates.emptyTitle", "No templates yet"),
106
+ description: o("notifications.v3.templates.emptyBody", "A template is a message you write once, like a welcome email, and send many times."),
107
+ action: /* @__PURE__ */ v(S, {
108
+ onClick: () => P(F.newTemplate),
109
+ children: o("notifications.v3.templates.new", "New template")
109
110
  })
110
- }) : /* @__PURE__ */ h(b, {
111
- items: R,
112
- loading: F.isLoading && R.length === 0,
111
+ }) : /* @__PURE__ */ v(C, {
112
+ items: U,
113
+ loading: B.isLoading && U.length === 0,
113
114
  skeletonRows: 5,
114
115
  getId: (e) => e.id,
115
- label: r("notifications.v3.templates.title", "Templates"),
116
+ label: o("notifications.v3.templates.title", "Templates"),
116
117
  lead: {
117
- header: r("notifications.v3.templates.template", "Template"),
118
- media: () => /* @__PURE__ */ h(S, {
118
+ header: o("notifications.v3.templates.template", "Template"),
119
+ media: () => /* @__PURE__ */ v(T, {
119
120
  size: "sm",
120
- children: /* @__PURE__ */ h(d, { "aria-hidden": "true" })
121
+ children: /* @__PURE__ */ v(m, { "aria-hidden": "true" })
121
122
  }),
122
123
  title: (e) => e.name,
123
- subtitle: (e) => e.subject ? s(e.subject, o(e.variables)) : void 0,
124
- onOpen: (e) => A(j.template(e.slug))
124
+ subtitle: (e) => e.subject ? u(e.subject, l(e.variables)) : void 0,
125
+ onOpen: (e) => P(F.template(e.slug))
125
126
  },
126
127
  columns: [
127
128
  {
128
129
  id: "kind",
129
- header: r("notifications.v3.templates.kind", "About"),
130
- cell: (e) => a(e.type, r)
130
+ header: o("notifications.v3.templates.kind", "About"),
131
+ cell: (e) => c(e.type, o)
131
132
  },
132
133
  {
133
134
  id: "channel",
134
- header: r("notifications.v3.templates.channel", "Sent by"),
135
- cell: (e) => i(e.channel, r)
135
+ header: o("notifications.v3.templates.channel", "Sent by"),
136
+ cell: (e) => s(e.channel, o)
136
137
  },
137
138
  {
138
139
  id: "edited",
139
- header: r("notifications.v3.templates.edited", "Edited"),
140
- cell: (e) => P.moment(e.updatedAt)
140
+ header: o("notifications.v3.templates.edited", "Edited"),
141
+ cell: (e) => z.moment(e.updatedAt)
141
142
  },
142
143
  {
143
144
  id: "status",
144
- header: r("notifications.v3.templates.status", "Status"),
145
- cell: (e) => e.enabled ? /* @__PURE__ */ h(T, {
145
+ header: o("notifications.v3.templates.status", "Status"),
146
+ cell: (e) => e.enabled ? /* @__PURE__ */ v(O, {
146
147
  status: "ok",
147
- children: r("notifications.v3.on", "On")
148
- }) : /* @__PURE__ */ h(T, {
148
+ children: o("notifications.v3.on", "On")
149
+ }) : /* @__PURE__ */ v(O, {
149
150
  status: "paused",
150
- children: r("notifications.v3.off", "Off")
151
+ children: o("notifications.v3.off", "Off")
151
152
  })
152
153
  }
153
154
  ],
154
- actions: (e) => /* @__PURE__ */ h(v, {
155
+ actions: (e) => /* @__PURE__ */ v(x, {
155
156
  placement: "row",
156
- label: r("notifications.v3.templates.actionsFor", "Actions for {{name}}", { name: e.name }),
157
+ label: o("notifications.v3.templates.actionsFor", "Actions for {{name}}", { name: e.name }),
157
158
  items: [{
158
159
  id: "toggle",
159
- label: e.enabled ? r("notifications.v3.templates.turnOff", "Turn off") : r("notifications.v3.templates.turnOn", "Turn on"),
160
- onSelect: () => void z(e)
160
+ label: e.enabled ? o("notifications.v3.templates.turnOff", "Turn off") : o("notifications.v3.templates.turnOn", "Turn on"),
161
+ ...i(N),
162
+ onSelect: () => void W(e)
161
163
  }, {
162
164
  id: "delete",
163
- label: r("notifications.v3.templates.delete", "Delete"),
165
+ label: o("notifications.v3.templates.delete", "Delete"),
164
166
  danger: !0,
165
- onSelect: () => void B(e)
167
+ ...i(N),
168
+ onSelect: () => void G(e)
166
169
  }]
167
170
  })
168
171
  })]
169
172
  })
170
173
  ] });
171
174
  }
172
- export { A as TemplatesPage };
175
+ export { N as TemplatesPage };
173
176
 
174
177
  //# 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","WorkspacePage","PageHeader","Button","Plus","StaleHint","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';\nimport { StaleHint } from '../StaleHint';\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 <StaleHint loadedAt={templates.dataUpdatedAt} />\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":";;;;;;;;;;;;;;AAmCA,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,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QAAQrB,EAAG,mCAAmC,OAAO;MACrD,OAAO,MAAauC,EAASlB,EAAS,MAAMrB,CAAE;KAChD;KACA;MACE,IAAI;MACJ,QAAQA,EAAG,sCAAsC,SAAS;MAC1D,OAAO,MAAawC,EAAYnB,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,kBAACoB,GAAD;OAAY,QAAO;OAAM,UAAAzC,EAAG,uBAAuB,IAAI;MAAc,CAAA,IAErE,kBAACyC,GAAD;OAAY,QAAO;OAAU,UAAAzC,EAAG,wBAAwB,KAAK;MAAc,CAAA;KAEjF;IACF;IACA,UAAU,MACR,kBAAC0C,GAAD;KACE,WAAU;KACV,OAAO1C,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;;CACQ,EAAA,CAAA;AAEnB"}
1
+ {"version":3,"file":"TemplatesPage.js","names":["TemplatesPage","AdminPageV2","TemplatesList","tr","useTr","connection","useNeedsConnection","navigate","useNavigate","paths","useNotificationPaths","confirm","useConfirm","gate","useConnectionGate","notify","useNotify","when","useWhenLabels","templates","useNotificationTemplates","search","setSearch","useState","shown","useMemo","query","all","template","toggle","remove","WorkspacePage","PageHeader","Button","Plus","StaleHint","Search","Input","event","LoadError","EmptyState","DataRows","IconTile","Mail","toReadable","readDetails","kindWord","channelWord","StatusChip","ActionMenu","waitingItem"],"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 { useConnectionGate, useNeedsConnection, waitingItem } from '../useNeedsConnection';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { channelWord, kindWord } from './words';\nimport { readDetails, toReadable } from './templateText';\nimport { StaleHint } from '../StaleHint';\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 connection = useNeedsConnection();\n const navigate = useNavigate();\n const paths = useNotificationPaths();\n const confirm = useConfirm();\n const gate = useConnectionGate();\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 // The connection may have dropped while the question was open (BOFF-18043).\n if (!yes || gate()) 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 <StaleHint loadedAt={templates.dataUpdatedAt} />\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 ...waitingItem(connection),\n onSelect: () => void toggle(template),\n },\n {\n id: 'delete',\n label: tr('notifications.v3.templates.delete', 'Delete'),\n danger: true,\n ...waitingItem(connection),\n onSelect: () => void remove(template),\n },\n ]}\n />\n )}\n />\n )}\n </div>\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAoCA,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,IAAaC,EAAmB,GAChCC,IAAWC,EAAY,GACvBC,IAAQC,EAAqB,GAC7BC,IAAUC,EAAW,GACrBC,IAAOC,EAAkB,GACzBC,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,GAA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