@burdenoff/microfe-notification 2026.625.2 → 2026.626.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/pages/CreateNotificationPage.js +473 -452
- package/dist/pages/CreateNotificationPage.js.map +1 -1
- package/dist/pages/NotificationCenterPage.js +87 -83
- package/dist/pages/NotificationCenterPage.js.map +1 -1
- package/dist/pages/NotificationHistoryAdminPage.js +139 -100
- package/dist/pages/NotificationHistoryAdminPage.js.map +1 -1
- package/dist/pages/NotificationHistoryPage.js +63 -59
- package/dist/pages/NotificationHistoryPage.js.map +1 -1
- package/dist/pages/NotificationPreferencesPage.js +77 -72
- package/dist/pages/NotificationPreferencesPage.js.map +1 -1
- package/dist/pages/NotificationTemplatesPage.js +127 -100
- package/dist/pages/NotificationTemplatesPage.js.map +1 -1
- package/dist/pages/NotificationTopicsPage.js +258 -210
- package/dist/pages/NotificationTopicsPage.js.map +1 -1
- package/dist/pages/TemplateEditorPage.js +350 -319
- package/dist/pages/TemplateEditorPage.js.map +1 -1
- package/package.json +2 -2
|
@@ -7,80 +7,80 @@ import { usePermissions as c } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
|
7
7
|
import { AlertCircle as l, FileText as u, Loader2 as d, Plus as f, RefreshCw as p, Search as m, Trash2 as h } from "lucide-react";
|
|
8
8
|
import { useNavigate as g } from "react-router-dom";
|
|
9
9
|
import { jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
10
|
-
import { Button as y,
|
|
11
|
-
import { useI18n as
|
|
10
|
+
import { Button as y, EmphasisPanel as b, GlassCard as x, IllustratedEmptyState as S, NextSteps as C, PagePurpose as w } from "@burdenoff/fe-libs/ui";
|
|
11
|
+
import { useI18n as T } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
12
12
|
//#region src/pages/NotificationTemplatesPage.tsx
|
|
13
|
-
var
|
|
13
|
+
var ee = {
|
|
14
14
|
TRANSACTIONAL: "text-status-info-text bg-status-info-bg-subtle border-status-info-bg-subtle",
|
|
15
15
|
MARKETING: "text-accent-purple bg-accent-purple-subtle border-accent-purple-subtle",
|
|
16
16
|
SYSTEM: "text-status-warning-text bg-status-warning-bg-subtle border-status-warning-bg-subtle",
|
|
17
17
|
ALERT: "text-status-error-text bg-status-error-bg-subtle border-status-error-bg-subtle"
|
|
18
|
-
},
|
|
18
|
+
}, te = {
|
|
19
19
|
TRANSACTIONAL: "Transactional",
|
|
20
20
|
MARKETING: "Marketing",
|
|
21
21
|
SYSTEM: "System",
|
|
22
22
|
ALERT: "Alert"
|
|
23
23
|
};
|
|
24
|
-
function
|
|
24
|
+
function E(e, t) {
|
|
25
25
|
return new Date(e).toLocaleDateString(t || "en-US", {
|
|
26
26
|
month: "short",
|
|
27
27
|
day: "numeric",
|
|
28
28
|
year: "numeric"
|
|
29
29
|
});
|
|
30
30
|
}
|
|
31
|
-
function
|
|
32
|
-
let
|
|
31
|
+
function D() {
|
|
32
|
+
let D = g(), O = e(), { locale: k } = T(), { hasPermission: A, isLoading: j } = c(), { templates: M, isLoading: N, isDeleting: P, error: F, total: I, hasMore: L, filter: R, refetch: z, loadMore: B, deleteTemplate: V, updateFilter: H } = a(), [U, W] = s(null), [G, K] = s(null), [q, J] = s(/* @__PURE__ */ new Set()), Y = o(() => M.filter((e) => q.has(e.id)), [q, M]), X = M.length > 0 && M.every((e) => q.has(e.id)), Z = M.some((e) => q.has(e.id)) && !X, Q = A(i.TEMPLATE_CREATE), $ = A(i.TEMPLATE_DELETE), ne = async (e, i) => {
|
|
33
33
|
e.stopPropagation(), n("medium");
|
|
34
|
-
let a =
|
|
35
|
-
title:
|
|
34
|
+
let a = O("notifTemplates.confirmDelete", `Delete template "${i.name}"? This cannot be undone.`), o = await t({
|
|
35
|
+
title: O("notifTemplates.deleteTitle", "Delete template"),
|
|
36
36
|
message: a,
|
|
37
|
-
okButtonTitle:
|
|
37
|
+
okButtonTitle: O("notifTemplates.delete", "Delete")
|
|
38
38
|
});
|
|
39
39
|
if (o === null ? confirm(a) : o) {
|
|
40
|
-
|
|
40
|
+
W(i.id), K(null);
|
|
41
41
|
try {
|
|
42
|
-
await
|
|
42
|
+
await V(i.id), r("success");
|
|
43
43
|
} catch (e) {
|
|
44
|
-
r("error"),
|
|
44
|
+
r("error"), K(e instanceof Error ? e.message : O("notifTemplates.deleteFailed", "Failed to delete template"));
|
|
45
45
|
} finally {
|
|
46
|
-
|
|
46
|
+
W(null);
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
},
|
|
50
|
-
if (
|
|
49
|
+
}, re = async () => {
|
|
50
|
+
if (Y.length === 0) return;
|
|
51
51
|
n("medium");
|
|
52
|
-
let e =
|
|
53
|
-
title:
|
|
52
|
+
let e = O("notifTemplates.confirmBulkDelete", `Delete ${Y.length} selected template${Y.length === 1 ? "" : "s"}? This cannot be undone.`), i = await t({
|
|
53
|
+
title: O("notifTemplates.bulkDeleteTitle", "Delete templates"),
|
|
54
54
|
message: e,
|
|
55
|
-
okButtonTitle:
|
|
55
|
+
okButtonTitle: O("notifTemplates.delete", "Delete")
|
|
56
56
|
});
|
|
57
|
-
(i === null ? window.confirm(e) : i) && (
|
|
58
|
-
},
|
|
59
|
-
|
|
57
|
+
(i === null ? window.confirm(e) : i) && (K(null), r((await Promise.allSettled(Y.map((e) => V(e.id)))).some((e) => e.status === "rejected") ? "error" : "success"), J(/* @__PURE__ */ new Set()));
|
|
58
|
+
}, ie = (e, t) => {
|
|
59
|
+
J((n) => {
|
|
60
60
|
let r = new Set(n);
|
|
61
61
|
return t ? r.add(e) : r.delete(e), r;
|
|
62
62
|
});
|
|
63
|
-
},
|
|
64
|
-
|
|
63
|
+
}, ae = (e) => {
|
|
64
|
+
J((t) => {
|
|
65
65
|
let n = new Set(t);
|
|
66
|
-
return
|
|
66
|
+
return M.forEach((t) => {
|
|
67
67
|
e ? n.add(t.id) : n.delete(t.id);
|
|
68
68
|
}), n;
|
|
69
69
|
});
|
|
70
70
|
};
|
|
71
|
-
return
|
|
71
|
+
return j ? /* @__PURE__ */ _("div", {
|
|
72
72
|
className: "flex h-64 items-center justify-center",
|
|
73
73
|
children: /* @__PURE__ */ _("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
|
|
74
|
-
}) :
|
|
74
|
+
}) : A(i.TEMPLATE_LIST) || Q || $ || A(i.TEMPLATE_UPDATE) ? N && M.length === 0 ? /* @__PURE__ */ v("div", {
|
|
75
75
|
className: "flex flex-col items-center justify-center h-64 gap-3",
|
|
76
76
|
children: [/* @__PURE__ */ _(d, {
|
|
77
77
|
size: 28,
|
|
78
78
|
className: "animate-spin text-accent-primary"
|
|
79
79
|
}), /* @__PURE__ */ _("p", {
|
|
80
80
|
className: "text-sm text-secondary",
|
|
81
|
-
children:
|
|
81
|
+
children: O("notifTemplates.loading", "Loading templates...")
|
|
82
82
|
})]
|
|
83
|
-
}) :
|
|
83
|
+
}) : F && M.length === 0 ? /* @__PURE__ */ v("div", {
|
|
84
84
|
className: "flex flex-col items-center justify-center h-64 gap-4",
|
|
85
85
|
children: [
|
|
86
86
|
/* @__PURE__ */ _(l, {
|
|
@@ -89,38 +89,65 @@ function E() {
|
|
|
89
89
|
}),
|
|
90
90
|
/* @__PURE__ */ _("p", {
|
|
91
91
|
className: "text-sm text-error",
|
|
92
|
-
children:
|
|
92
|
+
children: F
|
|
93
93
|
}),
|
|
94
94
|
/* @__PURE__ */ v("button", {
|
|
95
|
-
onClick:
|
|
95
|
+
onClick: z,
|
|
96
96
|
className: "flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-accent-primary hover:bg-accent-primary/90 rounded-lg transition-all duration-150",
|
|
97
|
-
children: [/* @__PURE__ */ _(p, { size: 14 }),
|
|
97
|
+
children: [/* @__PURE__ */ _(p, { size: 14 }), O("notifTemplates.retry", "Retry")]
|
|
98
98
|
})
|
|
99
99
|
]
|
|
100
100
|
}) : /* @__PURE__ */ v("div", {
|
|
101
101
|
className: "space-y-4 sm:space-y-6 p-3 sm:p-6 animate-in fade-in duration-200",
|
|
102
102
|
children: [
|
|
103
|
-
/* @__PURE__ */
|
|
104
|
-
|
|
103
|
+
/* @__PURE__ */ _(w, {
|
|
104
|
+
icon: /* @__PURE__ */ _(u, { size: 16 }),
|
|
105
|
+
children: O("notifTemplates.purpose", "Reusable, versioned message blueprints — subject lines, bodies and channel layouts with {{variables}} you fill in at send time. Build a template once (e.g. a welcome email or a payment receipt) and reuse it from the Send page so every notification stays on-brand and consistent.")
|
|
106
|
+
}),
|
|
107
|
+
/* @__PURE__ */ v(b, {
|
|
108
|
+
className: "flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6",
|
|
105
109
|
children: [/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("h1", {
|
|
106
110
|
className: "text-xl sm:text-2xl font-bold text-primary",
|
|
107
|
-
children:
|
|
111
|
+
children: O("notifTemplates.title", "Notification Templates")
|
|
108
112
|
}), /* @__PURE__ */ v("p", {
|
|
109
113
|
className: "text-sm text-secondary mt-1",
|
|
110
114
|
children: [
|
|
111
|
-
|
|
115
|
+
I,
|
|
112
116
|
" ",
|
|
113
|
-
|
|
114
|
-
|
|
117
|
+
O("notifTemplates.templateCount", "template"),
|
|
118
|
+
I === 1 ? "" : "s",
|
|
115
119
|
" ",
|
|
116
|
-
|
|
120
|
+
O("notifTemplates.total", "total")
|
|
117
121
|
]
|
|
118
|
-
})] }),
|
|
119
|
-
onClick: () =>
|
|
122
|
+
})] }), Q && /* @__PURE__ */ v(y, {
|
|
123
|
+
onClick: () => D("new"),
|
|
120
124
|
className: "gap-2",
|
|
121
|
-
children: [/* @__PURE__ */ _(f, { size: 16 }),
|
|
125
|
+
children: [/* @__PURE__ */ _(f, { size: 16 }), O("notifTemplates.createTemplate", "Create Template")]
|
|
122
126
|
})]
|
|
123
127
|
}),
|
|
128
|
+
/* @__PURE__ */ _(C, {
|
|
129
|
+
storageKey: "notification-templates",
|
|
130
|
+
steps: [
|
|
131
|
+
...Q ? [{
|
|
132
|
+
id: "create-template",
|
|
133
|
+
label: O("notifTemplates.nextCreateLabel", "Create your first template"),
|
|
134
|
+
description: O("notifTemplates.nextCreateDesc", "Build a reusable message blueprint with {{variables}} you fill in at send time."),
|
|
135
|
+
onClick: () => D("new")
|
|
136
|
+
}] : [],
|
|
137
|
+
{
|
|
138
|
+
id: "filter-type",
|
|
139
|
+
label: O("notifTemplates.nextFilterLabel", "Filter by type"),
|
|
140
|
+
description: O("notifTemplates.nextFilterDesc", "Narrow to Transactional, Marketing, System or Alert templates to find one fast."),
|
|
141
|
+
onClick: () => H({ type: "TRANSACTIONAL" })
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "use-on-send",
|
|
145
|
+
label: O("notifTemplates.nextUseLabel", "Send with a template"),
|
|
146
|
+
description: O("notifTemplates.nextUseDesc", "Pick any saved template from the Send page so every notification stays on-brand."),
|
|
147
|
+
href: "../send"
|
|
148
|
+
}
|
|
149
|
+
]
|
|
150
|
+
}),
|
|
124
151
|
/* @__PURE__ */ v("div", {
|
|
125
152
|
className: "flex flex-col gap-3 sm:flex-row sm:items-center",
|
|
126
153
|
children: [/* @__PURE__ */ v("div", {
|
|
@@ -130,108 +157,108 @@ function E() {
|
|
|
130
157
|
className: "absolute left-3 top-1/2 -translate-y-1/2 text-tertiary"
|
|
131
158
|
}), /* @__PURE__ */ _("input", {
|
|
132
159
|
type: "text",
|
|
133
|
-
value:
|
|
134
|
-
onChange: (e) =>
|
|
135
|
-
placeholder:
|
|
160
|
+
value: R.search || "",
|
|
161
|
+
onChange: (e) => H({ search: e.target.value }),
|
|
162
|
+
placeholder: O("notifTemplates.searchPlaceholder", "Search templates..."),
|
|
136
163
|
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"
|
|
137
164
|
})]
|
|
138
165
|
}), /* @__PURE__ */ v("select", {
|
|
139
|
-
value:
|
|
140
|
-
onChange: (e) =>
|
|
166
|
+
value: R.type || "",
|
|
167
|
+
onChange: (e) => H({ type: e.target.value || void 0 }),
|
|
141
168
|
className: "px-3 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",
|
|
142
169
|
children: [
|
|
143
170
|
/* @__PURE__ */ _("option", {
|
|
144
171
|
value: "",
|
|
145
|
-
children:
|
|
172
|
+
children: O("notifTemplates.allTypes", "All Types")
|
|
146
173
|
}),
|
|
147
174
|
/* @__PURE__ */ _("option", {
|
|
148
175
|
value: "TRANSACTIONAL",
|
|
149
|
-
children:
|
|
176
|
+
children: O("notifTemplates.typeTransactional", "Transactional")
|
|
150
177
|
}),
|
|
151
178
|
/* @__PURE__ */ _("option", {
|
|
152
179
|
value: "MARKETING",
|
|
153
|
-
children:
|
|
180
|
+
children: O("notifTemplates.typeMarketing", "Marketing")
|
|
154
181
|
}),
|
|
155
182
|
/* @__PURE__ */ _("option", {
|
|
156
183
|
value: "SYSTEM",
|
|
157
|
-
children:
|
|
184
|
+
children: O("notifTemplates.typeSystem", "System")
|
|
158
185
|
}),
|
|
159
186
|
/* @__PURE__ */ _("option", {
|
|
160
187
|
value: "ALERT",
|
|
161
|
-
children:
|
|
188
|
+
children: O("notifTemplates.typeAlert", "Alert")
|
|
162
189
|
})
|
|
163
190
|
]
|
|
164
191
|
})]
|
|
165
192
|
}),
|
|
166
|
-
|
|
193
|
+
M.length > 0 && /* @__PURE__ */ v(x, {
|
|
167
194
|
treatment: "plain",
|
|
168
195
|
className: "flex flex-col gap-3 border-border-seam p-4 sm:flex-row sm:items-center sm:justify-between",
|
|
169
196
|
children: [/* @__PURE__ */ v("label", {
|
|
170
197
|
className: "flex items-center gap-2 text-sm text-primary",
|
|
171
198
|
children: [/* @__PURE__ */ _("input", {
|
|
172
199
|
type: "checkbox",
|
|
173
|
-
checked:
|
|
200
|
+
checked: X,
|
|
174
201
|
ref: (e) => {
|
|
175
|
-
e && (e.indeterminate =
|
|
202
|
+
e && (e.indeterminate = Z && !X);
|
|
176
203
|
},
|
|
177
|
-
onChange: (e) =>
|
|
178
|
-
"aria-label":
|
|
204
|
+
onChange: (e) => ae(e.target.checked),
|
|
205
|
+
"aria-label": O("notifTemplates.selectAllVisibleAria", "Select all notification templates"),
|
|
179
206
|
className: "h-4 w-4 rounded border-default text-accent-primary"
|
|
180
|
-
}), /* @__PURE__ */ _("span", { children:
|
|
207
|
+
}), /* @__PURE__ */ _("span", { children: O("notifTemplates.selectAllVisible", "Select all visible") })]
|
|
181
208
|
}), /* @__PURE__ */ v("div", {
|
|
182
209
|
className: "flex items-center gap-2",
|
|
183
210
|
children: [
|
|
184
211
|
/* @__PURE__ */ v("span", {
|
|
185
212
|
className: "text-sm text-secondary",
|
|
186
213
|
children: [
|
|
187
|
-
|
|
214
|
+
q.size,
|
|
188
215
|
" ",
|
|
189
|
-
|
|
216
|
+
O("notifTemplates.selected", "selected")
|
|
190
217
|
]
|
|
191
218
|
}),
|
|
192
|
-
|
|
193
|
-
onClick: () =>
|
|
219
|
+
q.size > 0 && /* @__PURE__ */ _("button", {
|
|
220
|
+
onClick: () => J(/* @__PURE__ */ new Set()),
|
|
194
221
|
className: "text-sm text-secondary hover:text-primary",
|
|
195
|
-
children:
|
|
222
|
+
children: O("notifTemplates.clearSelection", "Clear selection")
|
|
196
223
|
}),
|
|
197
|
-
|
|
198
|
-
onClick:
|
|
199
|
-
disabled:
|
|
224
|
+
$ && /* @__PURE__ */ v("button", {
|
|
225
|
+
onClick: re,
|
|
226
|
+
disabled: Y.length === 0 || P,
|
|
200
227
|
className: "flex items-center gap-2 px-3 py-2 text-sm font-medium text-error border border-error/30 hover:bg-error/10 rounded-lg transition-all duration-150 disabled:opacity-50",
|
|
201
228
|
children: [
|
|
202
229
|
/* @__PURE__ */ _(h, { size: 14 }),
|
|
203
|
-
|
|
204
|
-
|
|
230
|
+
O("notifTemplates.deleteSelected", "Delete Selected"),
|
|
231
|
+
Y.length > 0 ? ` (${Y.length})` : ""
|
|
205
232
|
]
|
|
206
233
|
})
|
|
207
234
|
]
|
|
208
235
|
})]
|
|
209
236
|
}),
|
|
210
|
-
|
|
237
|
+
G && /* @__PURE__ */ v("div", {
|
|
211
238
|
className: "flex items-center gap-3 p-3 bg-error/10 border border-error/30 rounded-lg",
|
|
212
239
|
children: [/* @__PURE__ */ _(l, {
|
|
213
240
|
size: 16,
|
|
214
241
|
className: "text-error shrink-0"
|
|
215
242
|
}), /* @__PURE__ */ _("p", {
|
|
216
243
|
className: "text-sm text-error",
|
|
217
|
-
children:
|
|
244
|
+
children: G
|
|
218
245
|
})]
|
|
219
246
|
}),
|
|
220
|
-
|
|
221
|
-
illustration:
|
|
222
|
-
title:
|
|
223
|
-
description:
|
|
224
|
-
action: !
|
|
225
|
-
onClick: () =>
|
|
247
|
+
M.length === 0 && !N && /* @__PURE__ */ _(S, {
|
|
248
|
+
illustration: R.search || R.type ? "empty-search" : "empty-files",
|
|
249
|
+
title: R.search || R.type ? O("notifTemplates.noMatchingTemplates", "No templates match your filters") : O("notifTemplates.noTemplatesYet", "No templates yet. Create your first one!"),
|
|
250
|
+
description: R.search || R.type ? O("notifications.adjustSearchOrDateRange", "Try adjusting your filters") : O("notifTemplates.noTemplatesDescription", "Reusable templates let you send consistent notifications fast."),
|
|
251
|
+
action: !R.search && !R.type && Q ? /* @__PURE__ */ v(y, {
|
|
252
|
+
onClick: () => D("new"),
|
|
226
253
|
className: "gap-2",
|
|
227
|
-
children: [/* @__PURE__ */ _(f, { size: 16 }),
|
|
254
|
+
children: [/* @__PURE__ */ _(f, { size: 16 }), O("notifTemplates.createTemplate", "Create Template")]
|
|
228
255
|
}) : void 0
|
|
229
256
|
}),
|
|
230
257
|
/* @__PURE__ */ _("div", {
|
|
231
258
|
className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
|
|
232
|
-
children:
|
|
233
|
-
onClick: () =>
|
|
234
|
-
className: `group relative p-4 bg-gloss-card border rounded-lg cursor-pointer transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 ${
|
|
259
|
+
children: M.map((e) => /* @__PURE__ */ v("div", {
|
|
260
|
+
onClick: () => D(e.slug),
|
|
261
|
+
className: `group relative p-4 bg-gloss-card border rounded-lg cursor-pointer transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 ${q.has(e.id) ? "border-accent-primary/50 ring-1 ring-accent-primary/20" : "border-border-seam"}`,
|
|
235
262
|
children: [
|
|
236
263
|
/* @__PURE__ */ v("div", {
|
|
237
264
|
className: "flex items-start justify-between mb-3",
|
|
@@ -239,12 +266,12 @@ function E() {
|
|
|
239
266
|
className: "flex items-center gap-2",
|
|
240
267
|
children: [/* @__PURE__ */ _("input", {
|
|
241
268
|
type: "checkbox",
|
|
242
|
-
checked:
|
|
269
|
+
checked: q.has(e.id),
|
|
243
270
|
onChange: (t) => {
|
|
244
|
-
t.stopPropagation(),
|
|
271
|
+
t.stopPropagation(), ie(e.id, t.target.checked);
|
|
245
272
|
},
|
|
246
273
|
onClick: (e) => e.stopPropagation(),
|
|
247
|
-
"aria-label":
|
|
274
|
+
"aria-label": O("notifTemplates.selectTemplateAria", "Select template {{name}}").replace("{{name}}", e.name),
|
|
248
275
|
className: "h-4 w-4 rounded border-default text-accent-primary"
|
|
249
276
|
}), /* @__PURE__ */ _(u, {
|
|
250
277
|
size: 20,
|
|
@@ -253,14 +280,14 @@ function E() {
|
|
|
253
280
|
}), /* @__PURE__ */ v("div", {
|
|
254
281
|
className: "flex items-center gap-2",
|
|
255
282
|
children: [/* @__PURE__ */ _("span", {
|
|
256
|
-
className: `px-2 py-0.5 text-[10px] font-semibold rounded-full border ${
|
|
257
|
-
children:
|
|
258
|
-
}),
|
|
259
|
-
onClick: (t) =>
|
|
260
|
-
disabled:
|
|
283
|
+
className: `px-2 py-0.5 text-[10px] font-semibold rounded-full border ${ee[e.type] || "text-tertiary bg-bg-sunken border-default"}`,
|
|
284
|
+
children: O(`notifTemplates.type.${e.type}`, te[e.type] || e.type)
|
|
285
|
+
}), $ && /* @__PURE__ */ _("button", {
|
|
286
|
+
onClick: (t) => ne(t, e),
|
|
287
|
+
disabled: P && U === e.id,
|
|
261
288
|
className: "opacity-0 group-hover:opacity-100 p-1 text-tertiary hover:text-error rounded transition-all duration-150",
|
|
262
|
-
title:
|
|
263
|
-
children:
|
|
289
|
+
title: O("notifTemplates.deleteTemplate", "Delete template"),
|
|
290
|
+
children: P && U === e.id ? /* @__PURE__ */ _(d, {
|
|
264
291
|
size: 14,
|
|
265
292
|
className: "animate-spin"
|
|
266
293
|
}) : /* @__PURE__ */ _(h, { size: 14 })
|
|
@@ -287,40 +314,40 @@ function E() {
|
|
|
287
314
|
/* @__PURE__ */ _("span", { children: "•" }),
|
|
288
315
|
/* @__PURE__ */ _("span", {
|
|
289
316
|
className: e.enabled ? "text-success" : "text-tertiary",
|
|
290
|
-
children: e.enabled ?
|
|
317
|
+
children: e.enabled ? O("notifTemplates.enabled", "Enabled") : O("notifTemplates.disabled", "Disabled")
|
|
291
318
|
})
|
|
292
319
|
]
|
|
293
320
|
}),
|
|
294
321
|
/* @__PURE__ */ v("p", {
|
|
295
322
|
className: "text-[10px] text-tertiary mt-1.5",
|
|
296
323
|
children: [
|
|
297
|
-
|
|
324
|
+
O("notifTemplates.updated", "Updated"),
|
|
298
325
|
" ",
|
|
299
|
-
|
|
326
|
+
E(e.updatedAt, k)
|
|
300
327
|
]
|
|
301
328
|
})
|
|
302
329
|
]
|
|
303
330
|
}, e.id))
|
|
304
331
|
}),
|
|
305
|
-
|
|
332
|
+
L && /* @__PURE__ */ _("div", {
|
|
306
333
|
className: "flex justify-center pt-2",
|
|
307
334
|
children: /* @__PURE__ */ v("button", {
|
|
308
|
-
onClick:
|
|
309
|
-
disabled:
|
|
335
|
+
onClick: B,
|
|
336
|
+
disabled: N,
|
|
310
337
|
className: "flex items-center gap-2 px-4 py-2 text-sm text-secondary hover:text-primary border border-default rounded-lg transition-all duration-150 hover:shadow-sm",
|
|
311
|
-
children: [
|
|
338
|
+
children: [N ? /* @__PURE__ */ _(d, {
|
|
312
339
|
size: 14,
|
|
313
340
|
className: "animate-spin"
|
|
314
|
-
}) : null,
|
|
341
|
+
}) : null, O("notifTemplates.loadMore", "Load More")]
|
|
315
342
|
})
|
|
316
343
|
})
|
|
317
344
|
]
|
|
318
345
|
}) : /* @__PURE__ */ _("div", {
|
|
319
346
|
className: "p-8 text-center text-text-secondary",
|
|
320
|
-
children:
|
|
347
|
+
children: O("notifTemplates.noPermissionView", "You don't have permission to view notification templates.")
|
|
321
348
|
});
|
|
322
349
|
}
|
|
323
350
|
//#endregion
|
|
324
|
-
export {
|
|
351
|
+
export { D as NotificationTemplatesPage };
|
|
325
352
|
|
|
326
353
|
//# sourceMappingURL=NotificationTemplatesPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationTemplatesPage.js","names":[],"sources":["../../src/pages/NotificationTemplatesPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { FileText, Plus, Search, Trash2, Loader2, AlertCircle, RefreshCw } from 'lucide-react';\nimport { useNavigate } from 'react-router-dom';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button, GlassCard, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\nimport { useNotificationTemplates } from '../hooks/useNotificationTemplates';\nimport type { BackendNotificationTemplate } from '../hooks/useNotificationTemplates';\nimport type { NotificationType } from '../types';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\nimport { nativeConfirm, nativeImpact, nativeNotify } from '../utils/nativeBridge';\n\n// ── Helpers ────────────────────────────────────────────────────────────\n\nconst TYPE_COLORS: Record<NotificationType, string> = {\n TRANSACTIONAL: 'text-status-info-text bg-status-info-bg-subtle border-status-info-bg-subtle',\n MARKETING: 'text-accent-purple bg-accent-purple-subtle border-accent-purple-subtle',\n SYSTEM: 'text-status-warning-text bg-status-warning-bg-subtle border-status-warning-bg-subtle',\n ALERT: 'text-status-error-text bg-status-error-bg-subtle border-status-error-bg-subtle',\n};\n\nconst TYPE_LABELS: Record<NotificationType, string> = {\n TRANSACTIONAL: 'Transactional',\n MARKETING: 'Marketing',\n SYSTEM: 'System',\n ALERT: 'Alert',\n};\n\nfunction formatDate(iso: string, locale?: string) {\n return new Date(iso).toLocaleDateString(locale || 'en-US', {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n });\n}\n\n// ── Component ──────────────────────────────────────────────────────────\n\n/**\n * Notification Templates Page (Admin)\n *\n * Lists all notification templates from the real backend.\n * Supports search, type filtering, delete, and navigation to editor.\n */\nexport function NotificationTemplatesPage() {\n const navigate = useNavigate();\n const tr = useTr();\n const { locale } = useI18n();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const {\n templates,\n isLoading,\n isDeleting,\n error,\n total,\n hasMore,\n filter,\n refetch,\n loadMore,\n deleteTemplate,\n updateFilter,\n } = useNotificationTemplates();\n\n const [deletingId, setDeletingId] = useState<string | null>(null);\n const [deleteError, setDeleteError] = useState<string | null>(null);\n const [selectedTemplateIds, setSelectedTemplateIds] = useState<Set<string>>(new Set());\n\n const selectedTemplates = useMemo(\n () => templates.filter((template) => selectedTemplateIds.has(template.id)),\n [selectedTemplateIds, templates]\n );\n\n const allVisibleSelected =\n templates.length > 0 && templates.every((template) => selectedTemplateIds.has(template.id));\n const partiallySelected =\n templates.some((template) => selectedTemplateIds.has(template.id)) && !allVisibleSelected;\n\n const canCreateTemplate = hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_CREATE);\n const canDeleteTemplate = hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_DELETE);\n\n const handleDelete = async (e: React.MouseEvent, template: BackendNotificationTemplate) => {\n e.stopPropagation();\n nativeImpact('medium');\n const message = tr(\n 'notifTemplates.confirmDelete',\n `Delete template \"${template.name}\"? This cannot be undone.`\n );\n const nativeResult = await nativeConfirm({\n title: tr('notifTemplates.deleteTitle', 'Delete template'),\n message,\n okButtonTitle: tr('notifTemplates.delete', 'Delete'),\n });\n const confirmed = nativeResult === null ? confirm(message) : nativeResult;\n if (!confirmed) return;\n\n setDeletingId(template.id);\n setDeleteError(null);\n try {\n await deleteTemplate(template.id);\n void nativeNotify('success');\n } catch (err: unknown) {\n void nativeNotify('error');\n setDeleteError(\n err instanceof Error\n ? err.message\n : tr('notifTemplates.deleteFailed', 'Failed to delete template')\n );\n } finally {\n setDeletingId(null);\n }\n };\n\n const handleBulkDelete = async () => {\n if (selectedTemplates.length === 0) return;\n nativeImpact('medium');\n const message = tr(\n 'notifTemplates.confirmBulkDelete',\n `Delete ${selectedTemplates.length} selected template${selectedTemplates.length === 1 ? '' : 's'}? This cannot be undone.`\n );\n const nativeResult = await nativeConfirm({\n title: tr('notifTemplates.bulkDeleteTitle', 'Delete templates'),\n message,\n okButtonTitle: tr('notifTemplates.delete', 'Delete'),\n });\n const confirmed = nativeResult === null ? window.confirm(message) : nativeResult;\n if (!confirmed) return;\n\n setDeleteError(null);\n const results = await Promise.allSettled(\n selectedTemplates.map((template) => deleteTemplate(template.id))\n );\n const failed = results.some((r) => r.status === 'rejected');\n void nativeNotify(failed ? 'error' : 'success');\n setSelectedTemplateIds(new Set());\n };\n\n const toggleTemplateSelection = (templateId: string, checked: boolean) => {\n setSelectedTemplateIds((prev) => {\n const next = new Set(prev);\n if (checked) {\n next.add(templateId);\n } else {\n next.delete(templateId);\n }\n return next;\n });\n };\n\n const toggleAllTemplates = (checked: boolean) => {\n setSelectedTemplateIds((prev) => {\n const next = new Set(prev);\n templates.forEach((template) => {\n if (checked) {\n next.add(template.id);\n } else {\n next.delete(template.id);\n }\n });\n return next;\n });\n };\n\n // ── Permission guards ────────────────────────────────────────────────\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 // TEMPLATE_LIST admits read-only admins; the page already hides/disables write actions for them.\n const canViewTemplates =\n hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_LIST) ||\n canCreateTemplate ||\n canDeleteTemplate ||\n hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_UPDATE);\n\n if (!canViewTemplates) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifTemplates.noPermissionView',\n \"You don't have permission to view notification templates.\"\n )}\n </div>\n );\n }\n\n // ── Loading state ────────────────────────────────────────────────────\n if (isLoading && templates.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center h-64 gap-3\">\n <Loader2 size={28} className=\"animate-spin text-accent-primary\" />\n <p className=\"text-sm text-secondary\">\n {tr('notifTemplates.loading', 'Loading templates...')}\n </p>\n </div>\n );\n }\n\n // ── Error state ──────────────────────────────────────────────────────\n if (error && templates.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center h-64 gap-4\">\n <AlertCircle size={28} className=\"text-error\" />\n <p className=\"text-sm text-error\">{error}</p>\n <button\n onClick={refetch}\n className=\"flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-accent-primary hover:bg-accent-primary/90 rounded-lg transition-all duration-150\"\n >\n <RefreshCw size={14} />\n {tr('notifTemplates.retry', 'Retry')}\n </button>\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-200\">\n {/* Header */}\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('notifTemplates.title', 'Notification Templates')}\n </h1>\n <p className=\"text-sm text-secondary mt-1\">\n {total} {tr('notifTemplates.templateCount', 'template')}\n {total !== 1 ? 's' : ''} {tr('notifTemplates.total', 'total')}\n </p>\n </div>\n\n {canCreateTemplate && (\n <Button onClick={() => navigate('new')} className=\"gap-2\">\n <Plus size={16} />\n {tr('notifTemplates.createTemplate', 'Create Template')}\n </Button>\n )}\n </div>\n\n {/* Search + Type filter row */}\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center\">\n {/* Search */}\n <div className=\"relative flex-1\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n value={filter.search || ''}\n onChange={(e) => updateFilter({ search: e.target.value })}\n placeholder={tr('notifTemplates.searchPlaceholder', 'Search templates...')}\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 {/* Type filter */}\n <select\n value={filter.type || ''}\n onChange={(e) =>\n updateFilter({ type: (e.target.value || undefined) as NotificationType | undefined })\n }\n className=\"px-3 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 <option value=\"\">{tr('notifTemplates.allTypes', 'All Types')}</option>\n <option value=\"TRANSACTIONAL\">\n {tr('notifTemplates.typeTransactional', 'Transactional')}\n </option>\n <option value=\"MARKETING\">{tr('notifTemplates.typeMarketing', 'Marketing')}</option>\n <option value=\"SYSTEM\">{tr('notifTemplates.typeSystem', 'System')}</option>\n <option value=\"ALERT\">{tr('notifTemplates.typeAlert', 'Alert')}</option>\n </select>\n </div>\n\n {templates.length > 0 && (\n <GlassCard\n treatment=\"plain\"\n className=\"flex flex-col gap-3 border-border-seam p-4 sm:flex-row sm:items-center sm:justify-between\"\n >\n <label className=\"flex items-center gap-2 text-sm text-primary\">\n <input\n type=\"checkbox\"\n checked={allVisibleSelected}\n ref={(input) => {\n if (input) {\n input.indeterminate = partiallySelected && !allVisibleSelected;\n }\n }}\n onChange={(event) => toggleAllTemplates(event.target.checked)}\n aria-label={tr(\n 'notifTemplates.selectAllVisibleAria',\n 'Select all notification templates'\n )}\n className=\"h-4 w-4 rounded border-default text-accent-primary\"\n />\n <span>{tr('notifTemplates.selectAllVisible', 'Select all visible')}</span>\n </label>\n\n <div className=\"flex items-center gap-2\">\n <span className=\"text-sm text-secondary\">\n {selectedTemplateIds.size} {tr('notifTemplates.selected', 'selected')}\n </span>\n {selectedTemplateIds.size > 0 && (\n <button\n onClick={() => setSelectedTemplateIds(new Set())}\n className=\"text-sm text-secondary hover:text-primary\"\n >\n {tr('notifTemplates.clearSelection', 'Clear selection')}\n </button>\n )}\n {canDeleteTemplate && (\n <button\n onClick={handleBulkDelete}\n disabled={selectedTemplates.length === 0 || isDeleting}\n className=\"flex items-center gap-2 px-3 py-2 text-sm font-medium text-error border border-error/30 hover:bg-error/10 rounded-lg transition-all duration-150 disabled:opacity-50\"\n >\n <Trash2 size={14} />\n {tr('notifTemplates.deleteSelected', 'Delete Selected')}\n {selectedTemplates.length > 0 ? ` (${selectedTemplates.length})` : ''}\n </button>\n )}\n </div>\n </GlassCard>\n )}\n\n {/* Delete error banner */}\n {deleteError && (\n <div className=\"flex items-center gap-3 p-3 bg-error/10 border border-error/30 rounded-lg\">\n <AlertCircle size={16} className=\"text-error shrink-0\" />\n <p className=\"text-sm text-error\">{deleteError}</p>\n </div>\n )}\n\n {/* Empty state */}\n {templates.length === 0 && !isLoading && (\n <IllustratedEmptyState\n illustration={filter.search || filter.type ? 'empty-search' : 'empty-files'}\n title={\n filter.search || filter.type\n ? tr('notifTemplates.noMatchingTemplates', 'No templates match your filters')\n : tr('notifTemplates.noTemplatesYet', 'No templates yet. Create your first one!')\n }\n description={\n filter.search || filter.type\n ? tr('notifications.adjustSearchOrDateRange', 'Try adjusting your filters')\n : tr(\n 'notifTemplates.noTemplatesDescription',\n 'Reusable templates let you send consistent notifications fast.'\n )\n }\n action={\n !filter.search && !filter.type && canCreateTemplate ? (\n <Button onClick={() => navigate('new')} className=\"gap-2\">\n <Plus size={16} />\n {tr('notifTemplates.createTemplate', 'Create Template')}\n </Button>\n ) : undefined\n }\n />\n )}\n\n {/* Templates grid */}\n <div className=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {templates.map((template) => (\n <div\n key={template.id}\n onClick={() => navigate(template.slug)}\n className={`group relative p-4 bg-gloss-card border rounded-lg cursor-pointer transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 ${selectedTemplateIds.has(template.id) ? 'border-accent-primary/50 ring-1 ring-accent-primary/20' : 'border-border-seam'}`}\n >\n {/* Top row: icon + type badge + delete */}\n <div className=\"flex items-start justify-between mb-3\">\n <div className=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n checked={selectedTemplateIds.has(template.id)}\n onChange={(event) => {\n event.stopPropagation();\n toggleTemplateSelection(template.id, event.target.checked);\n }}\n onClick={(event) => event.stopPropagation()}\n aria-label={tr(\n 'notifTemplates.selectTemplateAria',\n 'Select template {{name}}'\n ).replace('{{name}}', template.name)}\n className=\"h-4 w-4 rounded border-default text-accent-primary\"\n />\n <FileText size={20} className=\"text-accent-primary\" />\n </div>\n <div className=\"flex items-center gap-2\">\n <span\n className={`px-2 py-0.5 text-[10px] font-semibold rounded-full border ${\n TYPE_COLORS[template.type as NotificationType] ||\n 'text-tertiary bg-bg-sunken border-default'\n }`}\n >\n {tr(\n `notifTemplates.type.${template.type as NotificationType}`,\n TYPE_LABELS[template.type as NotificationType] || template.type\n )}\n </span>\n {canDeleteTemplate && (\n <button\n onClick={(e) => handleDelete(e, template)}\n disabled={isDeleting && deletingId === template.id}\n className=\"opacity-0 group-hover:opacity-100 p-1 text-tertiary hover:text-error rounded transition-all duration-150\"\n title={tr('notifTemplates.deleteTemplate', 'Delete template')}\n >\n {isDeleting && deletingId === template.id ? (\n <Loader2 size={14} className=\"animate-spin\" />\n ) : (\n <Trash2 size={14} />\n )}\n </button>\n )}\n </div>\n </div>\n\n {/* Name */}\n <h3 className=\"text-sm font-semibold text-primary mb-1 truncate\">{template.name}</h3>\n\n {/* Description */}\n {template.description && (\n <p className=\"text-xs text-secondary mb-2 line-clamp-2\">{template.description}</p>\n )}\n\n {/* Bottom row: slug + enabled badge + locale */}\n <div className=\"flex items-center gap-2 text-[11px] text-tertiary mt-auto pt-2 border-t border-default/50\">\n <code className=\"px-1.5 py-0.5 bg-bg-sunken rounded text-[10px]\">{template.slug}</code>\n <span>•</span>\n <span>{template.locale || 'en'}</span>\n <span>•</span>\n <span className={template.enabled ? 'text-success' : 'text-tertiary'}>\n {template.enabled\n ? tr('notifTemplates.enabled', 'Enabled')\n : tr('notifTemplates.disabled', 'Disabled')}\n </span>\n </div>\n\n {/* Updated date */}\n <p className=\"text-[10px] text-tertiary mt-1.5\">\n {tr('notifTemplates.updated', 'Updated')} {formatDate(template.updatedAt, locale)}\n </p>\n </div>\n ))}\n </div>\n\n {/* Load more */}\n {hasMore && (\n <div className=\"flex justify-center pt-2\">\n <button\n onClick={loadMore}\n disabled={isLoading}\n className=\"flex items-center gap-2 px-4 py-2 text-sm text-secondary hover:text-primary border border-default rounded-lg transition-all duration-150 hover:shadow-sm\"\n >\n {isLoading ? <Loader2 size={14} className=\"animate-spin\" /> : null}\n {tr('notifTemplates.loadMore', 'Load More')}\n </button>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAeA,IAAM,IAAgD;CACpD,eAAe;CACf,WAAW;CACX,QAAQ;CACR,OAAO;CACR,EAEK,IAAgD;CACpD,eAAe;CACf,WAAW;CACX,QAAQ;CACR,OAAO;CACR;AAED,SAAS,EAAW,GAAa,GAAiB;AAChD,QAAO,IAAI,KAAK,EAAI,CAAC,mBAAmB,KAAU,SAAS;EACzD,OAAO;EACP,KAAK;EACL,MAAM;EACP,CAAC;;AAWJ,SAAgB,IAA4B;CAC1C,IAAM,IAAW,GAAa,EACxB,IAAK,GAAO,EACZ,EAAE,cAAW,GAAS,EACtB,EAAE,kBAAe,WAAW,MAAuB,GAAgB,EACnE,EACJ,cACA,cACA,eACA,UACA,UACA,YACA,WAC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import { useMemo, useState } from 'react';\nimport { FileText, Plus, Search, Trash2, Loader2, AlertCircle, RefreshCw } from 'lucide-react';\nimport { useNavigate } from 'react-router-dom';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport {\n Button,\n EmphasisPanel,\n GlassCard,\n IllustratedEmptyState,\n NextSteps,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationTemplates } from '../hooks/useNotificationTemplates';\nimport type { BackendNotificationTemplate } from '../hooks/useNotificationTemplates';\nimport type { NotificationType } from '../types';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\nimport { nativeConfirm, nativeImpact, nativeNotify } from '../utils/nativeBridge';\n\n// ── Helpers ────────────────────────────────────────────────────────────\n\nconst TYPE_COLORS: Record<NotificationType, string> = {\n TRANSACTIONAL: 'text-status-info-text bg-status-info-bg-subtle border-status-info-bg-subtle',\n MARKETING: 'text-accent-purple bg-accent-purple-subtle border-accent-purple-subtle',\n SYSTEM: 'text-status-warning-text bg-status-warning-bg-subtle border-status-warning-bg-subtle',\n ALERT: 'text-status-error-text bg-status-error-bg-subtle border-status-error-bg-subtle',\n};\n\nconst TYPE_LABELS: Record<NotificationType, string> = {\n TRANSACTIONAL: 'Transactional',\n MARKETING: 'Marketing',\n SYSTEM: 'System',\n ALERT: 'Alert',\n};\n\nfunction formatDate(iso: string, locale?: string) {\n return new Date(iso).toLocaleDateString(locale || 'en-US', {\n month: 'short',\n day: 'numeric',\n year: 'numeric',\n });\n}\n\n// ── Component ──────────────────────────────────────────────────────────\n\n/**\n * Notification Templates Page (Admin)\n *\n * Lists all notification templates from the real backend.\n * Supports search, type filtering, delete, and navigation to editor.\n */\nexport function NotificationTemplatesPage() {\n const navigate = useNavigate();\n const tr = useTr();\n const { locale } = useI18n();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const {\n templates,\n isLoading,\n isDeleting,\n error,\n total,\n hasMore,\n filter,\n refetch,\n loadMore,\n deleteTemplate,\n updateFilter,\n } = useNotificationTemplates();\n\n const [deletingId, setDeletingId] = useState<string | null>(null);\n const [deleteError, setDeleteError] = useState<string | null>(null);\n const [selectedTemplateIds, setSelectedTemplateIds] = useState<Set<string>>(new Set());\n\n const selectedTemplates = useMemo(\n () => templates.filter((template) => selectedTemplateIds.has(template.id)),\n [selectedTemplateIds, templates]\n );\n\n const allVisibleSelected =\n templates.length > 0 && templates.every((template) => selectedTemplateIds.has(template.id));\n const partiallySelected =\n templates.some((template) => selectedTemplateIds.has(template.id)) && !allVisibleSelected;\n\n const canCreateTemplate = hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_CREATE);\n const canDeleteTemplate = hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_DELETE);\n\n const handleDelete = async (e: React.MouseEvent, template: BackendNotificationTemplate) => {\n e.stopPropagation();\n nativeImpact('medium');\n const message = tr(\n 'notifTemplates.confirmDelete',\n `Delete template \"${template.name}\"? This cannot be undone.`\n );\n const nativeResult = await nativeConfirm({\n title: tr('notifTemplates.deleteTitle', 'Delete template'),\n message,\n okButtonTitle: tr('notifTemplates.delete', 'Delete'),\n });\n const confirmed = nativeResult === null ? confirm(message) : nativeResult;\n if (!confirmed) return;\n\n setDeletingId(template.id);\n setDeleteError(null);\n try {\n await deleteTemplate(template.id);\n void nativeNotify('success');\n } catch (err: unknown) {\n void nativeNotify('error');\n setDeleteError(\n err instanceof Error\n ? err.message\n : tr('notifTemplates.deleteFailed', 'Failed to delete template')\n );\n } finally {\n setDeletingId(null);\n }\n };\n\n const handleBulkDelete = async () => {\n if (selectedTemplates.length === 0) return;\n nativeImpact('medium');\n const message = tr(\n 'notifTemplates.confirmBulkDelete',\n `Delete ${selectedTemplates.length} selected template${selectedTemplates.length === 1 ? '' : 's'}? This cannot be undone.`\n );\n const nativeResult = await nativeConfirm({\n title: tr('notifTemplates.bulkDeleteTitle', 'Delete templates'),\n message,\n okButtonTitle: tr('notifTemplates.delete', 'Delete'),\n });\n const confirmed = nativeResult === null ? window.confirm(message) : nativeResult;\n if (!confirmed) return;\n\n setDeleteError(null);\n const results = await Promise.allSettled(\n selectedTemplates.map((template) => deleteTemplate(template.id))\n );\n const failed = results.some((r) => r.status === 'rejected');\n void nativeNotify(failed ? 'error' : 'success');\n setSelectedTemplateIds(new Set());\n };\n\n const toggleTemplateSelection = (templateId: string, checked: boolean) => {\n setSelectedTemplateIds((prev) => {\n const next = new Set(prev);\n if (checked) {\n next.add(templateId);\n } else {\n next.delete(templateId);\n }\n return next;\n });\n };\n\n const toggleAllTemplates = (checked: boolean) => {\n setSelectedTemplateIds((prev) => {\n const next = new Set(prev);\n templates.forEach((template) => {\n if (checked) {\n next.add(template.id);\n } else {\n next.delete(template.id);\n }\n });\n return next;\n });\n };\n\n // ── Permission guards ────────────────────────────────────────────────\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 // TEMPLATE_LIST admits read-only admins; the page already hides/disables write actions for them.\n const canViewTemplates =\n hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_LIST) ||\n canCreateTemplate ||\n canDeleteTemplate ||\n hasPermission(NOTIFICATION_PERMISSIONS.TEMPLATE_UPDATE);\n\n if (!canViewTemplates) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifTemplates.noPermissionView',\n \"You don't have permission to view notification templates.\"\n )}\n </div>\n );\n }\n\n // ── Loading state ────────────────────────────────────────────────────\n if (isLoading && templates.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center h-64 gap-3\">\n <Loader2 size={28} className=\"animate-spin text-accent-primary\" />\n <p className=\"text-sm text-secondary\">\n {tr('notifTemplates.loading', 'Loading templates...')}\n </p>\n </div>\n );\n }\n\n // ── Error state ──────────────────────────────────────────────────────\n if (error && templates.length === 0) {\n return (\n <div className=\"flex flex-col items-center justify-center h-64 gap-4\">\n <AlertCircle size={28} className=\"text-error\" />\n <p className=\"text-sm text-error\">{error}</p>\n <button\n onClick={refetch}\n className=\"flex items-center gap-2 px-4 py-2 text-sm font-medium text-white bg-accent-primary hover:bg-accent-primary/90 rounded-lg transition-all duration-150\"\n >\n <RefreshCw size={14} />\n {tr('notifTemplates.retry', 'Retry')}\n </button>\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-200\">\n <PagePurpose icon={<FileText size={16} />}>\n {tr(\n 'notifTemplates.purpose',\n 'Reusable, versioned message blueprints — subject lines, bodies and channel layouts with {{variables}} you fill in at send time. Build a template once (e.g. a welcome email or a payment receipt) and reuse it from the Send page so every notification stays on-brand and consistent.'\n )}\n </PagePurpose>\n\n {/* Header — single emphasis zone (count summary + the one create CTA). */}\n <EmphasisPanel className=\"flex flex-col gap-4 p-5 sm:flex-row sm:items-center sm:justify-between sm:p-6\">\n <div>\n <h1 className=\"text-xl sm:text-2xl font-bold text-primary\">\n {tr('notifTemplates.title', 'Notification Templates')}\n </h1>\n <p className=\"text-sm text-secondary mt-1\">\n {total} {tr('notifTemplates.templateCount', 'template')}\n {total !== 1 ? 's' : ''} {tr('notifTemplates.total', 'total')}\n </p>\n </div>\n\n {canCreateTemplate && (\n <Button onClick={() => navigate('new')} className=\"gap-2\">\n <Plus size={16} />\n {tr('notifTemplates.createTemplate', 'Create Template')}\n </Button>\n )}\n </EmphasisPanel>\n\n <NextSteps\n storageKey=\"notification-templates\"\n steps={[\n ...(canCreateTemplate\n ? [\n {\n id: 'create-template',\n label: tr('notifTemplates.nextCreateLabel', 'Create your first template'),\n description: tr(\n 'notifTemplates.nextCreateDesc',\n 'Build a reusable message blueprint with {{variables}} you fill in at send time.'\n ),\n onClick: () => navigate('new'),\n },\n ]\n : []),\n {\n id: 'filter-type',\n label: tr('notifTemplates.nextFilterLabel', 'Filter by type'),\n description: tr(\n 'notifTemplates.nextFilterDesc',\n 'Narrow to Transactional, Marketing, System or Alert templates to find one fast.'\n ),\n onClick: () => updateFilter({ type: 'TRANSACTIONAL' }),\n },\n {\n id: 'use-on-send',\n label: tr('notifTemplates.nextUseLabel', 'Send with a template'),\n description: tr(\n 'notifTemplates.nextUseDesc',\n 'Pick any saved template from the Send page so every notification stays on-brand.'\n ),\n href: '../send',\n },\n ]}\n />\n\n {/* Search + Type filter row */}\n <div className=\"flex flex-col gap-3 sm:flex-row sm:items-center\">\n {/* Search */}\n <div className=\"relative flex-1\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n value={filter.search || ''}\n onChange={(e) => updateFilter({ search: e.target.value })}\n placeholder={tr('notifTemplates.searchPlaceholder', 'Search templates...')}\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 {/* Type filter */}\n <select\n value={filter.type || ''}\n onChange={(e) =>\n updateFilter({ type: (e.target.value || undefined) as NotificationType | undefined })\n }\n className=\"px-3 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 <option value=\"\">{tr('notifTemplates.allTypes', 'All Types')}</option>\n <option value=\"TRANSACTIONAL\">\n {tr('notifTemplates.typeTransactional', 'Transactional')}\n </option>\n <option value=\"MARKETING\">{tr('notifTemplates.typeMarketing', 'Marketing')}</option>\n <option value=\"SYSTEM\">{tr('notifTemplates.typeSystem', 'System')}</option>\n <option value=\"ALERT\">{tr('notifTemplates.typeAlert', 'Alert')}</option>\n </select>\n </div>\n\n {templates.length > 0 && (\n <GlassCard\n treatment=\"plain\"\n className=\"flex flex-col gap-3 border-border-seam p-4 sm:flex-row sm:items-center sm:justify-between\"\n >\n <label className=\"flex items-center gap-2 text-sm text-primary\">\n <input\n type=\"checkbox\"\n checked={allVisibleSelected}\n ref={(input) => {\n if (input) {\n input.indeterminate = partiallySelected && !allVisibleSelected;\n }\n }}\n onChange={(event) => toggleAllTemplates(event.target.checked)}\n aria-label={tr(\n 'notifTemplates.selectAllVisibleAria',\n 'Select all notification templates'\n )}\n className=\"h-4 w-4 rounded border-default text-accent-primary\"\n />\n <span>{tr('notifTemplates.selectAllVisible', 'Select all visible')}</span>\n </label>\n\n <div className=\"flex items-center gap-2\">\n <span className=\"text-sm text-secondary\">\n {selectedTemplateIds.size} {tr('notifTemplates.selected', 'selected')}\n </span>\n {selectedTemplateIds.size > 0 && (\n <button\n onClick={() => setSelectedTemplateIds(new Set())}\n className=\"text-sm text-secondary hover:text-primary\"\n >\n {tr('notifTemplates.clearSelection', 'Clear selection')}\n </button>\n )}\n {canDeleteTemplate && (\n <button\n onClick={handleBulkDelete}\n disabled={selectedTemplates.length === 0 || isDeleting}\n className=\"flex items-center gap-2 px-3 py-2 text-sm font-medium text-error border border-error/30 hover:bg-error/10 rounded-lg transition-all duration-150 disabled:opacity-50\"\n >\n <Trash2 size={14} />\n {tr('notifTemplates.deleteSelected', 'Delete Selected')}\n {selectedTemplates.length > 0 ? ` (${selectedTemplates.length})` : ''}\n </button>\n )}\n </div>\n </GlassCard>\n )}\n\n {/* Delete error banner */}\n {deleteError && (\n <div className=\"flex items-center gap-3 p-3 bg-error/10 border border-error/30 rounded-lg\">\n <AlertCircle size={16} className=\"text-error shrink-0\" />\n <p className=\"text-sm text-error\">{deleteError}</p>\n </div>\n )}\n\n {/* Empty state */}\n {templates.length === 0 && !isLoading && (\n <IllustratedEmptyState\n illustration={filter.search || filter.type ? 'empty-search' : 'empty-files'}\n title={\n filter.search || filter.type\n ? tr('notifTemplates.noMatchingTemplates', 'No templates match your filters')\n : tr('notifTemplates.noTemplatesYet', 'No templates yet. Create your first one!')\n }\n description={\n filter.search || filter.type\n ? tr('notifications.adjustSearchOrDateRange', 'Try adjusting your filters')\n : tr(\n 'notifTemplates.noTemplatesDescription',\n 'Reusable templates let you send consistent notifications fast.'\n )\n }\n action={\n !filter.search && !filter.type && canCreateTemplate ? (\n <Button onClick={() => navigate('new')} className=\"gap-2\">\n <Plus size={16} />\n {tr('notifTemplates.createTemplate', 'Create Template')}\n </Button>\n ) : undefined\n }\n />\n )}\n\n {/* Templates grid */}\n <div className=\"grid gap-4 sm:grid-cols-2 lg:grid-cols-3\">\n {templates.map((template) => (\n <div\n key={template.id}\n onClick={() => navigate(template.slug)}\n className={`group relative p-4 bg-gloss-card border rounded-lg cursor-pointer transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)] hover:border-accent-primary/30 ${selectedTemplateIds.has(template.id) ? 'border-accent-primary/50 ring-1 ring-accent-primary/20' : 'border-border-seam'}`}\n >\n {/* Top row: icon + type badge + delete */}\n <div className=\"flex items-start justify-between mb-3\">\n <div className=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n checked={selectedTemplateIds.has(template.id)}\n onChange={(event) => {\n event.stopPropagation();\n toggleTemplateSelection(template.id, event.target.checked);\n }}\n onClick={(event) => event.stopPropagation()}\n aria-label={tr(\n 'notifTemplates.selectTemplateAria',\n 'Select template {{name}}'\n ).replace('{{name}}', template.name)}\n className=\"h-4 w-4 rounded border-default text-accent-primary\"\n />\n <FileText size={20} className=\"text-accent-primary\" />\n </div>\n <div className=\"flex items-center gap-2\">\n <span\n className={`px-2 py-0.5 text-[10px] font-semibold rounded-full border ${\n TYPE_COLORS[template.type as NotificationType] ||\n 'text-tertiary bg-bg-sunken border-default'\n }`}\n >\n {tr(\n `notifTemplates.type.${template.type as NotificationType}`,\n TYPE_LABELS[template.type as NotificationType] || template.type\n )}\n </span>\n {canDeleteTemplate && (\n <button\n onClick={(e) => handleDelete(e, template)}\n disabled={isDeleting && deletingId === template.id}\n className=\"opacity-0 group-hover:opacity-100 p-1 text-tertiary hover:text-error rounded transition-all duration-150\"\n title={tr('notifTemplates.deleteTemplate', 'Delete template')}\n >\n {isDeleting && deletingId === template.id ? (\n <Loader2 size={14} className=\"animate-spin\" />\n ) : (\n <Trash2 size={14} />\n )}\n </button>\n )}\n </div>\n </div>\n\n {/* Name */}\n <h3 className=\"text-sm font-semibold text-primary mb-1 truncate\">{template.name}</h3>\n\n {/* Description */}\n {template.description && (\n <p className=\"text-xs text-secondary mb-2 line-clamp-2\">{template.description}</p>\n )}\n\n {/* Bottom row: slug + enabled badge + locale */}\n <div className=\"flex items-center gap-2 text-[11px] text-tertiary mt-auto pt-2 border-t border-default/50\">\n <code className=\"px-1.5 py-0.5 bg-bg-sunken rounded text-[10px]\">{template.slug}</code>\n <span>•</span>\n <span>{template.locale || 'en'}</span>\n <span>•</span>\n <span className={template.enabled ? 'text-success' : 'text-tertiary'}>\n {template.enabled\n ? tr('notifTemplates.enabled', 'Enabled')\n : tr('notifTemplates.disabled', 'Disabled')}\n </span>\n </div>\n\n {/* Updated date */}\n <p className=\"text-[10px] text-tertiary mt-1.5\">\n {tr('notifTemplates.updated', 'Updated')} {formatDate(template.updatedAt, locale)}\n </p>\n </div>\n ))}\n </div>\n\n {/* Load more */}\n {hasMore && (\n <div className=\"flex justify-center pt-2\">\n <button\n onClick={loadMore}\n disabled={isLoading}\n className=\"flex items-center gap-2 px-4 py-2 text-sm text-secondary hover:text-primary border border-default rounded-lg transition-all duration-150 hover:shadow-sm\"\n >\n {isLoading ? <Loader2 size={14} className=\"animate-spin\" /> : null}\n {tr('notifTemplates.loadMore', 'Load More')}\n </button>\n </div>\n )}\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAsBA,IAAM,KAAgD;CACpD,eAAe;CACf,WAAW;CACX,QAAQ;CACR,OAAO;CACR,EAEK,KAAgD;CACpD,eAAe;CACf,WAAW;CACX,QAAQ;CACR,OAAO;CACR;AAED,SAAS,EAAW,GAAa,GAAiB;AAChD,QAAO,IAAI,KAAK,EAAI,CAAC,mBAAmB,KAAU,SAAS;EACzD,OAAO;EACP,KAAK;EACL,MAAM;EACP,CAAC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