@burdenoff/microfe-notification 2026.1201.1 → 2026.1202.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/hooks/answeredAt.d.ts +8 -0
- package/dist/hooks/answeredAt.js +33 -0
- package/dist/hooks/answeredAt.js.map +1 -0
- package/dist/hooks/useNotificationAdmin.d.ts +2 -0
- package/dist/hooks/useNotificationAdmin.js +32 -31
- package/dist/hooks/useNotificationAdmin.js.map +1 -1
- package/dist/hooks/useNotificationPreferences.d.ts +2 -0
- package/dist/hooks/useNotificationPreferences.js +45 -43
- package/dist/hooks/useNotificationPreferences.js.map +1 -1
- package/dist/hooks/useNotificationTemplates.d.ts +2 -0
- package/dist/hooks/useNotificationTemplates.js +92 -88
- package/dist/hooks/useNotificationTemplates.js.map +1 -1
- package/dist/hooks/useNotificationTopics.d.ts +2 -0
- package/dist/hooks/useNotificationTopics.js +19 -18
- package/dist/hooks/useNotificationTopics.js.map +1 -1
- package/dist/hooks/useNotifications.d.ts +2 -0
- package/dist/hooks/useNotifications.js +69 -68
- package/dist/hooks/useNotifications.js.map +1 -1
- package/dist/hooks/usePreferenceToggles.d.ts +2 -0
- package/dist/hooks/usePreferenceToggles.js +19 -18
- package/dist/hooks/usePreferenceToggles.js.map +1 -1
- package/dist/v2/InboxPage.js +100 -98
- package/dist/v2/InboxPage.js.map +1 -1
- package/dist/v2/PreferencesPage.js +98 -92
- package/dist/v2/PreferencesPage.js.map +1 -1
- package/dist/v2/StaleHint.d.ts +4 -0
- package/dist/v2/StaleHint.js +18 -0
- package/dist/v2/StaleHint.js.map +1 -0
- package/dist/v2/admin/DeliveryLogPage.js +71 -69
- package/dist/v2/admin/DeliveryLogPage.js.map +1 -1
- package/dist/v2/admin/TemplatesPage.js +135 -130
- package/dist/v2/admin/TemplatesPage.js.map +1 -1
- package/dist/v2/admin/TopicsPage.js +51 -49
- package/dist/v2/admin/TopicsPage.js.map +1 -1
- package/dist/v2/model/loadedAt.d.ts +5 -0
- package/dist/v2/model/loadedAt.js +8 -0
- package/dist/v2/model/loadedAt.js.map +1 -0
- package/package.json +2 -2
|
@@ -3,123 +3,129 @@ import { preferenceKey as t, usePreferenceToggles as n } from "../hooks/usePrefe
|
|
|
3
3
|
import { useTr as r } from "../shared/hooks/useTr.js";
|
|
4
4
|
import { useNotificationPaths as i } from "../navigation-v2/paths.js";
|
|
5
5
|
import { EVERYDAY_CHANNELS as a, MORE_CHANNELS as o, TYPES as s } from "../navigation-v2/settingsOptions.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
6
|
+
import { StaleHint as c } from "./StaleHint.js";
|
|
7
|
+
import { oldestLoad as l } from "./model/loadedAt.js";
|
|
8
|
+
import { useMemo as u, useState as d } from "react";
|
|
9
|
+
import { Bell as f, BellOff as p, Check as m, Inbox as h, Megaphone as g, Search as _, X as v } from "lucide-react";
|
|
10
|
+
import { useNavigate as y } from "react-router";
|
|
11
|
+
import { jsx as b, jsxs as x } from "react/jsx-runtime";
|
|
12
|
+
import { PageHeader as S, PushOptInToggle as C } from "@burdenoff/fe-libs/chrome";
|
|
13
|
+
import { Button as w, Input as T, SettingRow as E, SettingsSection as D, Switch as O, WorkspacePage as k } from "@burdenoff/fe-libs/ui";
|
|
12
14
|
// src/v2/PreferencesPage.tsx
|
|
13
|
-
function
|
|
14
|
-
let
|
|
15
|
+
function A() {
|
|
16
|
+
let m = r(), v = y(), E = i(), O = n(), { topics: A, isLoading: M, isForbidden: N, dataUpdatedAt: P } = e({
|
|
15
17
|
type: "MARKETING",
|
|
16
18
|
isActive: !0
|
|
17
|
-
}), [
|
|
18
|
-
let e =
|
|
19
|
-
return e ?
|
|
20
|
-
}, [
|
|
19
|
+
}), [F, I] = d(""), L = u(() => {
|
|
20
|
+
let e = F.trim().toLowerCase();
|
|
21
|
+
return e ? A.filter((t) => t.name.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e)) : A;
|
|
22
|
+
}, [F, A]), R = O.preferencesByKey.get(t({ scope: "GLOBAL" }))?.enabled === !1, z = (e, n, r = {}) => /* @__PURE__ */ b(j, {
|
|
21
23
|
target: e,
|
|
22
24
|
label: n,
|
|
23
25
|
options: r,
|
|
24
|
-
toggles:
|
|
26
|
+
toggles: O
|
|
25
27
|
}, t(e));
|
|
26
|
-
return /* @__PURE__ */
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
return /* @__PURE__ */ x(k, { children: [
|
|
29
|
+
/* @__PURE__ */ b(S, {
|
|
30
|
+
variant: "compact",
|
|
31
|
+
title: m("notifications.v3.title", "Notifications"),
|
|
32
|
+
description: m("notifications.v3.prefs.purpose", "Choose what reaches you, and where."),
|
|
33
|
+
secondary: /* @__PURE__ */ x(w, {
|
|
34
|
+
variant: "outline",
|
|
35
|
+
onClick: () => v(E.inbox),
|
|
36
|
+
children: [/* @__PURE__ */ b(h, { "aria-hidden": "true" }), m("notifications.v3.prefs.openInbox", "Open the inbox")]
|
|
37
|
+
})
|
|
38
|
+
}),
|
|
39
|
+
/* @__PURE__ */ b(c, { loadedAt: l(O.preferencesUpdatedAt, P) }),
|
|
40
|
+
/* @__PURE__ */ x("div", {
|
|
41
|
+
className: "flex flex-col gap-4",
|
|
42
|
+
children: [
|
|
43
|
+
/* @__PURE__ */ b(D, {
|
|
44
|
+
icon: p,
|
|
45
|
+
title: m("notifications.v3.prefs.pauseTitle", "Pause everything"),
|
|
46
|
+
children: z({ scope: "GLOBAL" }, m("notifications.v3.prefs.pause", "Pause notifications"), {
|
|
47
|
+
description: R ? m("notifications.v3.prefs.pausedNow", "Paused. Nothing reaches you until you turn this off.") : m("notifications.v3.prefs.pauseHelp", "Stop every notification, everywhere, until you turn this off."),
|
|
48
|
+
inverted: !0
|
|
49
|
+
})
|
|
50
|
+
}),
|
|
51
|
+
/* @__PURE__ */ x(D, {
|
|
52
|
+
icon: f,
|
|
53
|
+
title: m("notifications.v3.prefs.whereTitle", "Where you hear from us"),
|
|
54
|
+
children: [[...a, ...o].map((e) => z({
|
|
55
|
+
scope: "CHANNEL",
|
|
56
|
+
channel: e.value
|
|
57
|
+
}, m(e.labelKey, e.label))), /* @__PURE__ */ b("div", {
|
|
58
|
+
className: "px-1 py-2",
|
|
59
|
+
children: /* @__PURE__ */ b(C, {})
|
|
60
|
+
})]
|
|
61
|
+
}),
|
|
62
|
+
/* @__PURE__ */ b(D, {
|
|
63
|
+
icon: h,
|
|
64
|
+
title: m("notifications.v3.prefs.whatTitle", "What you hear about"),
|
|
65
|
+
children: s.map((e) => z({
|
|
66
|
+
scope: "TYPE",
|
|
67
|
+
type: e.value
|
|
68
|
+
}, m(e.labelKey, e.label)))
|
|
69
|
+
}),
|
|
70
|
+
!M && !N && A.length > 0 ? /* @__PURE__ */ x(D, {
|
|
71
|
+
icon: g,
|
|
72
|
+
title: m("notifications.v3.prefs.topicsTitle", "Updates you can opt into"),
|
|
73
|
+
children: [A.length > 5 ? /* @__PURE__ */ x("label", {
|
|
74
|
+
className: "relative block px-1 py-2",
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ b("span", {
|
|
77
|
+
className: "sr-only",
|
|
78
|
+
children: m("notifications.searchTopics", "Search topics...")
|
|
79
|
+
}),
|
|
80
|
+
/* @__PURE__ */ b(_, {
|
|
81
|
+
className: "pointer-events-none absolute top-1/2 left-4 size-4 -translate-y-1/2 text-text-muted",
|
|
82
|
+
"aria-hidden": "true"
|
|
83
|
+
}),
|
|
84
|
+
/* @__PURE__ */ b(T, {
|
|
85
|
+
type: "search",
|
|
86
|
+
className: "pl-9",
|
|
87
|
+
value: F,
|
|
88
|
+
placeholder: m("notifications.searchTopics", "Search topics..."),
|
|
89
|
+
onChange: (e) => I(e.target.value)
|
|
90
|
+
})
|
|
91
|
+
]
|
|
92
|
+
}) : null, L.length === 0 ? /* @__PURE__ */ b("p", {
|
|
93
|
+
className: "m-0 px-1 py-2 text-sm text-text-secondary",
|
|
94
|
+
children: m("notifications.noTopicsFound", "No topics match your search")
|
|
95
|
+
}) : L.map((e) => z({
|
|
96
|
+
scope: "TOPIC",
|
|
97
|
+
topicId: e.id
|
|
98
|
+
}, e.name, { description: e.description || void 0 }))]
|
|
99
|
+
}) : null
|
|
100
|
+
]
|
|
34
101
|
})
|
|
35
|
-
})
|
|
36
|
-
className: "flex flex-col gap-4",
|
|
37
|
-
children: [
|
|
38
|
-
/* @__PURE__ */ v(T, {
|
|
39
|
-
icon: d,
|
|
40
|
-
title: f("notifications.v3.prefs.pauseTitle", "Pause everything"),
|
|
41
|
-
children: I({ scope: "GLOBAL" }, f("notifications.v3.prefs.pause", "Pause notifications"), {
|
|
42
|
-
description: F ? f("notifications.v3.prefs.pausedNow", "Paused. Nothing reaches you until you turn this off.") : f("notifications.v3.prefs.pauseHelp", "Stop every notification, everywhere, until you turn this off."),
|
|
43
|
-
inverted: !0
|
|
44
|
-
})
|
|
45
|
-
}),
|
|
46
|
-
/* @__PURE__ */ y(T, {
|
|
47
|
-
icon: u,
|
|
48
|
-
title: f("notifications.v3.prefs.whereTitle", "Where you hear from us"),
|
|
49
|
-
children: [[...a, ...o].map((e) => I({
|
|
50
|
-
scope: "CHANNEL",
|
|
51
|
-
channel: e.value
|
|
52
|
-
}, f(e.labelKey, e.label))), /* @__PURE__ */ v("div", {
|
|
53
|
-
className: "px-1 py-2",
|
|
54
|
-
children: /* @__PURE__ */ v(x, {})
|
|
55
|
-
})]
|
|
56
|
-
}),
|
|
57
|
-
/* @__PURE__ */ v(T, {
|
|
58
|
-
icon: p,
|
|
59
|
-
title: f("notifications.v3.prefs.whatTitle", "What you hear about"),
|
|
60
|
-
children: s.map((e) => I({
|
|
61
|
-
scope: "TYPE",
|
|
62
|
-
type: e.value
|
|
63
|
-
}, f(e.labelKey, e.label)))
|
|
64
|
-
}),
|
|
65
|
-
!A && !j && O.length > 0 ? /* @__PURE__ */ y(T, {
|
|
66
|
-
icon: m,
|
|
67
|
-
title: f("notifications.v3.prefs.topicsTitle", "Updates you can opt into"),
|
|
68
|
-
children: [O.length > 5 ? /* @__PURE__ */ y("label", {
|
|
69
|
-
className: "relative block px-1 py-2",
|
|
70
|
-
children: [
|
|
71
|
-
/* @__PURE__ */ v("span", {
|
|
72
|
-
className: "sr-only",
|
|
73
|
-
children: f("notifications.searchTopics", "Search topics...")
|
|
74
|
-
}),
|
|
75
|
-
/* @__PURE__ */ v(h, {
|
|
76
|
-
className: "pointer-events-none absolute top-1/2 left-4 size-4 -translate-y-1/2 text-text-muted",
|
|
77
|
-
"aria-hidden": "true"
|
|
78
|
-
}),
|
|
79
|
-
/* @__PURE__ */ v(C, {
|
|
80
|
-
type: "search",
|
|
81
|
-
className: "pl-9",
|
|
82
|
-
value: M,
|
|
83
|
-
placeholder: f("notifications.searchTopics", "Search topics..."),
|
|
84
|
-
onChange: (e) => N(e.target.value)
|
|
85
|
-
})
|
|
86
|
-
]
|
|
87
|
-
}) : null, P.length === 0 ? /* @__PURE__ */ v("p", {
|
|
88
|
-
className: "m-0 px-1 py-2 text-sm text-text-secondary",
|
|
89
|
-
children: f("notifications.noTopicsFound", "No topics match your search")
|
|
90
|
-
}) : P.map((e) => I({
|
|
91
|
-
scope: "TOPIC",
|
|
92
|
-
topicId: e.id
|
|
93
|
-
}, e.name, { description: e.description || void 0 }))]
|
|
94
|
-
}) : null
|
|
95
|
-
]
|
|
96
|
-
})] });
|
|
102
|
+
] });
|
|
97
103
|
}
|
|
98
|
-
function
|
|
104
|
+
function j({ target: e, label: n, options: i, toggles: a }) {
|
|
99
105
|
let o = r(), s = t(e), c = a.preferencesByKey.get(s), l = c?.enabled ?? !0, u = a.saveFeedback?.key === s ? a.saveFeedback : null, d = i.description;
|
|
100
106
|
if (u) {
|
|
101
|
-
let e = u.type === "success" ?
|
|
102
|
-
d = /* @__PURE__ */
|
|
107
|
+
let e = u.type === "success" ? m : v;
|
|
108
|
+
d = /* @__PURE__ */ x("span", {
|
|
103
109
|
className: `inline-flex items-center gap-1 ${u.type === "success" ? "text-status-success-text" : "text-status-error-text"}`,
|
|
104
110
|
role: u.type === "error" ? "alert" : "status",
|
|
105
|
-
children: [/* @__PURE__ */
|
|
111
|
+
children: [/* @__PURE__ */ b(e, {
|
|
106
112
|
className: "size-3.5",
|
|
107
113
|
"aria-hidden": "true"
|
|
108
114
|
}), u.message]
|
|
109
115
|
});
|
|
110
116
|
}
|
|
111
|
-
return /* @__PURE__ */
|
|
117
|
+
return /* @__PURE__ */ b(E, {
|
|
112
118
|
label: n,
|
|
113
119
|
description: d,
|
|
114
|
-
control: (t) => /* @__PURE__ */
|
|
120
|
+
control: (t) => /* @__PURE__ */ x("span", {
|
|
115
121
|
className: "flex items-center gap-2",
|
|
116
|
-
children: [c ? /* @__PURE__ */
|
|
122
|
+
children: [c ? /* @__PURE__ */ b(w, {
|
|
117
123
|
size: "sm",
|
|
118
124
|
variant: "ghost",
|
|
119
125
|
disabled: a.savingKey === s,
|
|
120
126
|
onClick: () => void a.resetPreference(s),
|
|
121
127
|
children: o("notifications.v3.prefs.useDefault", "Use default")
|
|
122
|
-
}) : null, /* @__PURE__ */
|
|
128
|
+
}) : null, /* @__PURE__ */ b(O, {
|
|
123
129
|
checked: i.inverted ? !l : l,
|
|
124
130
|
disabled: a.savingKey === s,
|
|
125
131
|
onCheckedChange: () => void a.togglePreference(e),
|
|
@@ -130,6 +136,6 @@ function k({ target: e, label: n, options: i, toggles: a }) {
|
|
|
130
136
|
})
|
|
131
137
|
});
|
|
132
138
|
}
|
|
133
|
-
export {
|
|
139
|
+
export { A as PreferencesPage };
|
|
134
140
|
|
|
135
141
|
//# sourceMappingURL=PreferencesPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PreferencesPage.js","names":["PreferencesPage","tr","useTr","navigate","useNavigate","paths","useNotificationPaths","toggles","usePreferenceToggles","topicsLoading","useNotificationTopics","search","setSearch","useState","shownTopics","useMemo","query","topics","topic","paused","preferenceKey","row","PreferenceRow","target","WorkspacePage","PageHeader","Button","Inbox","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';\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 } = 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 <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":";;;;;;;;;;;;AA6BA,SAAgBA,IAAkB;CAChC,IAAMC,IAAKC,EAAM,GACXC,IAAWC,EAAY,GACvBC,IAAQC,EAAqB,GAC7BC,IAAUC,EAAqB,GAC/B,EACJ,WACA,WAAWC,GACX,mBACEC,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,IACJZ,EAAQ,iBAAiB,IAAIa,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,CACE,kBAACC,GAAD;EACE,SAAQ;EACR,OAAOxB,EAAG,0BAA0B,eAAe;EACnD,aAAaA,EAAG,kCAAkC,qCAAqC;EACvF,WACE,kBAACyB,GAAD;GAAQ,SAAQ;GAAU,eAAevB,EAASE,EAAM,KAAK;GAA7D,UAAA,CACE,kBAACsB,GAAD,EAAO,eAAY,OAAQ,CAAA,GAC1B1B,EAAG,oCAAoC,gBAAgB,CAClD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CAACH,IAAUA;IACvC,UAAUrC,EAAQ,cAAcmC;IAChC,uBAAuB,KAAKnC,EAAQ,iBAAiBgB,CAAM;IAC3D,mBAAiB8B,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","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,G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C,IAAyBC,EAAQ;CACrC,IAAIF,GAAU;EACZ,IAAMG,IAAOH,EAAS,SAAS,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"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Clock as e } from "lucide-react";
|
|
2
|
+
import { jsx as t, jsxs as n } from "react/jsx-runtime";
|
|
3
|
+
import { useAccountPagesV2 as r, useStaleSince as i } from "@burdenoff/fe-libs/ui";
|
|
4
|
+
// src/v2/StaleHint.tsx
|
|
5
|
+
function a({ loadedAt: a, className: o }) {
|
|
6
|
+
let s = r(), c = i(s ? a : 0);
|
|
7
|
+
return c.label ? /* @__PURE__ */ n("p", {
|
|
8
|
+
"data-stale-hint": "",
|
|
9
|
+
className: `m-0 flex items-center gap-1.5 text-xs text-status-warning-text ${o ?? ""}`.trim(),
|
|
10
|
+
children: [/* @__PURE__ */ t(e, {
|
|
11
|
+
className: "size-3.5 shrink-0",
|
|
12
|
+
"aria-hidden": "true"
|
|
13
|
+
}), /* @__PURE__ */ t("span", { children: c.label })]
|
|
14
|
+
}) : null;
|
|
15
|
+
}
|
|
16
|
+
export { a as StaleHint };
|
|
17
|
+
|
|
18
|
+
//# sourceMappingURL=StaleHint.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StaleHint.js","names":["StaleHint","v2","useAccountPagesV2","stale","useStaleSince","loadedAt","className","Clock"],"sources":["../../src/v2/StaleHint.tsx"],"sourcesContent":["/**\n * While the app is offline, under the page's header: \"Showing what was loaded at 10:42. Buttons\n * that need a connection wait until you're back.\" (fe-libs `useStaleSince`, F2; BOFF-16786).\n * Online, before the data has loaded, or without the Account & platform opt-in, nothing.\n *\n * `loadedAt`: when the page's data arrived (its hook's `dataUpdatedAt`, ms; 0 = not yet).\n */\nimport { Clock } from 'lucide-react';\nimport { useAccountPagesV2, useStaleSince } from '@burdenoff/fe-libs/ui';\n\nexport function StaleHint({ loadedAt, className }: { loadedAt: number; className?: string }) {\n const v2 = useAccountPagesV2();\n const stale = useStaleSince(v2 ? loadedAt : 0);\n if (!stale.label) return null;\n return (\n <p\n data-stale-hint=\"\"\n className={`m-0 flex items-center gap-1.5 text-xs text-status-warning-text ${className ?? ''}`.trim()}\n >\n <Clock className=\"size-3.5 shrink-0\" aria-hidden=\"true\" />\n <span>{stale.label}</span>\n </p>\n );\n}\n"],"mappings":";;;;AAUA,SAAgBA,EAAU,EAAE,aAAU,gBAAuD;CAC3F,IAAMC,IAAKC,EAAkB,GACvBC,IAAQC,EAAcH,IAAKI,IAAW,CAAC;CAE7C,OADKF,EAAM,QAET,kBAAC,KAAD;EACE,mBAAgB;EAChB,WAAW,kEAAkEG,KAAa,KAAK,KAAK;EAFtG,UAAA,CAIE,kBAACC,GAAD;GAAO,WAAU;GAAoB,eAAY;EAAQ,CAAA,GACzD,kBAAC,QAAD,EAAA,UAAOJ,EAAM,MAAY,CAAA,CACxB;C,KARoB;AAU3B"}
|
|
@@ -5,57 +5,58 @@ import { AdminPageV2 as r } from "../../navigation-v2/AdminPageV2.js";
|
|
|
5
5
|
import { NotificationDetailPanel as i } from "../NotificationDetailPanel.js";
|
|
6
6
|
import { groupByDay as a } from "../model/days.js";
|
|
7
7
|
import { channelWord as o, deliveryState as s } from "./words.js";
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
8
|
+
import { StaleHint as c } from "../StaleHint.js";
|
|
9
|
+
import { useMemo as l, useState as u } from "react";
|
|
10
|
+
import { useFeatureFlagDetails as d } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
11
|
+
import { CheckCircle2 as f, Clock as p, XCircle as m } from "lucide-react";
|
|
12
|
+
import { Navigate as h } from "react-router";
|
|
13
|
+
import { jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
14
|
+
import { PageHeader as v } from "@burdenoff/fe-libs/chrome";
|
|
15
|
+
import { EmptyState as y, LoadError as b, Segmented as x, Skeleton as S, StatusChip as C, WorkspacePage as w, useWhenLabels as T } from "@burdenoff/fe-libs/ui";
|
|
15
16
|
// src/v2/admin/DeliveryLogPage.tsx
|
|
16
|
-
var
|
|
17
|
-
ok:
|
|
18
|
-
bad:
|
|
19
|
-
waiting:
|
|
20
|
-
},
|
|
17
|
+
var E = {
|
|
18
|
+
ok: f,
|
|
19
|
+
bad: m,
|
|
20
|
+
waiting: p
|
|
21
|
+
}, D = new Intl.NumberFormat(), O = {
|
|
21
22
|
ok: "text-status-success-text",
|
|
22
23
|
bad: "text-status-error-text",
|
|
23
24
|
waiting: "text-status-warning-text"
|
|
24
25
|
};
|
|
25
|
-
function
|
|
26
|
-
let e =
|
|
27
|
-
return /* @__PURE__ */
|
|
26
|
+
function k() {
|
|
27
|
+
let e = d("notification.history"), t = n(), i = e ? !!e.value : !1;
|
|
28
|
+
return /* @__PURE__ */ g(r, {
|
|
28
29
|
tool: "deliveryLog",
|
|
29
30
|
back: !1,
|
|
30
|
-
children: i ? /* @__PURE__ */
|
|
31
|
+
children: i ? /* @__PURE__ */ g(I, {}) : /* @__PURE__ */ g(h, {
|
|
31
32
|
to: t.inbox,
|
|
32
33
|
replace: !0
|
|
33
34
|
})
|
|
34
35
|
});
|
|
35
36
|
}
|
|
36
|
-
function
|
|
37
|
+
function A(e, t) {
|
|
37
38
|
return e.recipientEmail || e.recipientPhone || t("notifications.v3.log.inApp", "someone in the app");
|
|
38
39
|
}
|
|
39
|
-
function
|
|
40
|
+
function j({ counts: e, tone: n, onTone: r }) {
|
|
40
41
|
let i = t();
|
|
41
|
-
return /* @__PURE__ */
|
|
42
|
+
return /* @__PURE__ */ _("div", {
|
|
42
43
|
className: "flex flex-wrap items-center gap-2",
|
|
43
44
|
"data-testid": "log-counts",
|
|
44
45
|
children: [
|
|
45
|
-
/* @__PURE__ */
|
|
46
|
+
/* @__PURE__ */ g(C, {
|
|
46
47
|
status: "ok",
|
|
47
|
-
children: i("notifications.v3.log.delivered", "{{count}} delivered", { count:
|
|
48
|
+
children: i("notifications.v3.log.delivered", "{{count}} delivered", { count: D.format(e.ok) })
|
|
48
49
|
}),
|
|
49
|
-
/* @__PURE__ */
|
|
50
|
+
/* @__PURE__ */ g(C, {
|
|
50
51
|
status: "bad",
|
|
51
|
-
children: i("notifications.v3.log.failed", "{{count}} didn’t arrive", { count:
|
|
52
|
+
children: i("notifications.v3.log.failed", "{{count}} didn’t arrive", { count: D.format(e.bad) })
|
|
52
53
|
}),
|
|
53
|
-
/* @__PURE__ */
|
|
54
|
+
/* @__PURE__ */ g(C, {
|
|
54
55
|
status: "waiting",
|
|
55
|
-
children: i("notifications.v3.log.waiting", "{{count}} waiting", { count:
|
|
56
|
+
children: i("notifications.v3.log.waiting", "{{count}} waiting", { count: D.format(e.waiting) })
|
|
56
57
|
}),
|
|
57
|
-
/* @__PURE__ */
|
|
58
|
-
/* @__PURE__ */
|
|
58
|
+
/* @__PURE__ */ g("span", { className: "flex-1" }),
|
|
59
|
+
/* @__PURE__ */ g(x, {
|
|
59
60
|
"aria-label": i("notifications.v3.log.show", "Show"),
|
|
60
61
|
value: n,
|
|
61
62
|
onValueChange: r,
|
|
@@ -81,28 +82,28 @@ function A({ counts: e, tone: n, onTone: r }) {
|
|
|
81
82
|
]
|
|
82
83
|
});
|
|
83
84
|
}
|
|
84
|
-
function
|
|
85
|
-
let r = t(), i =
|
|
86
|
-
return /* @__PURE__ */
|
|
85
|
+
function M({ item: e, onOpen: n }) {
|
|
86
|
+
let r = t(), i = T(), { notification: a, state: s } = e, c = E[s.tone];
|
|
87
|
+
return /* @__PURE__ */ g("li", {
|
|
87
88
|
"data-row-id": a.id,
|
|
88
|
-
children: /* @__PURE__ */
|
|
89
|
+
children: /* @__PURE__ */ _("button", {
|
|
89
90
|
type: "button",
|
|
90
91
|
className: "flex w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-3 py-2.5 text-left",
|
|
91
92
|
onClick: () => n(a.id),
|
|
92
93
|
children: [
|
|
93
|
-
/* @__PURE__ */
|
|
94
|
-
className: `size-4 shrink-0 ${
|
|
94
|
+
/* @__PURE__ */ g(c, {
|
|
95
|
+
className: `size-4 shrink-0 ${O[s.tone]}`,
|
|
95
96
|
"aria-hidden": "true"
|
|
96
97
|
}),
|
|
97
|
-
/* @__PURE__ */
|
|
98
|
+
/* @__PURE__ */ _("span", {
|
|
98
99
|
className: "min-w-0 flex-1",
|
|
99
|
-
children: [/* @__PURE__ */
|
|
100
|
+
children: [/* @__PURE__ */ g("span", {
|
|
100
101
|
className: "block truncate text-sm text-text-primary",
|
|
101
102
|
children: r("notifications.v3.log.line", "{{title}} → {{who}}", {
|
|
102
103
|
title: a.title,
|
|
103
|
-
who:
|
|
104
|
+
who: A(a, r)
|
|
104
105
|
})
|
|
105
|
-
}), /* @__PURE__ */
|
|
106
|
+
}), /* @__PURE__ */ _("span", {
|
|
106
107
|
className: "block truncate text-xs text-text-secondary",
|
|
107
108
|
children: [
|
|
108
109
|
o(a.channel, r),
|
|
@@ -111,7 +112,7 @@ function j({ item: e, onOpen: n }) {
|
|
|
111
112
|
]
|
|
112
113
|
})]
|
|
113
114
|
}),
|
|
114
|
-
/* @__PURE__ */
|
|
115
|
+
/* @__PURE__ */ g("time", {
|
|
115
116
|
className: "shrink-0 text-xs text-text-muted",
|
|
116
117
|
dateTime: a.createdAt,
|
|
117
118
|
children: i.moment(a.createdAt)
|
|
@@ -120,20 +121,20 @@ function j({ item: e, onOpen: n }) {
|
|
|
120
121
|
})
|
|
121
122
|
});
|
|
122
123
|
}
|
|
123
|
-
function
|
|
124
|
+
function N({ items: e, onOpen: n }) {
|
|
124
125
|
let r = t();
|
|
125
|
-
return /* @__PURE__ */
|
|
126
|
+
return /* @__PURE__ */ g("div", {
|
|
126
127
|
className: "flex flex-col gap-4",
|
|
127
128
|
"data-testid": "log-rows",
|
|
128
|
-
children: a(e, r).map((e) => /* @__PURE__ */
|
|
129
|
+
children: a(e, r).map((e) => /* @__PURE__ */ _("section", {
|
|
129
130
|
"aria-label": e.label,
|
|
130
131
|
className: "flex flex-col gap-1",
|
|
131
|
-
children: [/* @__PURE__ */
|
|
132
|
+
children: [/* @__PURE__ */ g("h2", {
|
|
132
133
|
className: "m-0 px-1 text-xs font-medium text-text-muted",
|
|
133
134
|
children: e.label
|
|
134
|
-
}), /* @__PURE__ */
|
|
135
|
+
}), /* @__PURE__ */ g("ul", {
|
|
135
136
|
className: "m-0 flex list-none flex-col divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle bg-bg-surface p-0",
|
|
136
|
-
children: e.items.map((e) => /* @__PURE__ */
|
|
137
|
+
children: e.items.map((e) => /* @__PURE__ */ g(M, {
|
|
137
138
|
item: e,
|
|
138
139
|
onOpen: n
|
|
139
140
|
}, e.notification.id))
|
|
@@ -141,44 +142,44 @@ function M({ items: e, onOpen: n }) {
|
|
|
141
142
|
}, e.key))
|
|
142
143
|
});
|
|
143
144
|
}
|
|
144
|
-
function
|
|
145
|
+
function P({ filtered: e }) {
|
|
145
146
|
let n = t();
|
|
146
|
-
return /* @__PURE__ */
|
|
147
|
+
return /* @__PURE__ */ g(y, {
|
|
147
148
|
kind: e ? "filtered" : "first-use",
|
|
148
149
|
title: e ? n("notifications.v3.log.noneTitle", "Nothing here") : n("notifications.v3.log.emptyTitle", "Nothing sent yet"),
|
|
149
150
|
description: n("notifications.v3.log.emptyBody", "Each notification sent is listed here with what happened to it.")
|
|
150
151
|
});
|
|
151
152
|
}
|
|
152
|
-
function
|
|
153
|
-
return /* @__PURE__ */
|
|
153
|
+
function F() {
|
|
154
|
+
return /* @__PURE__ */ g("div", {
|
|
154
155
|
className: "flex flex-col gap-2",
|
|
155
156
|
"aria-busy": "true",
|
|
156
|
-
children: Array.from({ length: 6 }, (e, t) => /* @__PURE__ */
|
|
157
|
+
children: Array.from({ length: 6 }, (e, t) => /* @__PURE__ */ g(S, { className: "h-12 w-full rounded-lg" }, t))
|
|
157
158
|
});
|
|
158
159
|
}
|
|
159
|
-
function
|
|
160
|
-
let r = t(), a = n(), o = e(), [
|
|
160
|
+
function I() {
|
|
161
|
+
let r = t(), a = n(), o = e(), [d, f] = u("any"), [p, m] = u(null), h = l(() => o.notifications.map((e) => ({
|
|
161
162
|
notification: e,
|
|
162
163
|
state: s(e.deliveryStatus, r),
|
|
163
164
|
createdAt: e.createdAt
|
|
164
|
-
})), [o.notifications, r]),
|
|
165
|
+
})), [o.notifications, r]), y = l(() => {
|
|
165
166
|
let e = {
|
|
166
167
|
ok: 0,
|
|
167
168
|
bad: 0,
|
|
168
169
|
waiting: 0
|
|
169
170
|
};
|
|
170
|
-
for (let t of
|
|
171
|
+
for (let t of h) e[t.state.tone] += 1;
|
|
171
172
|
return e;
|
|
172
|
-
}, [
|
|
173
|
-
items:
|
|
174
|
-
onOpen:
|
|
173
|
+
}, [h]), x = d === "any" ? h : h.filter((e) => e.state.tone === d), S = h.length === 0, C = /* @__PURE__ */ g(N, {
|
|
174
|
+
items: x,
|
|
175
|
+
onOpen: m
|
|
175
176
|
});
|
|
176
|
-
return o.error &&
|
|
177
|
+
return o.error && S ? C = /* @__PURE__ */ g(b, {
|
|
177
178
|
what: r("notifications.v3.log.title", "Delivery log"),
|
|
178
179
|
error: o.error,
|
|
179
180
|
onRetry: () => void o.refetch()
|
|
180
|
-
}) : o.isLoading &&
|
|
181
|
-
/* @__PURE__ */
|
|
181
|
+
}) : o.isLoading && S ? C = /* @__PURE__ */ g(F, {}) : x.length === 0 && (C = /* @__PURE__ */ g(P, { filtered: d !== "any" })), /* @__PURE__ */ _(w, { children: [
|
|
182
|
+
/* @__PURE__ */ g(v, {
|
|
182
183
|
variant: "compact",
|
|
183
184
|
title: r("notifications.v3.log.title", "Delivery log"),
|
|
184
185
|
description: r("notifications.v3.log.purpose", "Every notification sent, and whether it arrived."),
|
|
@@ -187,20 +188,21 @@ function F() {
|
|
|
187
188
|
to: a.inbox
|
|
188
189
|
}
|
|
189
190
|
}),
|
|
190
|
-
/* @__PURE__ */ g(
|
|
191
|
+
/* @__PURE__ */ g(c, { loadedAt: o.dataUpdatedAt }),
|
|
192
|
+
/* @__PURE__ */ _("div", {
|
|
191
193
|
className: "flex flex-col gap-3",
|
|
192
|
-
children: [/* @__PURE__ */
|
|
193
|
-
counts:
|
|
194
|
-
tone:
|
|
195
|
-
onTone:
|
|
196
|
-
}),
|
|
194
|
+
children: [/* @__PURE__ */ g(j, {
|
|
195
|
+
counts: y,
|
|
196
|
+
tone: d,
|
|
197
|
+
onTone: f
|
|
198
|
+
}), C]
|
|
197
199
|
}),
|
|
198
|
-
/* @__PURE__ */
|
|
199
|
-
id:
|
|
200
|
-
onClose: () =>
|
|
200
|
+
/* @__PURE__ */ g(i, {
|
|
201
|
+
id: p,
|
|
202
|
+
onClose: () => m(null)
|
|
201
203
|
})
|
|
202
204
|
] });
|
|
203
205
|
}
|
|
204
|
-
export {
|
|
206
|
+
export { k as DeliveryLogPage };
|
|
205
207
|
|
|
206
208
|
//# sourceMappingURL=DeliveryLogPage.js.map
|