@burdenoff/microfe-notification 2026.424.101
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/README.md +376 -0
- package/dist/AdminNotificationRoot.d.ts +35 -0
- package/dist/AdminNotificationRoot.d.ts.map +1 -0
- package/dist/AdminNotificationRoot.js +81 -0
- package/dist/AdminNotificationRoot.js.map +1 -0
- package/dist/AdminNotificationRoutes.d.ts +2 -0
- package/dist/AdminNotificationRoutes.d.ts.map +1 -0
- package/dist/AdminNotificationRoutes.js +108 -0
- package/dist/AdminNotificationRoutes.js.map +1 -0
- package/dist/NotificationRoot.d.ts +31 -0
- package/dist/NotificationRoot.d.ts.map +1 -0
- package/dist/NotificationRoot.js +81 -0
- package/dist/NotificationRoot.js.map +1 -0
- package/dist/NotificationRoutes.d.ts +17 -0
- package/dist/NotificationRoutes.d.ts.map +1 -0
- package/dist/NotificationRoutes.js +67 -0
- package/dist/NotificationRoutes.js.map +1 -0
- package/dist/UserNotificationRoot.d.ts +34 -0
- package/dist/UserNotificationRoot.d.ts.map +1 -0
- package/dist/UserNotificationRoot.js +64 -0
- package/dist/UserNotificationRoot.js.map +1 -0
- package/dist/UserNotificationRoutes.d.ts +15 -0
- package/dist/UserNotificationRoutes.d.ts.map +1 -0
- package/dist/UserNotificationRoutes.js +52 -0
- package/dist/UserNotificationRoutes.js.map +1 -0
- package/dist/__tests__/setup.d.ts +2 -0
- package/dist/__tests__/setup.d.ts.map +1 -0
- package/dist/components/NotificationBell.d.ts +14 -0
- package/dist/components/NotificationBell.d.ts.map +1 -0
- package/dist/components/NotificationBell.js +47 -0
- package/dist/components/NotificationBell.js.map +1 -0
- package/dist/components/NotificationCard.d.ts +19 -0
- package/dist/components/NotificationCard.d.ts.map +1 -0
- package/dist/components/NotificationCard.js +112 -0
- package/dist/components/NotificationCard.js.map +1 -0
- package/dist/components/NotificationPanel.d.ts +11 -0
- package/dist/components/NotificationPanel.d.ts.map +1 -0
- package/dist/components/NotificationPanel.js +100 -0
- package/dist/components/NotificationPanel.js.map +1 -0
- package/dist/components/RecipientSelector.d.ts +34 -0
- package/dist/components/RecipientSelector.d.ts.map +1 -0
- package/dist/components/RecipientSelector.js +212 -0
- package/dist/components/RecipientSelector.js.map +1 -0
- package/dist/components/TemplatePreview.d.ts +22 -0
- package/dist/components/TemplatePreview.d.ts.map +1 -0
- package/dist/components/TemplatePreview.js +425 -0
- package/dist/components/TemplatePreview.js.map +1 -0
- package/dist/components/VariableInserter.d.ts +12 -0
- package/dist/components/VariableInserter.d.ts.map +1 -0
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +3 -0
- package/dist/constants/permissions.d.ts +24 -0
- package/dist/constants/permissions.d.ts.map +1 -0
- package/dist/constants/permissions.js +17 -0
- package/dist/constants/permissions.js.map +1 -0
- package/dist/dev/main.d.ts +2 -0
- package/dist/dev/main.d.ts.map +1 -0
- package/dist/generated/global-operations.d.ts +1408 -0
- package/dist/generated/global-operations.d.ts.map +1 -0
- package/dist/generated/global-operations.js +514 -0
- package/dist/generated/global-operations.js.map +1 -0
- package/dist/generated/global-types.d.ts +20773 -0
- package/dist/generated/global-types.d.ts.map +1 -0
- package/dist/generated/wspace-operations.d.ts +2 -0
- package/dist/generated/wspace-operations.d.ts.map +1 -0
- package/dist/generated/wspace-types.d.ts +53363 -0
- package/dist/generated/wspace-types.d.ts.map +1 -0
- package/dist/graphql/global-client.d.ts +19 -0
- package/dist/graphql/global-client.d.ts.map +1 -0
- package/dist/graphql/global-client.js +57 -0
- package/dist/graphql/global-client.js.map +1 -0
- package/dist/hooks/index.d.ts +6 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +5 -0
- package/dist/hooks/useNotificationAdmin.d.ts +51 -0
- package/dist/hooks/useNotificationAdmin.d.ts.map +1 -0
- package/dist/hooks/useNotificationAdmin.js +203 -0
- package/dist/hooks/useNotificationAdmin.js.map +1 -0
- package/dist/hooks/useNotificationTemplates.d.ts +136 -0
- package/dist/hooks/useNotificationTemplates.d.ts.map +1 -0
- package/dist/hooks/useNotificationTemplates.js +168 -0
- package/dist/hooks/useNotificationTemplates.js.map +1 -0
- package/dist/hooks/useNotificationTopics.d.ts +36 -0
- package/dist/hooks/useNotificationTopics.d.ts.map +1 -0
- package/dist/hooks/useNotificationTopics.js +127 -0
- package/dist/hooks/useNotificationTopics.js.map +1 -0
- package/dist/hooks/useNotifications.d.ts +36 -0
- package/dist/hooks/useNotifications.d.ts.map +1 -0
- package/dist/hooks/useNotifications.js +289 -0
- package/dist/hooks/useNotifications.js.map +1 -0
- package/dist/hooks/useSendNotification.d.ts +159 -0
- package/dist/hooks/useSendNotification.d.ts.map +1 -0
- package/dist/hooks/useSendNotification.js +123 -0
- package/dist/hooks/useSendNotification.js.map +1 -0
- package/dist/hooks/useUserSearch.d.ts +27 -0
- package/dist/hooks/useUserSearch.d.ts.map +1 -0
- package/dist/hooks/useUserSearch.js +76 -0
- package/dist/hooks/useUserSearch.js.map +1 -0
- package/dist/index.d.ts +37 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +13 -0
- package/dist/pages/CreateNotificationPage.d.ts +6 -0
- package/dist/pages/CreateNotificationPage.d.ts.map +1 -0
- package/dist/pages/CreateNotificationPage.js +1366 -0
- package/dist/pages/CreateNotificationPage.js.map +1 -0
- package/dist/pages/NotificationCenterPage.d.ts +7 -0
- package/dist/pages/NotificationCenterPage.d.ts.map +1 -0
- package/dist/pages/NotificationCenterPage.js +203 -0
- package/dist/pages/NotificationCenterPage.js.map +1 -0
- package/dist/pages/NotificationHistoryAdminPage.d.ts +3 -0
- package/dist/pages/NotificationHistoryAdminPage.d.ts.map +1 -0
- package/dist/pages/NotificationHistoryAdminPage.js +484 -0
- package/dist/pages/NotificationHistoryAdminPage.js.map +1 -0
- package/dist/pages/NotificationHistoryPage.d.ts +3 -0
- package/dist/pages/NotificationHistoryPage.d.ts.map +1 -0
- package/dist/pages/NotificationHistoryPage.js +136 -0
- package/dist/pages/NotificationHistoryPage.js.map +1 -0
- package/dist/pages/NotificationLandingPage.d.ts +11 -0
- package/dist/pages/NotificationLandingPage.d.ts.map +1 -0
- package/dist/pages/NotificationLandingPage.js +85 -0
- package/dist/pages/NotificationLandingPage.js.map +1 -0
- package/dist/pages/NotificationPreferencesPage.d.ts +2 -0
- package/dist/pages/NotificationPreferencesPage.d.ts.map +1 -0
- package/dist/pages/NotificationPreferencesPage.js +108 -0
- package/dist/pages/NotificationPreferencesPage.js.map +1 -0
- package/dist/pages/NotificationTemplatesPage.d.ts +8 -0
- package/dist/pages/NotificationTemplatesPage.d.ts.map +1 -0
- package/dist/pages/NotificationTemplatesPage.js +310 -0
- package/dist/pages/NotificationTemplatesPage.js.map +1 -0
- package/dist/pages/NotificationTopicsPage.d.ts +2 -0
- package/dist/pages/NotificationTopicsPage.d.ts.map +1 -0
- package/dist/pages/NotificationTopicsPage.js +254 -0
- package/dist/pages/NotificationTopicsPage.js.map +1 -0
- package/dist/pages/TemplateEditorPage.d.ts +13 -0
- package/dist/pages/TemplateEditorPage.d.ts.map +1 -0
- package/dist/pages/TemplateEditorPage.js +790 -0
- package/dist/pages/TemplateEditorPage.js.map +1 -0
- package/dist/providers/NotificationProvider.d.ts +19 -0
- package/dist/providers/NotificationProvider.d.ts.map +1 -0
- package/dist/providers/NotificationProvider.js +35 -0
- package/dist/providers/NotificationProvider.js.map +1 -0
- package/dist/shared/hooks/useTr.d.ts +14 -0
- package/dist/shared/hooks/useTr.d.ts.map +1 -0
- package/dist/shared/hooks/useTr.js +14 -0
- package/dist/shared/hooks/useTr.js.map +1 -0
- package/dist/store/notificationStore.d.ts +32 -0
- package/dist/store/notificationStore.d.ts.map +1 -0
- package/dist/store/notificationStore.js +124 -0
- package/dist/store/notificationStore.js.map +1 -0
- package/dist/types/index.d.ts +215 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/utils/index.d.ts +68 -0
- package/dist/utils/index.d.ts.map +1 -0
- package/dist/utils/index.js +122 -0
- package/dist/utils/index.js.map +1 -0
- package/dist/utils/notificationHistoryExport.d.ts +13 -0
- package/dist/utils/notificationHistoryExport.d.ts.map +1 -0
- package/dist/utils/notificationHistoryExport.js +29 -0
- package/dist/utils/notificationHistoryExport.js.map +1 -0
- package/package.json +115 -0
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { useNotification as e } from "../providers/NotificationProvider.js";
|
|
2
|
+
import { useNotifications as t } from "../hooks/useNotifications.js";
|
|
3
|
+
import { useNotificationTopics as n } from "../hooks/useNotificationTopics.js";
|
|
4
|
+
import "../hooks/index.js";
|
|
5
|
+
import { useTr as r } from "../shared/hooks/useTr.js";
|
|
6
|
+
import { NotificationCard as i } from "../components/NotificationCard.js";
|
|
7
|
+
import { NOTIFICATION_PERMISSIONS as a } from "../constants/permissions.js";
|
|
8
|
+
import { exportNotificationsAsCsv as o } from "../utils/notificationHistoryExport.js";
|
|
9
|
+
import { useEffect as s } from "react";
|
|
10
|
+
import { Archive as c, Download as l, Search as u } from "lucide-react";
|
|
11
|
+
import { usePermissions as d } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
12
|
+
import { jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
13
|
+
//#region src/pages/NotificationHistoryPage.tsx
|
|
14
|
+
function m() {
|
|
15
|
+
let m = r(), { hasPermission: h, isLoading: g } = d(), { currentUser: _ } = e(), { topics: v } = n({ isActive: !0 }), { notifications: y, notificationFilter: b, updateFilter: x, archiveNotification: S, unarchiveNotification: C, recordAction: w } = t();
|
|
16
|
+
return s(() => {
|
|
17
|
+
x({
|
|
18
|
+
archived: null,
|
|
19
|
+
channel: "ALL"
|
|
20
|
+
});
|
|
21
|
+
}, [x]), g ? /* @__PURE__ */ f("div", {
|
|
22
|
+
className: "flex h-64 items-center justify-center",
|
|
23
|
+
children: /* @__PURE__ */ f("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
|
|
24
|
+
}) : !h(a.NOTIFICATION_LIST) && !_?.id ? /* @__PURE__ */ f("div", {
|
|
25
|
+
className: "p-8 text-center text-text-secondary",
|
|
26
|
+
children: m("notifications.noPermissionHistory", "You don't have permission to view notification history.")
|
|
27
|
+
}) : /* @__PURE__ */ p("div", {
|
|
28
|
+
className: "space-y-4 sm:space-y-6 p-3 sm:p-6 animate-in fade-in duration-300",
|
|
29
|
+
children: [
|
|
30
|
+
/* @__PURE__ */ p("div", {
|
|
31
|
+
className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
|
|
32
|
+
children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("h1", {
|
|
33
|
+
className: "text-xl sm:text-2xl font-bold text-primary",
|
|
34
|
+
children: m("notifications.historyTitle", "Notification History")
|
|
35
|
+
}), /* @__PURE__ */ f("p", {
|
|
36
|
+
className: "text-sm text-secondary mt-1",
|
|
37
|
+
children: m("notifications.historySubtitle", "View and search all your notifications")
|
|
38
|
+
})] }), /* @__PURE__ */ p("button", {
|
|
39
|
+
onClick: () => o(m, y),
|
|
40
|
+
disabled: y.length === 0,
|
|
41
|
+
className: "flex items-center gap-2 px-4 py-2 text-sm font-medium text-accent-primary hover:text-accent-primary/80 border border-accent-primary hover:border-accent-primary/80 rounded-lg transition-all duration-150 hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed",
|
|
42
|
+
children: [/* @__PURE__ */ f(l, { size: 16 }), m("notifications.export", "Export")]
|
|
43
|
+
})]
|
|
44
|
+
}),
|
|
45
|
+
/* @__PURE__ */ p("div", {
|
|
46
|
+
className: "grid gap-3 sm:grid-cols-2 xl:grid-cols-5",
|
|
47
|
+
children: [
|
|
48
|
+
/* @__PURE__ */ p("div", {
|
|
49
|
+
className: "relative sm:col-span-2 xl:col-span-2",
|
|
50
|
+
children: [/* @__PURE__ */ f(u, {
|
|
51
|
+
size: 16,
|
|
52
|
+
className: "absolute left-3 top-1/2 -translate-y-1/2 text-tertiary"
|
|
53
|
+
}), /* @__PURE__ */ f("input", {
|
|
54
|
+
type: "text",
|
|
55
|
+
placeholder: m("notifications.searchByTitleOrContent", "Search by title or content..."),
|
|
56
|
+
value: b.search,
|
|
57
|
+
onChange: (e) => x({ search: e.target.value }),
|
|
58
|
+
className: "w-full pl-9 pr-4 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150"
|
|
59
|
+
})]
|
|
60
|
+
}),
|
|
61
|
+
/* @__PURE__ */ p("select", {
|
|
62
|
+
value: b.topicId || "",
|
|
63
|
+
onChange: (e) => x({ topicId: e.target.value || void 0 }),
|
|
64
|
+
className: "rounded-lg border border-default bg-surface px-3 py-2 text-sm text-primary",
|
|
65
|
+
children: [/* @__PURE__ */ f("option", {
|
|
66
|
+
value: "",
|
|
67
|
+
children: m("notifications.allTopics", "All Topics")
|
|
68
|
+
}), v.map((e) => /* @__PURE__ */ f("option", {
|
|
69
|
+
value: e.id,
|
|
70
|
+
children: e.name
|
|
71
|
+
}, e.id))]
|
|
72
|
+
}),
|
|
73
|
+
/* @__PURE__ */ f("input", {
|
|
74
|
+
type: "date",
|
|
75
|
+
"aria-label": m("notifications.startDate", "Start date"),
|
|
76
|
+
value: b.dateRange.start ? b.dateRange.start.toISOString().split("T")[0] : "",
|
|
77
|
+
onChange: (e) => x({ dateRange: {
|
|
78
|
+
...b.dateRange,
|
|
79
|
+
start: e.target.value ? new Date(e.target.value) : null
|
|
80
|
+
} }),
|
|
81
|
+
className: "rounded-lg border border-default bg-surface px-3 py-2 text-sm text-primary"
|
|
82
|
+
}),
|
|
83
|
+
/* @__PURE__ */ f("input", {
|
|
84
|
+
type: "date",
|
|
85
|
+
"aria-label": m("notifications.endDate", "End date"),
|
|
86
|
+
value: b.dateRange.end ? b.dateRange.end.toISOString().split("T")[0] : "",
|
|
87
|
+
onChange: (e) => x({ dateRange: {
|
|
88
|
+
...b.dateRange,
|
|
89
|
+
end: e.target.value ? new Date(e.target.value) : null
|
|
90
|
+
} }),
|
|
91
|
+
className: "rounded-lg border border-default bg-surface px-3 py-2 text-sm text-primary"
|
|
92
|
+
})
|
|
93
|
+
]
|
|
94
|
+
}),
|
|
95
|
+
/* @__PURE__ */ f("div", {
|
|
96
|
+
className: "space-y-2",
|
|
97
|
+
children: y.length > 0 ? y.map((e) => /* @__PURE__ */ p("div", {
|
|
98
|
+
className: "space-y-2",
|
|
99
|
+
children: [/* @__PURE__ */ f(i, {
|
|
100
|
+
notification: e,
|
|
101
|
+
onArchive: S,
|
|
102
|
+
onAction: w,
|
|
103
|
+
showArchivedState: !0
|
|
104
|
+
}), e.archivedAt && /* @__PURE__ */ f("div", {
|
|
105
|
+
className: "flex justify-end",
|
|
106
|
+
children: /* @__PURE__ */ f("button", {
|
|
107
|
+
onClick: () => C(e.id),
|
|
108
|
+
className: "rounded-md border border-default px-3 py-2 text-xs text-secondary hover:bg-muted",
|
|
109
|
+
children: m("notifications.restore", "Restore")
|
|
110
|
+
})
|
|
111
|
+
})]
|
|
112
|
+
}, e.id)) : /* @__PURE__ */ p("div", {
|
|
113
|
+
className: "flex flex-col items-center justify-center py-12 text-center animate-in fade-in duration-300",
|
|
114
|
+
children: [
|
|
115
|
+
/* @__PURE__ */ f(c, {
|
|
116
|
+
size: 48,
|
|
117
|
+
className: "text-tertiary mb-4"
|
|
118
|
+
}),
|
|
119
|
+
/* @__PURE__ */ f("h3", {
|
|
120
|
+
className: "text-lg font-semibold text-primary mb-2",
|
|
121
|
+
children: m("notifications.noNotificationsFound", "No notifications found")
|
|
122
|
+
}),
|
|
123
|
+
/* @__PURE__ */ f("p", {
|
|
124
|
+
className: "text-sm text-secondary",
|
|
125
|
+
children: m("notifications.adjustSearchOrDateRange", "Try adjusting your filters")
|
|
126
|
+
})
|
|
127
|
+
]
|
|
128
|
+
})
|
|
129
|
+
})
|
|
130
|
+
]
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
//#endregion
|
|
134
|
+
export { m as NotificationHistoryPage };
|
|
135
|
+
|
|
136
|
+
//# sourceMappingURL=NotificationHistoryPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationHistoryPage.js","names":[],"sources":["../../src/pages/NotificationHistoryPage.tsx"],"sourcesContent":["import { useEffect } from 'react';\nimport { Archive, Download, Search } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { NotificationCard } from '../components/NotificationCard';\nimport { useNotifications, useNotificationTopics } from '../hooks';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { useTr } from '../shared/hooks/useTr';\nimport { exportNotificationsAsCsv } from '../utils/notificationHistoryExport';\n\n/** User Notification History — personal history, filter, CSV export, archive/unarchive. */\nexport function NotificationHistoryPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { currentUser } = useNotification();\n const { topics } = useNotificationTopics({ isActive: true });\n const {\n notifications,\n notificationFilter,\n updateFilter,\n archiveNotification,\n unarchiveNotification,\n recordAction,\n } = useNotifications();\n\n useEffect(() => {\n updateFilter({ archived: null, channel: 'ALL' });\n }, [updateFilter]);\n\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_LIST) && !currentUser?.id) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionHistory',\n \"You don't have permission to view notification history.\"\n )}\n </div>\n );\n }\n\n return (\n <div className=\"space-y-4 sm:space-y-6 p-3 sm:p-6 animate-in fade-in duration-300\">\n <div className=\"flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between\">\n <div>\n <h1 className=\"text-xl sm:text-2xl font-bold text-primary\">\n {tr('notifications.historyTitle', 'Notification History')}\n </h1>\n <p className=\"text-sm text-secondary mt-1\">\n {tr('notifications.historySubtitle', 'View and search all your notifications')}\n </p>\n </div>\n\n <button\n onClick={() => exportNotificationsAsCsv(tr, notifications)}\n disabled={notifications.length === 0}\n className=\"flex items-center gap-2 px-4 py-2 text-sm font-medium text-accent-primary hover:text-accent-primary/80 border border-accent-primary hover:border-accent-primary/80 rounded-lg transition-all duration-150 hover:shadow-sm disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n <Download size={16} />\n {tr('notifications.export', 'Export')}\n </button>\n </div>\n\n <div className=\"grid gap-3 sm:grid-cols-2 xl:grid-cols-5\">\n <div className=\"relative sm:col-span-2 xl:col-span-2\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n placeholder={tr(\n 'notifications.searchByTitleOrContent',\n 'Search by title or content...'\n )}\n value={notificationFilter.search}\n onChange={(e) => updateFilter({ search: e.target.value })}\n className=\"w-full pl-9 pr-4 py-2 text-sm text-primary bg-surface border border-default rounded-lg focus:outline-none focus:ring-2 focus:ring-accent transition-shadow duration-150\"\n />\n </div>\n\n <select\n value={notificationFilter.topicId || ''}\n onChange={(event) => updateFilter({ topicId: event.target.value || undefined })}\n className=\"rounded-lg border border-default bg-surface px-3 py-2 text-sm text-primary\"\n >\n <option value=\"\">{tr('notifications.allTopics', 'All Topics')}</option>\n {topics.map((topic) => (\n <option key={topic.id} value={topic.id}>\n {topic.name}\n </option>\n ))}\n </select>\n\n <input\n type=\"date\"\n aria-label={tr('notifications.startDate', 'Start date')}\n value={\n notificationFilter.dateRange.start\n ? notificationFilter.dateRange.start.toISOString().split('T')[0]\n : ''\n }\n onChange={(e) =>\n updateFilter({\n dateRange: {\n ...notificationFilter.dateRange,\n start: e.target.value ? new Date(e.target.value) : null,\n },\n })\n }\n className=\"rounded-lg border border-default bg-surface px-3 py-2 text-sm text-primary\"\n />\n\n <input\n type=\"date\"\n aria-label={tr('notifications.endDate', 'End date')}\n value={\n notificationFilter.dateRange.end\n ? notificationFilter.dateRange.end.toISOString().split('T')[0]\n : ''\n }\n onChange={(e) =>\n updateFilter({\n dateRange: {\n ...notificationFilter.dateRange,\n end: e.target.value ? new Date(e.target.value) : null,\n },\n })\n }\n className=\"rounded-lg border border-default bg-surface px-3 py-2 text-sm text-primary\"\n />\n </div>\n\n <div className=\"space-y-2\">\n {notifications.length > 0 ? (\n notifications.map((notification) => (\n <div key={notification.id} className=\"space-y-2\">\n <NotificationCard\n notification={notification}\n onArchive={archiveNotification}\n onAction={recordAction}\n showArchivedState\n />\n {notification.archivedAt && (\n <div className=\"flex justify-end\">\n <button\n onClick={() => unarchiveNotification(notification.id)}\n className=\"rounded-md border border-default px-3 py-2 text-xs text-secondary hover:bg-muted\"\n >\n {tr('notifications.restore', 'Restore')}\n </button>\n </div>\n )}\n </div>\n ))\n ) : (\n <div className=\"flex flex-col items-center justify-center py-12 text-center animate-in fade-in duration-300\">\n <Archive size={48} className=\"text-tertiary mb-4\" />\n <h3 className=\"text-lg font-semibold text-primary mb-2\">\n {tr('notifications.noNotificationsFound', 'No notifications found')}\n </h3>\n <p className=\"text-sm text-secondary\">\n {tr('notifications.adjustSearchOrDateRange', 'Try adjusting your filters')}\n </p>\n </div>\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;;AAWA,SAAgB,IAA0B;CACxC,IAAM,IAAK,GAAO,EACZ,EAAE,kBAAe,WAAW,MAAuB,GAAgB,EACnE,EAAE,mBAAgB,GAAiB,EACnC,EAAE,cAAW,EAAsB,EAAE,UAAU,IAAM,CAAC,EACtD,EACJ,kBACA,uBACA,iBACA,wBACA,0BACA,oBACE,GAAkB;AAyBtB,QAvBA,QAAgB;AACd,IAAa;GAAE,UAAU;GAAM,SAAS;GAAO,CAAC;IAC/C,CAAC,EAAa,CAAC,EAEd,IAEA,kBAAC,OAAD;EAAK,WAAU;YACb,kBAAC,OAAD,EAAK,WAAU,kFAAmF,CAAA;EAC9F,CAAA,GAIN,CAAC,EAAc,EAAy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.
|
|
3
|
+
*
|
|
4
|
+
* Admin-only tabs (Send, History, Templates, Topics) are gated by the
|
|
5
|
+
* notification.* feature flags. Gating is applied here because this
|
|
6
|
+
* page bypasses the route-level flag gates in AdminNotificationRoutes:
|
|
7
|
+
* without this check an admin landing on /notifications could click
|
|
8
|
+
* into any tab regardless of flag state.
|
|
9
|
+
*/
|
|
10
|
+
export declare function NotificationLandingPage(): import("react/jsx-runtime").JSX.Element;
|
|
11
|
+
//# sourceMappingURL=NotificationLandingPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationLandingPage.d.ts","sourceRoot":"","sources":["../../src/pages/NotificationLandingPage.tsx"],"names":[],"mappings":"AAuCA;;;;;;;;GAQG;AACH,wBAAgB,uBAAuB,4CA2GtC"}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { useTr as e } from "../shared/hooks/useTr.js";
|
|
2
|
+
import { NotificationCenterPage as t } from "./NotificationCenterPage.js";
|
|
3
|
+
import { Suspense as n, lazy as r, useEffect as i, useMemo as a } from "react";
|
|
4
|
+
import { useFeatureFlagDetails as o } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
5
|
+
import { useSearchParams as s } from "react-router-dom";
|
|
6
|
+
import { jsx as c, jsxs as l } from "react/jsx-runtime";
|
|
7
|
+
import { Tabs as u } from "@burdenoff/fe-libs/chrome";
|
|
8
|
+
//#region src/pages/NotificationLandingPage.tsx
|
|
9
|
+
var d = r(() => import("./NotificationHistoryAdminPage.js").then((e) => ({ default: e.NotificationHistoryAdminPage }))), f = r(() => import("./NotificationTemplatesPage.js").then((e) => ({ default: e.NotificationTemplatesPage }))), p = r(() => import("./CreateNotificationPage.js").then((e) => ({ default: e.CreateNotificationPage }))), m = r(() => import("./NotificationTopicsPage.js").then((e) => ({ default: e.NotificationTopicsPage })));
|
|
10
|
+
function h() {
|
|
11
|
+
return /* @__PURE__ */ c("div", {
|
|
12
|
+
className: "flex h-64 items-center justify-center",
|
|
13
|
+
children: /* @__PURE__ */ c("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
function g() {
|
|
17
|
+
let [r, g] = s(), _ = e(), v = o("notification.templates"), y = o("notification.create"), b = o("notification.history"), x = v ? !!v.value : !1, S = y ? !!y.value : !1, C = b ? !!b.value : !1, w = a(() => [
|
|
18
|
+
{
|
|
19
|
+
id: "inbox",
|
|
20
|
+
label: _("notification.landing.tabs.inbox", "Inbox")
|
|
21
|
+
},
|
|
22
|
+
...S ? [{
|
|
23
|
+
id: "send",
|
|
24
|
+
label: _("notification.landing.tabs.send", "Send")
|
|
25
|
+
}] : [],
|
|
26
|
+
...C ? [{
|
|
27
|
+
id: "history",
|
|
28
|
+
label: _("notification.landing.tabs.history", "History")
|
|
29
|
+
}] : [],
|
|
30
|
+
...x ? [{
|
|
31
|
+
id: "templates",
|
|
32
|
+
label: _("notification.landing.tabs.templates", "Templates")
|
|
33
|
+
}] : [],
|
|
34
|
+
...S ? [{
|
|
35
|
+
id: "topics",
|
|
36
|
+
label: _("notification.landing.tabs.topics", "Topics")
|
|
37
|
+
}] : []
|
|
38
|
+
], [
|
|
39
|
+
_,
|
|
40
|
+
x,
|
|
41
|
+
S,
|
|
42
|
+
C
|
|
43
|
+
]), T = r.get("tab"), E = T && w.some((e) => e.id === T) ? T : w[0].id;
|
|
44
|
+
return i(() => {
|
|
45
|
+
T && !w.some((e) => e.id === T) && g((e) => {
|
|
46
|
+
let t = new URLSearchParams(e);
|
|
47
|
+
return t.delete("tab"), t;
|
|
48
|
+
}, { replace: !0 });
|
|
49
|
+
}, [
|
|
50
|
+
T,
|
|
51
|
+
w,
|
|
52
|
+
g
|
|
53
|
+
]), /* @__PURE__ */ l("div", {
|
|
54
|
+
className: "flex flex-col h-full",
|
|
55
|
+
children: [/* @__PURE__ */ c("div", {
|
|
56
|
+
className: "border-b border-border-subtle px-4 pt-3",
|
|
57
|
+
children: /* @__PURE__ */ c(u, {
|
|
58
|
+
items: w,
|
|
59
|
+
activeTabId: E,
|
|
60
|
+
onTabChange: (e) => {
|
|
61
|
+
g((t) => {
|
|
62
|
+
let n = new URLSearchParams(t);
|
|
63
|
+
return e === w[0].id ? n.delete("tab") : n.set("tab", e), n;
|
|
64
|
+
}, { replace: !0 });
|
|
65
|
+
},
|
|
66
|
+
variant: "underline"
|
|
67
|
+
})
|
|
68
|
+
}), /* @__PURE__ */ l("div", {
|
|
69
|
+
className: "flex-1 min-h-0 overflow-auto",
|
|
70
|
+
children: [E === "inbox" && /* @__PURE__ */ c(t, {}), /* @__PURE__ */ l(n, {
|
|
71
|
+
fallback: /* @__PURE__ */ c(h, {}),
|
|
72
|
+
children: [
|
|
73
|
+
E === "send" && S && /* @__PURE__ */ c(p, {}),
|
|
74
|
+
E === "history" && C && /* @__PURE__ */ c(d, {}),
|
|
75
|
+
E === "templates" && x && /* @__PURE__ */ c(f, {}),
|
|
76
|
+
E === "topics" && S && /* @__PURE__ */ c(m, {})
|
|
77
|
+
]
|
|
78
|
+
})]
|
|
79
|
+
})]
|
|
80
|
+
});
|
|
81
|
+
}
|
|
82
|
+
//#endregion
|
|
83
|
+
export { g as NotificationLandingPage };
|
|
84
|
+
|
|
85
|
+
//# sourceMappingURL=NotificationLandingPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationLandingPage.js","names":[],"sources":["../../src/pages/NotificationLandingPage.tsx"],"sourcesContent":["import { Suspense, lazy, useEffect, useMemo } from 'react';\nimport { useSearchParams } from 'react-router-dom';\nimport { Tabs, type TabItem } from '@burdenoff/fe-libs/chrome';\nimport { useFeatureFlagDetails } from '@burdenoff/fe-libs/shared/feature-flags';\n\nimport { NotificationCenterPage } from './NotificationCenterPage';\nimport { useTr } from '../shared/hooks/useTr';\n\n// Lazy-load admin tab bodies — each tab pulls its bundle only when activated,\n// matching the code-splitting done in AdminNotificationRoutes.\nconst NotificationHistoryAdminPage = lazy(() =>\n import('./NotificationHistoryAdminPage').then((m) => ({\n default: m.NotificationHistoryAdminPage,\n }))\n);\nconst NotificationTemplatesPage = lazy(() =>\n import('./NotificationTemplatesPage').then((m) => ({\n default: m.NotificationTemplatesPage,\n }))\n);\nconst CreateNotificationPage = lazy(() =>\n import('./CreateNotificationPage').then((m) => ({\n default: m.CreateNotificationPage,\n }))\n);\nconst NotificationTopicsPage = lazy(() =>\n import('./NotificationTopicsPage').then((m) => ({\n default: m.NotificationTopicsPage,\n }))\n);\n\nfunction TabBodyLoader() {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n}\n\n/**\n * Tabbed landing page for the Notification microfrontend.\n *\n * Admin-only tabs (Send, History, Templates, Topics) are gated by the\n * notification.* feature flags. Gating is applied here because this\n * page bypasses the route-level flag gates in AdminNotificationRoutes:\n * without this check an admin landing on /notifications could click\n * into any tab regardless of flag state.\n */\nexport function NotificationLandingPage() {\n const [params, setParams] = useSearchParams();\n const tr = useTr();\n\n // Explicit `false` fallback prevents the provider's default-allow from\n // leaking unseeded flags — same pattern as AdminNotificationRoot.tsx.\n const templatesDetails = useFeatureFlagDetails('notification.templates');\n const createDetails = useFeatureFlagDetails('notification.create');\n const historyDetails = useFeatureFlagDetails('notification.history');\n const templatesEnabled = templatesDetails ? Boolean(templatesDetails.value) : false;\n const createEnabled = createDetails ? Boolean(createDetails.value) : false;\n const historyEnabled = historyDetails ? Boolean(historyDetails.value) : false;\n\n const tabs: TabItem[] = useMemo(\n () => [\n { id: 'inbox', label: tr('notification.landing.tabs.inbox', 'Inbox') },\n ...(createEnabled\n ? [{ id: 'send', label: tr('notification.landing.tabs.send', 'Send') }]\n : []),\n ...(historyEnabled\n ? [{ id: 'history', label: tr('notification.landing.tabs.history', 'History') }]\n : []),\n ...(templatesEnabled\n ? [{ id: 'templates', label: tr('notification.landing.tabs.templates', 'Templates') }]\n : []),\n // Topics CRUD maps to `notification.create` per the backend @rbac (see\n // AdminNotificationRoutes.tsx: topics route is gated by createEnabled).\n ...(createEnabled\n ? [{ id: 'topics', label: tr('notification.landing.tabs.topics', 'Topics') }]\n : []),\n ],\n [tr, templatesEnabled, createEnabled, historyEnabled]\n );\n\n // Validate the `?tab=` query param against the filtered tab list — an\n // unknown value (stale URL, disabled flag) would otherwise leave the body\n // empty and the Tabs strip with no active item.\n const rawTab = params.get('tab');\n const activeId = rawTab && tabs.some((t) => t.id === rawTab) ? rawTab : tabs[0].id;\n\n // Rule 3 of COMPONENT_LEVEL_GATING.md: when a flag flips off while the\n // user is viewing that tab, clear the `tab` query param so subsequent\n // reloads don't resurrect the disabled view. Using the functional setter\n // form avoids depending on the `params` reference (which would re-fire\n // this effect on every update).\n useEffect(() => {\n if (rawTab && !tabs.some((t) => t.id === rawTab)) {\n setParams(\n (prev) => {\n const next = new URLSearchParams(prev);\n next.delete('tab');\n return next;\n },\n { replace: true }\n );\n }\n }, [rawTab, tabs, setParams]);\n\n // Functional setter avoids capturing a stale `params` reference in the\n // closure — prevents dropping a concurrent query param on rapid clicks.\n const handleTabChange = (id: string) => {\n setParams(\n (prev) => {\n const next = new URLSearchParams(prev);\n if (id === tabs[0].id) {\n next.delete('tab');\n } else {\n next.set('tab', id);\n }\n return next;\n },\n { replace: true }\n );\n };\n\n return (\n <div className=\"flex flex-col h-full\">\n <div className=\"border-b border-border-subtle px-4 pt-3\">\n <Tabs\n items={tabs}\n activeTabId={activeId}\n onTabChange={handleTabChange}\n variant=\"underline\"\n />\n </div>\n <div className=\"flex-1 min-h-0 overflow-auto\">\n {/*\n History tab is flag-gated but not PermissionGate-wrapped at this layer\n — it mirrors AdminNotificationRoutes where the /history route is the\n same: the admin page itself requires NOTIFICATION_LIST permission and\n renders its own no-permission fallback when missing. Templates and\n Create tabs go through separate flag-gated routes with PermissionGate\n in AdminNotificationRoutes, so when navigated via tab here they\n bypass that gate — but the inner pages (TemplateEditor, CreateNotificationPage,\n NotificationTemplatesPage) each perform their own permission checks\n and hide write actions for read-only users.\n */}\n {activeId === 'inbox' && <NotificationCenterPage />}\n <Suspense fallback={<TabBodyLoader />}>\n {activeId === 'send' && createEnabled && <CreateNotificationPage />}\n {activeId === 'history' && historyEnabled && <NotificationHistoryAdminPage />}\n {activeId === 'templates' && templatesEnabled && <NotificationTemplatesPage />}\n {activeId === 'topics' && createEnabled && <NotificationTopicsPage />}\n </Suspense>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;AAUA,IAAM,IAA+B,QACnC,OAAO,qCAAkC,MAAM,OAAO,EACpD,SAAS,EAAE,8BACZ,EAAE,CACJ,EACK,IAA4B,QAChC,OAAO,kCAA+B,MAAM,OAAO,EACjD,SAAS,EAAE,2BACZ,EAAE,CACJ,EACK,IAAyB,QAC7B,OAAO,+BAA4B,MAAM,OAAO,EAC9C,SAAS,EAAE,wBACZ,EAAE,CACJ,EACK,IAAyB,QAC7B,OAAO,+BAA4B,MAAM,OAAO,EAC9C,SAAS,EAAE,wBACZ,EAAE,CACJ;AAED,SAAS,IAAgB;AACvB,QACE,kBAAC,OAAD;EAAK,WAAU;YACb,kBAAC,OAAD,EAAK,WAAU,kFAAmF,CAAA;EAC9F,CAAA;;AAaV,SAAgB,IAA0B;CACxC,IAAM,CAAC,GAAQ,KAAa,GAAiB,EACvC,IAAK,GAAO,EAIZ,IAAmB,EAAsB,yBAAyB,EAClE,IAAgB,EAAsB,sBAAsB,EAC5D,IAAiB,EAAsB,uBAAuB,EAC9D,IAAmB,IAAmB,EAAQ,EAAiB,QAAS,IACxE,IAAgB,IAAgB,EAAQ,EAAc,QAAS,IAC/D,IAAiB,IAAiB,EAAQ,EAAe,QAAS,IAElE,IAAkB,QAChB;EACJ;GAAE,IAAI;GAAS,OAAO,EAAG,mCAAmC,QAAQ;GAAE;EACtE,GAAI,IACA,CAAC;GAAE,IAAI;GAAQ,OAAO,EAAG,kCAAkC,OAAO;GAAE,CAAC,GACrE,EAAE;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GAAD,EAAgC,CAAA;KAC5E,MAAa,eAAe,KAAoB,kBAAC,GAAD,EAA6B,CAAA;KAC7E,MAAa,YAAY,KAAiB,kBAAC,GAAD,EAA0B,CAAA;KAC5D;MACP;KACF"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationPreferencesPage.d.ts","sourceRoot":"","sources":["../../src/pages/NotificationPreferencesPage.tsx"],"names":[],"mappings":"AAQA,wBAAgB,2BAA2B,4CAmI1C"}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { useNotification as e } from "../providers/NotificationProvider.js";
|
|
2
|
+
import { useNotificationTopics as t } from "../hooks/useNotificationTopics.js";
|
|
3
|
+
import "../hooks/index.js";
|
|
4
|
+
import { useTr as n } from "../shared/hooks/useTr.js";
|
|
5
|
+
import { NOTIFICATION_PERMISSIONS as r } from "../constants/permissions.js";
|
|
6
|
+
import { useMemo as i, useState as a } from "react";
|
|
7
|
+
import { BellRing as o, Search as s, ToggleLeft as c, ToggleRight as l } from "lucide-react";
|
|
8
|
+
import { usePermissions as u } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
9
|
+
import { jsx as d, jsxs as f } from "react/jsx-runtime";
|
|
10
|
+
//#region src/pages/NotificationPreferencesPage.tsx
|
|
11
|
+
function p() {
|
|
12
|
+
let p = n(), { hasPermission: m, isLoading: h } = u(), { currentUser: g } = e(), { topics: _, isLoading: v, setTopicSubscription: y } = t({
|
|
13
|
+
type: "MARKETING",
|
|
14
|
+
isActive: !0
|
|
15
|
+
}), [b, x] = a(""), [S, C] = a(null), w = i(() => {
|
|
16
|
+
if (!b.trim()) return _;
|
|
17
|
+
let e = b.toLowerCase();
|
|
18
|
+
return _.filter((t) => t.name.toLowerCase().includes(e) || t.slug.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e));
|
|
19
|
+
}, [b, _]);
|
|
20
|
+
return h ? /* @__PURE__ */ d("div", {
|
|
21
|
+
className: "flex h-64 items-center justify-center",
|
|
22
|
+
children: /* @__PURE__ */ d("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
|
|
23
|
+
}) : !m(r.NOTIFICATION_LIST) && !g?.id ? /* @__PURE__ */ d("div", {
|
|
24
|
+
className: "p-8 text-center text-text-secondary",
|
|
25
|
+
children: p("notifications.noPermissionPreferences", "You don't have permission to manage notification preferences.")
|
|
26
|
+
}) : /* @__PURE__ */ f("div", {
|
|
27
|
+
className: "space-y-6 p-4 sm:p-6",
|
|
28
|
+
children: [
|
|
29
|
+
/* @__PURE__ */ f("div", { children: [/* @__PURE__ */ d("h1", {
|
|
30
|
+
className: "text-2xl font-bold text-primary",
|
|
31
|
+
children: p("notifications.preferencesTitle", "Notification Preferences")
|
|
32
|
+
}), /* @__PURE__ */ d("p", {
|
|
33
|
+
className: "mt-1 text-sm text-secondary",
|
|
34
|
+
children: p("notifications.preferencesSubtitle", "Choose which promotional topics you want to keep receiving.")
|
|
35
|
+
})] }),
|
|
36
|
+
/* @__PURE__ */ f("div", {
|
|
37
|
+
className: "relative max-w-xl",
|
|
38
|
+
children: [/* @__PURE__ */ d(s, {
|
|
39
|
+
size: 16,
|
|
40
|
+
className: "absolute left-3 top-1/2 -translate-y-1/2 text-tertiary"
|
|
41
|
+
}), /* @__PURE__ */ d("input", {
|
|
42
|
+
type: "text",
|
|
43
|
+
value: b,
|
|
44
|
+
onChange: (e) => x(e.target.value),
|
|
45
|
+
placeholder: p("notifications.searchTopics", "Search topics..."),
|
|
46
|
+
className: "w-full rounded-lg border border-default bg-surface py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent"
|
|
47
|
+
})]
|
|
48
|
+
}),
|
|
49
|
+
/* @__PURE__ */ d("div", {
|
|
50
|
+
className: "space-y-3",
|
|
51
|
+
children: v ? /* @__PURE__ */ d("div", {
|
|
52
|
+
className: "rounded-lg border border-default bg-surface p-6 text-sm text-secondary",
|
|
53
|
+
children: p("notifications.loadingTopics", "Loading topics...")
|
|
54
|
+
}) : w.length === 0 ? /* @__PURE__ */ d("div", {
|
|
55
|
+
className: "rounded-lg border border-default bg-surface p-6 text-sm text-secondary",
|
|
56
|
+
children: p("notifications.noTopicsFound", "No promotional topics available right now.")
|
|
57
|
+
}) : w.map((e) => {
|
|
58
|
+
let t = e.mySubscription?.subscribed ?? !0, n = S === e.id;
|
|
59
|
+
return /* @__PURE__ */ d("div", {
|
|
60
|
+
className: "rounded-lg border border-default bg-surface p-4 shadow-sm",
|
|
61
|
+
children: /* @__PURE__ */ f("div", {
|
|
62
|
+
className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between",
|
|
63
|
+
children: [/* @__PURE__ */ f("div", {
|
|
64
|
+
className: "space-y-1",
|
|
65
|
+
children: [/* @__PURE__ */ f("div", {
|
|
66
|
+
className: "flex items-center gap-2",
|
|
67
|
+
children: [
|
|
68
|
+
/* @__PURE__ */ d(o, {
|
|
69
|
+
size: 16,
|
|
70
|
+
className: "text-accent-primary"
|
|
71
|
+
}),
|
|
72
|
+
/* @__PURE__ */ d("h2", {
|
|
73
|
+
className: "text-sm font-semibold text-primary",
|
|
74
|
+
children: e.name
|
|
75
|
+
}),
|
|
76
|
+
/* @__PURE__ */ d("span", {
|
|
77
|
+
className: "rounded-full bg-muted px-2 py-0.5 text-xs text-secondary",
|
|
78
|
+
children: e.slug
|
|
79
|
+
})
|
|
80
|
+
]
|
|
81
|
+
}), e.description && /* @__PURE__ */ d("p", {
|
|
82
|
+
className: "text-sm text-secondary",
|
|
83
|
+
children: e.description
|
|
84
|
+
})]
|
|
85
|
+
}), /* @__PURE__ */ f("button", {
|
|
86
|
+
disabled: n,
|
|
87
|
+
onClick: async () => {
|
|
88
|
+
C(e.id);
|
|
89
|
+
try {
|
|
90
|
+
await y(e.id, !t);
|
|
91
|
+
} finally {
|
|
92
|
+
C(null);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
95
|
+
className: `inline-flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors ${t ? "bg-accent-primary text-white hover:opacity-90" : "bg-muted text-secondary hover:bg-muted/80"} disabled:cursor-not-allowed disabled:opacity-50`,
|
|
96
|
+
children: [d(t ? l : c, { size: 18 }), t ? p("notifications.subscribed", "Subscribed") : p("notifications.unsubscribed", "Unsubscribed")]
|
|
97
|
+
})]
|
|
98
|
+
})
|
|
99
|
+
}, e.id);
|
|
100
|
+
})
|
|
101
|
+
})
|
|
102
|
+
]
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
export { p as NotificationPreferencesPage };
|
|
107
|
+
|
|
108
|
+
//# sourceMappingURL=NotificationPreferencesPage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationPreferencesPage.js","names":[],"sources":["../../src/pages/NotificationPreferencesPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { BellRing, Search, ToggleLeft, ToggleRight } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { useNotificationTopics } from '../hooks';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useNotification } from '../providers/NotificationProvider';\nimport { useTr } from '../shared/hooks/useTr';\n\nexport function NotificationPreferencesPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { currentUser } = useNotification();\n const { topics, isLoading, setTopicSubscription } = useNotificationTopics({\n type: 'MARKETING',\n isActive: true,\n });\n const [search, setSearch] = useState('');\n const [savingTopicId, setSavingTopicId] = useState<string | null>(null);\n\n const filteredTopics = useMemo(() => {\n if (!search.trim()) {\n return topics;\n }\n\n const query = search.toLowerCase();\n return topics.filter(\n (topic) =>\n topic.name.toLowerCase().includes(query) ||\n topic.slug.toLowerCase().includes(query) ||\n topic.description?.toLowerCase().includes(query)\n );\n }, [search, topics]);\n\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_LIST) && !currentUser?.id) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionPreferences',\n \"You don't have permission to manage notification preferences.\"\n )}\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-4 sm:p-6\">\n <div>\n <h1 className=\"text-2xl font-bold text-primary\">\n {tr('notifications.preferencesTitle', 'Notification Preferences')}\n </h1>\n <p className=\"mt-1 text-sm text-secondary\">\n {tr(\n 'notifications.preferencesSubtitle',\n 'Choose which promotional topics you want to keep receiving.'\n )}\n </p>\n </div>\n\n <div className=\"relative max-w-xl\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n placeholder={tr('notifications.searchTopics', 'Search topics...')}\n className=\"w-full rounded-lg border border-default bg-surface py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </div>\n\n <div className=\"space-y-3\">\n {isLoading ? (\n <div className=\"rounded-lg border border-default bg-surface p-6 text-sm text-secondary\">\n {tr('notifications.loadingTopics', 'Loading topics...')}\n </div>\n ) : filteredTopics.length === 0 ? (\n <div className=\"rounded-lg border border-default bg-surface p-6 text-sm text-secondary\">\n {tr('notifications.noTopicsFound', 'No promotional topics available right now.')}\n </div>\n ) : (\n filteredTopics.map((topic) => {\n const isSubscribed = topic.mySubscription?.subscribed ?? true;\n const isSaving = savingTopicId === topic.id;\n\n return (\n <div\n key={topic.id}\n className=\"rounded-lg border border-default bg-surface p-4 shadow-sm\"\n >\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <div className=\"space-y-1\">\n <div className=\"flex items-center gap-2\">\n <BellRing size={16} className=\"text-accent-primary\" />\n <h2 className=\"text-sm font-semibold text-primary\">{topic.name}</h2>\n <span className=\"rounded-full bg-muted px-2 py-0.5 text-xs text-secondary\">\n {topic.slug}\n </span>\n </div>\n {topic.description && (\n <p className=\"text-sm text-secondary\">{topic.description}</p>\n )}\n </div>\n\n <button\n disabled={isSaving}\n onClick={async () => {\n setSavingTopicId(topic.id);\n try {\n await setTopicSubscription(topic.id, !isSubscribed);\n } finally {\n setSavingTopicId(null);\n }\n }}\n className={`inline-flex items-center gap-2 rounded-md px-3 py-2 text-sm font-medium transition-colors ${\n isSubscribed\n ? 'bg-accent-primary text-white hover:opacity-90'\n : 'bg-muted text-secondary hover:bg-muted/80'\n } disabled:cursor-not-allowed disabled:opacity-50`}\n >\n {isSubscribed ? <ToggleRight size={18} /> : <ToggleLeft size={18} />}\n {isSubscribed\n ? tr('notifications.subscribed', 'Subscribed')\n : tr('notifications.unsubscribed', 'Unsubscribed')}\n </button>\n </div>\n </div>\n );\n })\n )}\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAQA,SAAgB,IAA8B;CAC5C,IAAM,IAAK,GAAO,EACZ,EAAE,kBAAe,WAAW,MAAuB,GAAgB,EACnE,EAAE,mBAAgB,GAAiB,EACnC,EAAE,WAAQ,cAAW,4BAAyB,EAAsB;EACxE,MAAM;EACN,UAAU;EACX,CAAC,EACI,CAAC,GAAQ,KAAa,EAAS,GAAG,EAClC,CAAC,GAAe,KAAoB,EAAwB,KAAK,EAEjE,IAAiB,QAAc;AACnC,MAAI,CAAC,EAAO,MAAM,CAChB,QAAO;EAGT,IAAM,IAAQ,EAAO,aAAa;AAClC,SAAO,EAAO,QACX,MACC,EAAM,KAAK,aAAa,CAAC,SAAS,EAAM,IACxC,EAAM,KAAK,aAAa,CAAC,SAAS,EAAM,IACxC,EAAM,aAAa,aAAa,CAAC,SAAS,EAAM,CACnD;IACA,CAAC,GAAQ,EAAO,CAAC;AAqBpB,QAnBI,IAEA,kBAAC,OAAD;EAAK,WAAU;YACb,kBAAC,OAAD,EAAK,WAAU,kFAAmF,CAAA;EAC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,WAAU;mBAA0B,EAAM;SAAgB,CAAA,CAE3D;WAEN,kBAAC,UAAD;QACE,UAAU;QACV,SAAS,YAAY;AACnB,WAAiB,EAAM,GAAG;AAC1B,aAAI;AACF,gBAAM,EAAqB,EAAM,IAAI,CAAC,EAAa;mBAC3C;AACR,YAAiB,KAAK;;;QAG1B,WAAW,6FACT,IACI,kDACA,4CACL;kBAdH,CAgBkB,EAAf,IAAgB,IAA4B,GAA7B,EAAa,MAAM,IAAM,CAA2B,EACnE,IACG,EAAG,4BAA4B,aAAa,GAC5C,EAAG,8BAA8B,eAAe,CAC7C;UACL;;MACF,EAvCC,EAAM,GAuCP;MAER;IAEA,CAAA;GACF"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Notification Templates Page (Admin)
|
|
3
|
+
*
|
|
4
|
+
* Lists all notification templates from the real backend.
|
|
5
|
+
* Supports search, type filtering, delete, and navigation to editor.
|
|
6
|
+
*/
|
|
7
|
+
export declare function NotificationTemplatesPage(): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=NotificationTemplatesPage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"NotificationTemplatesPage.d.ts","sourceRoot":"","sources":["../../src/pages/NotificationTemplatesPage.tsx"],"names":[],"mappings":"AAqCA;;;;;GAKG;AACH,wBAAgB,yBAAyB,4CAiYxC"}
|