@burdenoff/microfe-notification 2026.1130.1 → 2026.1201.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.
|
@@ -2,33 +2,36 @@ import { useNotificationAdmin as e } from "../../hooks/useNotificationAdmin.js";
|
|
|
2
2
|
import { useTr as t } from "../../shared/hooks/useTr.js";
|
|
3
3
|
import { useNotificationPaths as n } from "../../navigation-v2/paths.js";
|
|
4
4
|
import { AdminPageV2 as r } from "../../navigation-v2/AdminPageV2.js";
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
5
|
+
import { NotificationDetailPanel as i } from "../NotificationDetailPanel.js";
|
|
6
|
+
import { groupByDay as a } from "../model/days.js";
|
|
7
|
+
import { channelWord as o, deliveryState as s } from "./words.js";
|
|
8
|
+
import { useMemo as c, useState as l } from "react";
|
|
9
|
+
import { useFeatureFlagDetails as u } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
10
|
+
import { CheckCircle2 as d, Clock as f, XCircle as p } from "lucide-react";
|
|
11
|
+
import { Navigate as m } from "react-router";
|
|
12
12
|
import { jsx as h, jsxs as g } from "react/jsx-runtime";
|
|
13
13
|
import { PageHeader as _ } from "@burdenoff/fe-libs/chrome";
|
|
14
14
|
import { EmptyState as v, LoadError as y, Segmented as b, Skeleton as x, StatusChip as S, WorkspacePage as C, useWhenLabels as w } from "@burdenoff/fe-libs/ui";
|
|
15
15
|
// src/v2/admin/DeliveryLogPage.tsx
|
|
16
16
|
var T = {
|
|
17
|
-
ok:
|
|
18
|
-
bad:
|
|
19
|
-
waiting:
|
|
17
|
+
ok: d,
|
|
18
|
+
bad: p,
|
|
19
|
+
waiting: f
|
|
20
20
|
}, E = new Intl.NumberFormat(), D = {
|
|
21
21
|
ok: "text-status-success-text",
|
|
22
22
|
bad: "text-status-error-text",
|
|
23
23
|
waiting: "text-status-warning-text"
|
|
24
24
|
};
|
|
25
25
|
function O() {
|
|
26
|
-
let e =
|
|
27
|
-
return
|
|
26
|
+
let e = u("notification.history"), t = n(), i = e ? !!e.value : !1;
|
|
27
|
+
return /* @__PURE__ */ h(r, {
|
|
28
28
|
tool: "deliveryLog",
|
|
29
29
|
back: !1,
|
|
30
|
-
children: /* @__PURE__ */ h(F, {})
|
|
31
|
-
|
|
30
|
+
children: i ? /* @__PURE__ */ h(F, {}) : /* @__PURE__ */ h(m, {
|
|
31
|
+
to: t.inbox,
|
|
32
|
+
replace: !0
|
|
33
|
+
})
|
|
34
|
+
});
|
|
32
35
|
}
|
|
33
36
|
function k(e, t) {
|
|
34
37
|
return e.recipientEmail || e.recipientPhone || t("notifications.v3.log.inApp", "someone in the app");
|
|
@@ -79,7 +82,7 @@ function A({ counts: e, tone: n, onTone: r }) {
|
|
|
79
82
|
});
|
|
80
83
|
}
|
|
81
84
|
function j({ item: e, onOpen: n }) {
|
|
82
|
-
let r = t(), i = w(), { notification: a, state:
|
|
85
|
+
let r = t(), i = w(), { notification: a, state: s } = e, c = T[s.tone];
|
|
83
86
|
return /* @__PURE__ */ h("li", {
|
|
84
87
|
"data-row-id": a.id,
|
|
85
88
|
children: /* @__PURE__ */ g("button", {
|
|
@@ -88,7 +91,7 @@ function j({ item: e, onOpen: n }) {
|
|
|
88
91
|
onClick: () => n(a.id),
|
|
89
92
|
children: [
|
|
90
93
|
/* @__PURE__ */ h(c, {
|
|
91
|
-
className: `size-4 shrink-0 ${D[
|
|
94
|
+
className: `size-4 shrink-0 ${D[s.tone]}`,
|
|
92
95
|
"aria-hidden": "true"
|
|
93
96
|
}),
|
|
94
97
|
/* @__PURE__ */ g("span", {
|
|
@@ -102,9 +105,9 @@ function j({ item: e, onOpen: n }) {
|
|
|
102
105
|
}), /* @__PURE__ */ g("span", {
|
|
103
106
|
className: "block truncate text-xs text-text-secondary",
|
|
104
107
|
children: [
|
|
105
|
-
|
|
108
|
+
o(a.channel, r),
|
|
106
109
|
" · ",
|
|
107
|
-
|
|
110
|
+
s.word
|
|
108
111
|
]
|
|
109
112
|
})]
|
|
110
113
|
}),
|
|
@@ -122,7 +125,7 @@ function M({ items: e, onOpen: n }) {
|
|
|
122
125
|
return /* @__PURE__ */ h("div", {
|
|
123
126
|
className: "flex flex-col gap-4",
|
|
124
127
|
"data-testid": "log-rows",
|
|
125
|
-
children:
|
|
128
|
+
children: a(e, r).map((e) => /* @__PURE__ */ g("section", {
|
|
126
129
|
"aria-label": e.label,
|
|
127
130
|
className: "flex flex-col gap-1",
|
|
128
131
|
children: [/* @__PURE__ */ h("h2", {
|
|
@@ -154,11 +157,11 @@ function P() {
|
|
|
154
157
|
});
|
|
155
158
|
}
|
|
156
159
|
function F() {
|
|
157
|
-
let r = t(),
|
|
160
|
+
let r = t(), a = n(), o = e(), [u, d] = l("any"), [f, p] = l(null), m = c(() => o.notifications.map((e) => ({
|
|
158
161
|
notification: e,
|
|
159
|
-
state:
|
|
162
|
+
state: s(e.deliveryStatus, r),
|
|
160
163
|
createdAt: e.createdAt
|
|
161
|
-
})), [o.notifications, r]), v =
|
|
164
|
+
})), [o.notifications, r]), v = c(() => {
|
|
162
165
|
let e = {
|
|
163
166
|
ok: 0,
|
|
164
167
|
bad: 0,
|
|
@@ -166,7 +169,7 @@ function F() {
|
|
|
166
169
|
};
|
|
167
170
|
for (let t of m) e[t.state.tone] += 1;
|
|
168
171
|
return e;
|
|
169
|
-
}, [m]), b =
|
|
172
|
+
}, [m]), b = u === "any" ? m : m.filter((e) => e.state.tone === u), x = m.length === 0, S = /* @__PURE__ */ h(M, {
|
|
170
173
|
items: b,
|
|
171
174
|
onOpen: p
|
|
172
175
|
});
|
|
@@ -174,25 +177,25 @@ function F() {
|
|
|
174
177
|
what: r("notifications.v3.log.title", "Delivery log"),
|
|
175
178
|
error: o.error,
|
|
176
179
|
onRetry: () => void o.refetch()
|
|
177
|
-
}) : o.isLoading && x ? S = /* @__PURE__ */ h(P, {}) : b.length === 0 && (S = /* @__PURE__ */ h(N, { filtered:
|
|
180
|
+
}) : o.isLoading && x ? S = /* @__PURE__ */ h(P, {}) : b.length === 0 && (S = /* @__PURE__ */ h(N, { filtered: u !== "any" })), /* @__PURE__ */ g(C, { children: [
|
|
178
181
|
/* @__PURE__ */ h(_, {
|
|
179
182
|
variant: "compact",
|
|
180
183
|
title: r("notifications.v3.log.title", "Delivery log"),
|
|
181
184
|
description: r("notifications.v3.log.purpose", "Every notification sent, and whether it arrived."),
|
|
182
185
|
back: {
|
|
183
186
|
label: r("notifications.v3.title", "Notifications"),
|
|
184
|
-
to:
|
|
187
|
+
to: a.inbox
|
|
185
188
|
}
|
|
186
189
|
}),
|
|
187
190
|
/* @__PURE__ */ g("div", {
|
|
188
191
|
className: "flex flex-col gap-3",
|
|
189
192
|
children: [/* @__PURE__ */ h(A, {
|
|
190
193
|
counts: v,
|
|
191
|
-
tone:
|
|
194
|
+
tone: u,
|
|
192
195
|
onTone: d
|
|
193
196
|
}), S]
|
|
194
197
|
}),
|
|
195
|
-
/* @__PURE__ */ h(
|
|
198
|
+
/* @__PURE__ */ h(i, {
|
|
196
199
|
id: f,
|
|
197
200
|
onClose: () => p(null)
|
|
198
201
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DeliveryLogPage.js","names":["TONE_ICON","CheckCircle2","XCircle","Clock","COUNT","TONE_TEXT","DeliveryLogPage","details","useFeatureFlagDetails","AdminPageV2","DeliveryLog","NotificationCenterPage","recipientOf","notification","tr","DeliveryCounts","useTr","StatusChip","counts","Segmented","tone","onTone","DeliveryLine","when","useWhenLabels","item","Icon","state","onOpen","channelWord","DeliveryDays","groupByDay","items","group","DeliveryEmpty","EmptyState","filtered","DeliveryLoading","Skeleton","index","paths","useNotificationPaths","admin","useNotificationAdmin","setTone","useState","openId","setOpenId","withState","useMemo","deliveryState","out","shown","empty","body","LoadError","WorkspacePage","PageHeader","NotificationDetailPanel"],"sources":["../../../src/v2/admin/DeliveryLogPage.tsx"],"sourcesContent":["/**\n * The delivery log (BOFF-16785, C2; the mockup's `ndelivery`), under fe-libs' `accountPagesV2`:\n * every notification sent, and whether it arrived. Counts first (delivered, didn't arrive, waiting),\n * then a line each, grouped by day: what was sent to whom, how, and what happened, with an icon and a\n * word. A line opens the notification's panel, read-only. Admins only (`AdminPageV2`), behind the\n * same flag as today (`notification.history`). Today's hook (`useNotificationAdmin`).\n */\nimport { useMemo, useState } from 'react';\nimport { CheckCircle2, Clock, XCircle } from 'lucide-react';\nimport { useFeatureFlagDetails } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport {\n EmptyState,\n LoadError,\n Segmented,\n Skeleton,\n StatusChip,\n WorkspacePage,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationAdmin } from '../../hooks/useNotificationAdmin';\nimport type { Notification } from '../../types';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { NotificationCenterPage } from '../../pages/NotificationCenterPage';\nimport { NotificationDetailPanel } from '../NotificationDetailPanel';\nimport { groupByDay } from '../model/days';\nimport { channelWord, deliveryState, type DeliveryTone } from './words';\n\ntype ToneFilter = 'any' | DeliveryTone;\n\nconst TONE_ICON = { ok: CheckCircle2, bad: XCircle, waiting: Clock } as const;\nconst COUNT = new Intl.NumberFormat();\nconst TONE_TEXT: Record<DeliveryTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n};\n\nexport function DeliveryLogPage() {\n const details = useFeatureFlagDetails('notification.history');\n // As today: only while `notification.history` is on; otherwise the inbox shows in its place.\n if (!(details ? Boolean(details.value) : false)) return <NotificationCenterPage />;\n return (\n <AdminPageV2 tool=\"deliveryLog\" back={false}>\n <DeliveryLog />\n </AdminPageV2>\n );\n}\n\nfunction recipientOf(\n notification: Notification,\n tr: (key: string, fallback: string) => string\n): string {\n return (\n notification.recipientEmail ||\n notification.recipientPhone ||\n tr('notifications.v3.log.inApp', 'someone in the app')\n );\n}\n\ntype LogItem = {\n notification: Notification;\n state: ReturnType<typeof deliveryState>;\n createdAt: string;\n};\n\nfunction DeliveryCounts({\n counts,\n tone,\n onTone,\n}: {\n counts: Record<DeliveryTone, number>;\n tone: ToneFilter;\n onTone: (tone: ToneFilter) => void;\n}) {\n const tr = useTr();\n return (\n <div className=\"flex flex-wrap items-center gap-2\" data-testid=\"log-counts\">\n <StatusChip status=\"ok\">\n {tr('notifications.v3.log.delivered', '{{count}} delivered', {\n count: COUNT.format(counts.ok),\n })}\n </StatusChip>\n <StatusChip status=\"bad\">\n {tr('notifications.v3.log.failed', '{{count}} didn’t arrive', {\n count: COUNT.format(counts.bad),\n })}\n </StatusChip>\n <StatusChip status=\"waiting\">\n {tr('notifications.v3.log.waiting', '{{count}} waiting', {\n count: COUNT.format(counts.waiting),\n })}\n </StatusChip>\n <span className=\"flex-1\" />\n <Segmented<ToneFilter>\n aria-label={tr('notifications.v3.log.show', 'Show')}\n value={tone}\n onValueChange={onTone}\n options={[\n { value: 'any', label: tr('notifications.v3.log.any', 'All') },\n { value: 'ok', label: tr('notifications.v3.delivery.delivered', 'Delivered') },\n { value: 'bad', label: tr('notifications.v3.delivery.failed', 'Didn’t arrive') },\n { value: 'waiting', label: tr('notifications.v3.log.waitingShort', 'Waiting') },\n ]}\n />\n </div>\n );\n}\n\nfunction DeliveryLine({ item, onOpen }: { item: LogItem; onOpen: (id: string) => void }) {\n const tr = useTr();\n const when = useWhenLabels();\n const { notification, state } = item;\n const Icon = TONE_ICON[state.tone];\n return (\n <li data-row-id={notification.id}>\n <button\n type=\"button\"\n className=\"flex w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-3 py-2.5 text-left\"\n onClick={() => onOpen(notification.id)}\n >\n <Icon className={`size-4 shrink-0 ${TONE_TEXT[state.tone]}`} aria-hidden=\"true\" />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-sm text-text-primary\">\n {tr('notifications.v3.log.line', '{{title}} → {{who}}', {\n title: notification.title,\n who: recipientOf(notification, tr),\n })}\n </span>\n <span className=\"block truncate text-xs text-text-secondary\">\n {channelWord(notification.channel, tr)} · {state.word}\n </span>\n </span>\n <time className=\"shrink-0 text-xs text-text-muted\" dateTime={notification.createdAt}>\n {when.moment(notification.createdAt)}\n </time>\n </button>\n </li>\n );\n}\n\nfunction DeliveryDays({ items, onOpen }: { items: LogItem[]; onOpen: (id: string) => void }) {\n const tr = useTr();\n return (\n <div className=\"flex flex-col gap-4\" data-testid=\"log-rows\">\n {groupByDay(items, tr).map((group) => (\n <section key={group.key} aria-label={group.label} className=\"flex flex-col gap-1\">\n <h2 className=\"m-0 px-1 text-xs font-medium text-text-muted\">{group.label}</h2>\n <ul className=\"m-0 flex list-none flex-col divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle bg-bg-surface p-0\">\n {group.items.map((item) => (\n <DeliveryLine key={item.notification.id} item={item} onOpen={onOpen} />\n ))}\n </ul>\n </section>\n ))}\n </div>\n );\n}\n\nfunction DeliveryEmpty({ filtered }: { filtered: boolean }) {\n const tr = useTr();\n return (\n <EmptyState\n kind={filtered ? 'filtered' : 'first-use'}\n title={\n filtered\n ? tr('notifications.v3.log.noneTitle', 'Nothing here')\n : tr('notifications.v3.log.emptyTitle', 'Nothing sent yet')\n }\n description={tr(\n 'notifications.v3.log.emptyBody',\n 'Each notification sent is listed here with what happened to it.'\n )}\n />\n );\n}\n\nfunction DeliveryLoading() {\n return (\n <div className=\"flex flex-col gap-2\" aria-busy=\"true\">\n {Array.from({ length: 6 }, (_, index) => (\n <Skeleton key={index} className=\"h-12 w-full rounded-lg\" />\n ))}\n </div>\n );\n}\n\nfunction DeliveryLog() {\n const tr = useTr();\n const paths = useNotificationPaths();\n const admin = useNotificationAdmin();\n const [tone, setTone] = useState<ToneFilter>('any');\n const [openId, setOpenId] = useState<string | null>(null);\n const withState = useMemo<LogItem[]>(\n () =>\n admin.notifications.map((notification) => ({\n notification,\n state: deliveryState(notification.deliveryStatus, tr),\n createdAt: notification.createdAt,\n })),\n [admin.notifications, tr]\n );\n const counts = useMemo(() => {\n const out = { ok: 0, bad: 0, waiting: 0 };\n for (const item of withState) out[item.state.tone] += 1;\n return out;\n }, [withState]);\n const shown = tone === 'any' ? withState : withState.filter((item) => item.state.tone === tone);\n const empty = withState.length === 0;\n\n let body = <DeliveryDays items={shown} onOpen={setOpenId} />;\n if (admin.error && empty) {\n body = (\n <LoadError\n what={tr('notifications.v3.log.title', 'Delivery log')}\n error={admin.error}\n onRetry={() => void admin.refetch()}\n />\n );\n } else if (admin.isLoading && empty) {\n body = <DeliveryLoading />;\n } else if (shown.length === 0) {\n body = <DeliveryEmpty filtered={tone !== 'any'} />;\n }\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.log.title', 'Delivery log')}\n description={tr(\n 'notifications.v3.log.purpose',\n 'Every notification sent, and whether it arrived.'\n )}\n back={{ label: tr('notifications.v3.title', 'Notifications'), to: paths.inbox }}\n />\n <div className=\"flex flex-col gap-3\">\n <DeliveryCounts counts={counts} tone={tone} onTone={setTone} />\n {body}\n </div>\n <NotificationDetailPanel id={openId} onClose={() => setOpenId(null)} />\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgCA,IAAMA,IAAY;CAAE,IAAIC;CAAc,KAAKC;CAAS,SAASC;AAAM,GAC7DC,IAAQ,IAAI,KAAK,aAAa,GAC9BC,IAA0C;CAC9C,IAAI;CACJ,KAAK;CACL,SAAS;AACX;AAEA,SAAgBC,IAAkB;CAChC,IAAMC,IAAUC,EAAsB,sBAAsB;CAG5D,OADMD,KAAkBA,EAAQ,QAE9B,kBAACE,GAAD;EAAa,MAAK;EAAc,MAAM;EACpC,UAAA,kBAACC,GAAD,CAAc,CAAA;CACH,CAAA,IAJyC,kBAACC,GAAD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AO,kBAAClB,GAAD,EAAe,UAAUd,MAAS,MAAQ,CAAA,IAIjD,kBAACoC,GAAD,EAAA,UAAA;EACE,kBAACC,GAAD;GACE,SAAQ;GACR,OAAO3C,EAAG,8BAA8B,cAAc;GACtD,aAAaA,EACX,gCACA,kDACF;GACA,MAAM;IAAE,OAAOA,EAAG,0BAA0B,eAAe;IAAG,IAAI0B,EAAM;GAAM;EAC/E,CAAA;EACD,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACzB,GAAD;IAAwB;IAAc;IAAM,QAAQ6B;GAAU,CAAA,GAC7DU,CACE;;EACL,kBAACI,GAAD;GAAyB,IAAIZ;GAAQ,eAAeC,EAAU,IAAI;EAAI,CAAA;CACzD,EAAA,CAAA;AAEnB"}
|
|
1
|
+
{"version":3,"file":"DeliveryLogPage.js","names":["TONE_ICON","CheckCircle2","XCircle","Clock","COUNT","TONE_TEXT","DeliveryLogPage","details","useFeatureFlagDetails","paths","useNotificationPaths","on","AdminPageV2","DeliveryLog","Navigate","recipientOf","notification","tr","DeliveryCounts","useTr","StatusChip","counts","Segmented","tone","onTone","DeliveryLine","when","useWhenLabels","item","Icon","state","onOpen","channelWord","DeliveryDays","groupByDay","items","group","DeliveryEmpty","EmptyState","filtered","DeliveryLoading","Skeleton","index","admin","useNotificationAdmin","setTone","useState","openId","setOpenId","withState","useMemo","deliveryState","out","shown","empty","body","LoadError","WorkspacePage","PageHeader","NotificationDetailPanel"],"sources":["../../../src/v2/admin/DeliveryLogPage.tsx"],"sourcesContent":["/**\n * The delivery log (BOFF-16785, C2; the mockup's `ndelivery`), under fe-libs' `accountPagesV2`:\n * every notification sent, and whether it arrived. Counts first (delivered, didn't arrive, waiting),\n * then a line each, grouped by day: what was sent to whom, how, and what happened, with an icon and a\n * word. A line opens the notification's panel, read-only. Admins only (`AdminPageV2`), behind the\n * same flag as today (`notification.history`). Today's hook (`useNotificationAdmin`).\n */\nimport { useMemo, useState } from 'react';\nimport { Navigate } from 'react-router';\nimport { CheckCircle2, Clock, XCircle } from 'lucide-react';\nimport { useFeatureFlagDetails } from '@burdenoff/fe-libs/shared/feature-flags';\nimport { PageHeader } from '@burdenoff/fe-libs/chrome';\nimport {\n EmptyState,\n LoadError,\n Segmented,\n Skeleton,\n StatusChip,\n WorkspacePage,\n useWhenLabels,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationAdmin } from '../../hooks/useNotificationAdmin';\nimport type { Notification } from '../../types';\nimport { useTr } from '../../shared/hooks/useTr';\nimport { useNotificationPaths } from '../../navigation-v2/paths';\nimport { AdminPageV2 } from '../../navigation-v2/AdminPageV2';\nimport { NotificationDetailPanel } from '../NotificationDetailPanel';\nimport { groupByDay } from '../model/days';\nimport { channelWord, deliveryState, type DeliveryTone } from './words';\n\ntype ToneFilter = 'any' | DeliveryTone;\n\nconst TONE_ICON = { ok: CheckCircle2, bad: XCircle, waiting: Clock } as const;\nconst COUNT = new Intl.NumberFormat();\nconst TONE_TEXT: Record<DeliveryTone, string> = {\n ok: 'text-status-success-text',\n bad: 'text-status-error-text',\n waiting: 'text-status-warning-text',\n};\n\nexport function DeliveryLogPage() {\n const details = useFeatureFlagDetails('notification.history');\n const paths = useNotificationPaths();\n const on = details ? Boolean(details.value) : false;\n // Someone without the permission sees the lock, whatever the flag says (alpha check BOFF-17355:\n // a member got today's inbox here). An admin while `notification.history` is off goes to the\n // inbox, as today, but the redesigned one, never today's page.\n return (\n <AdminPageV2 tool=\"deliveryLog\" back={false}>\n {on ? <DeliveryLog /> : <Navigate to={paths.inbox} replace />}\n </AdminPageV2>\n );\n}\n\nfunction recipientOf(\n notification: Notification,\n tr: (key: string, fallback: string) => string\n): string {\n return (\n notification.recipientEmail ||\n notification.recipientPhone ||\n tr('notifications.v3.log.inApp', 'someone in the app')\n );\n}\n\ntype LogItem = {\n notification: Notification;\n state: ReturnType<typeof deliveryState>;\n createdAt: string;\n};\n\nfunction DeliveryCounts({\n counts,\n tone,\n onTone,\n}: {\n counts: Record<DeliveryTone, number>;\n tone: ToneFilter;\n onTone: (tone: ToneFilter) => void;\n}) {\n const tr = useTr();\n return (\n <div className=\"flex flex-wrap items-center gap-2\" data-testid=\"log-counts\">\n <StatusChip status=\"ok\">\n {tr('notifications.v3.log.delivered', '{{count}} delivered', {\n count: COUNT.format(counts.ok),\n })}\n </StatusChip>\n <StatusChip status=\"bad\">\n {tr('notifications.v3.log.failed', '{{count}} didn’t arrive', {\n count: COUNT.format(counts.bad),\n })}\n </StatusChip>\n <StatusChip status=\"waiting\">\n {tr('notifications.v3.log.waiting', '{{count}} waiting', {\n count: COUNT.format(counts.waiting),\n })}\n </StatusChip>\n <span className=\"flex-1\" />\n <Segmented<ToneFilter>\n aria-label={tr('notifications.v3.log.show', 'Show')}\n value={tone}\n onValueChange={onTone}\n options={[\n { value: 'any', label: tr('notifications.v3.log.any', 'All') },\n { value: 'ok', label: tr('notifications.v3.delivery.delivered', 'Delivered') },\n { value: 'bad', label: tr('notifications.v3.delivery.failed', 'Didn’t arrive') },\n { value: 'waiting', label: tr('notifications.v3.log.waitingShort', 'Waiting') },\n ]}\n />\n </div>\n );\n}\n\nfunction DeliveryLine({ item, onOpen }: { item: LogItem; onOpen: (id: string) => void }) {\n const tr = useTr();\n const when = useWhenLabels();\n const { notification, state } = item;\n const Icon = TONE_ICON[state.tone];\n return (\n <li data-row-id={notification.id}>\n <button\n type=\"button\"\n className=\"flex w-full cursor-pointer items-center gap-3 border-0 bg-transparent px-3 py-2.5 text-left\"\n onClick={() => onOpen(notification.id)}\n >\n <Icon className={`size-4 shrink-0 ${TONE_TEXT[state.tone]}`} aria-hidden=\"true\" />\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-sm text-text-primary\">\n {tr('notifications.v3.log.line', '{{title}} → {{who}}', {\n title: notification.title,\n who: recipientOf(notification, tr),\n })}\n </span>\n <span className=\"block truncate text-xs text-text-secondary\">\n {channelWord(notification.channel, tr)} · {state.word}\n </span>\n </span>\n <time className=\"shrink-0 text-xs text-text-muted\" dateTime={notification.createdAt}>\n {when.moment(notification.createdAt)}\n </time>\n </button>\n </li>\n );\n}\n\nfunction DeliveryDays({ items, onOpen }: { items: LogItem[]; onOpen: (id: string) => void }) {\n const tr = useTr();\n return (\n <div className=\"flex flex-col gap-4\" data-testid=\"log-rows\">\n {groupByDay(items, tr).map((group) => (\n <section key={group.key} aria-label={group.label} className=\"flex flex-col gap-1\">\n <h2 className=\"m-0 px-1 text-xs font-medium text-text-muted\">{group.label}</h2>\n <ul className=\"m-0 flex list-none flex-col divide-y divide-border-subtle overflow-hidden rounded-lg border border-border-subtle bg-bg-surface p-0\">\n {group.items.map((item) => (\n <DeliveryLine key={item.notification.id} item={item} onOpen={onOpen} />\n ))}\n </ul>\n </section>\n ))}\n </div>\n );\n}\n\nfunction DeliveryEmpty({ filtered }: { filtered: boolean }) {\n const tr = useTr();\n return (\n <EmptyState\n kind={filtered ? 'filtered' : 'first-use'}\n title={\n filtered\n ? tr('notifications.v3.log.noneTitle', 'Nothing here')\n : tr('notifications.v3.log.emptyTitle', 'Nothing sent yet')\n }\n description={tr(\n 'notifications.v3.log.emptyBody',\n 'Each notification sent is listed here with what happened to it.'\n )}\n />\n );\n}\n\nfunction DeliveryLoading() {\n return (\n <div className=\"flex flex-col gap-2\" aria-busy=\"true\">\n {Array.from({ length: 6 }, (_, index) => (\n <Skeleton key={index} className=\"h-12 w-full rounded-lg\" />\n ))}\n </div>\n );\n}\n\nfunction DeliveryLog() {\n const tr = useTr();\n const paths = useNotificationPaths();\n const admin = useNotificationAdmin();\n const [tone, setTone] = useState<ToneFilter>('any');\n const [openId, setOpenId] = useState<string | null>(null);\n const withState = useMemo<LogItem[]>(\n () =>\n admin.notifications.map((notification) => ({\n notification,\n state: deliveryState(notification.deliveryStatus, tr),\n createdAt: notification.createdAt,\n })),\n [admin.notifications, tr]\n );\n const counts = useMemo(() => {\n const out = { ok: 0, bad: 0, waiting: 0 };\n for (const item of withState) out[item.state.tone] += 1;\n return out;\n }, [withState]);\n const shown = tone === 'any' ? withState : withState.filter((item) => item.state.tone === tone);\n const empty = withState.length === 0;\n\n let body = <DeliveryDays items={shown} onOpen={setOpenId} />;\n if (admin.error && empty) {\n body = (\n <LoadError\n what={tr('notifications.v3.log.title', 'Delivery log')}\n error={admin.error}\n onRetry={() => void admin.refetch()}\n />\n );\n } else if (admin.isLoading && empty) {\n body = <DeliveryLoading />;\n } else if (shown.length === 0) {\n body = <DeliveryEmpty filtered={tone !== 'any'} />;\n }\n\n return (\n <WorkspacePage>\n <PageHeader\n variant=\"compact\"\n title={tr('notifications.v3.log.title', 'Delivery log')}\n description={tr(\n 'notifications.v3.log.purpose',\n 'Every notification sent, and whether it arrived.'\n )}\n back={{ label: tr('notifications.v3.title', 'Notifications'), to: paths.inbox }}\n />\n <div className=\"flex flex-col gap-3\">\n <DeliveryCounts counts={counts} tone={tone} onTone={setTone} />\n {body}\n </div>\n <NotificationDetailPanel id={openId} onClose={() => setOpenId(null)} />\n </WorkspacePage>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AAgCA,IAAMA,IAAY;CAAE,IAAIC;CAAc,KAAKC;CAAS,SAASC;AAAM,GAC7DC,IAAQ,IAAI,KAAK,aAAa,GAC9BC,IAA0C;CAC9C,IAAI;CACJ,KAAK;CACL,SAAS;AACX;AAEA,SAAgBC,IAAkB;CAChC,IAAMC,IAAUC,EAAsB,sBAAsB,GACtDC,IAAQC,EAAqB,GAC7BC,IAAKJ,IAAU,EAAQA,EAAQ,QAAS;CAI9C,OACE,kBAACK,GAAD;EAAa,MAAK;EAAc,MAAM;EACnC,UAAAD,IAAK,kBAACE,GAAD,CAAc,CAAA,IAAI,kBAACC,GAAD;GAAU,IAAIL,EAAM;GAAO,SAAA;EAAS,CAAA;CACjD,CAAA;AAEjB;AAEA,SAASM,EACP,GACA,GACQ;CACR,OACEC,EAAa,kBACbA,EAAa,kBACbC,EAAG,8BAA8B,oBAAoB;AAEzD;AAQA,SAASC,EAAe,EACtB,WACA,SAC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Ac;GACtD,aAAaA,EACX,gCACA,kDACF;GACA,MAAM;IAAE,OAAOA,EAAG,0BAA0B,eAAe;IAAG,IAAIR,EAAM;GAAM;EAC/E,CAAA;EACD,kBAAC,OAAD;GAAK,WAAU;GAAf,UAAA,CACE,kBAACS,GAAD;IAAwB;IAAc;IAAM,QAAQ2B;GAAU,CAAA,GAC7DU,CACE;;EACL,kBAACI,GAAD;GAAyB,IAAIZ;GAAQ,eAAeC,EAAU,IAAI;EAAI,CAAA;CACzD,EAAA,CAAA;AAEnB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@burdenoff/microfe-notification",
|
|
3
|
-
"version": "2026.
|
|
3
|
+
"version": "2026.1201.1",
|
|
4
4
|
"description": "Notification microfrontend for multi-channel notification management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"imports": {
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
],
|
|
96
96
|
"repository": {
|
|
97
97
|
"type": "git",
|
|
98
|
-
"url": "git+https://github.com/
|
|
98
|
+
"url": "git+https://github.com/Algoshred/microfe-notification.git"
|
|
99
99
|
},
|
|
100
100
|
"author": "Burdenoff",
|
|
101
101
|
"license": "MIT",
|