@burdenoff/microfe-notification 2026.624.1 → 2026.625.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.
@@ -7,79 +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 { useI18n as y } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
10
+ import { Button as y, GlassCard as b } from "@burdenoff/fe-libs/ui";
11
+ import { useI18n as x } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
11
12
  //#region src/pages/NotificationTemplatesPage.tsx
12
- var b = {
13
+ var S = {
13
14
  TRANSACTIONAL: "text-status-info-text bg-status-info-bg-subtle border-status-info-bg-subtle",
14
15
  MARKETING: "text-accent-purple bg-accent-purple-subtle border-accent-purple-subtle",
15
16
  SYSTEM: "text-status-warning-text bg-status-warning-bg-subtle border-status-warning-bg-subtle",
16
17
  ALERT: "text-status-error-text bg-status-error-bg-subtle border-status-error-bg-subtle"
17
- }, x = {
18
+ }, C = {
18
19
  TRANSACTIONAL: "Transactional",
19
20
  MARKETING: "Marketing",
20
21
  SYSTEM: "System",
21
22
  ALERT: "Alert"
22
23
  };
23
- function S(e, t) {
24
+ function w(e, t) {
24
25
  return new Date(e).toLocaleDateString(t || "en-US", {
25
26
  month: "short",
26
27
  day: "numeric",
27
28
  year: "numeric"
28
29
  });
29
30
  }
30
- function C() {
31
- let C = g(), w = e(), { locale: T } = y(), { hasPermission: E, isLoading: D } = c(), { templates: O, isLoading: k, isDeleting: A, error: j, total: M, hasMore: N, filter: P, refetch: F, loadMore: I, deleteTemplate: L, updateFilter: R } = a(), [z, B] = s(null), [V, H] = s(null), [U, W] = s(/* @__PURE__ */ new Set()), G = o(() => O.filter((e) => U.has(e.id)), [U, O]), K = O.length > 0 && O.every((e) => U.has(e.id)), q = O.some((e) => U.has(e.id)) && !K, J = E(i.TEMPLATE_CREATE), Y = E(i.TEMPLATE_DELETE), X = async (e, i) => {
31
+ function T() {
32
+ let T = g(), E = e(), { locale: D } = x(), { hasPermission: O, isLoading: k } = c(), { templates: A, isLoading: j, isDeleting: M, error: N, total: P, hasMore: F, filter: I, refetch: L, loadMore: R, deleteTemplate: z, updateFilter: B } = a(), [V, H] = s(null), [U, W] = s(null), [G, K] = s(/* @__PURE__ */ new Set()), q = o(() => A.filter((e) => G.has(e.id)), [G, A]), J = A.length > 0 && A.every((e) => G.has(e.id)), Y = A.some((e) => G.has(e.id)) && !J, X = O(i.TEMPLATE_CREATE), Z = O(i.TEMPLATE_DELETE), Q = async (e, i) => {
32
33
  e.stopPropagation(), n("medium");
33
- let a = w("notifTemplates.confirmDelete", `Delete template "${i.name}"? This cannot be undone.`), o = await t({
34
- title: w("notifTemplates.deleteTitle", "Delete template"),
34
+ let a = E("notifTemplates.confirmDelete", `Delete template "${i.name}"? This cannot be undone.`), o = await t({
35
+ title: E("notifTemplates.deleteTitle", "Delete template"),
35
36
  message: a,
36
- okButtonTitle: w("notifTemplates.delete", "Delete")
37
+ okButtonTitle: E("notifTemplates.delete", "Delete")
37
38
  });
38
39
  if (o === null ? confirm(a) : o) {
39
- B(i.id), H(null);
40
+ H(i.id), W(null);
40
41
  try {
41
- await L(i.id), r("success");
42
+ await z(i.id), r("success");
42
43
  } catch (e) {
43
- r("error"), H(e instanceof Error ? e.message : w("notifTemplates.deleteFailed", "Failed to delete template"));
44
+ r("error"), W(e instanceof Error ? e.message : E("notifTemplates.deleteFailed", "Failed to delete template"));
44
45
  } finally {
45
- B(null);
46
+ H(null);
46
47
  }
47
48
  }
48
- }, Z = async () => {
49
- if (G.length === 0) return;
49
+ }, $ = async () => {
50
+ if (q.length === 0) return;
50
51
  n("medium");
51
- let e = w("notifTemplates.confirmBulkDelete", `Delete ${G.length} selected template${G.length === 1 ? "" : "s"}? This cannot be undone.`), i = await t({
52
- title: w("notifTemplates.bulkDeleteTitle", "Delete templates"),
52
+ let e = E("notifTemplates.confirmBulkDelete", `Delete ${q.length} selected template${q.length === 1 ? "" : "s"}? This cannot be undone.`), i = await t({
53
+ title: E("notifTemplates.bulkDeleteTitle", "Delete templates"),
53
54
  message: e,
54
- okButtonTitle: w("notifTemplates.delete", "Delete")
55
+ okButtonTitle: E("notifTemplates.delete", "Delete")
55
56
  });
56
- (i === null ? window.confirm(e) : i) && (H(null), r((await Promise.allSettled(G.map((e) => L(e.id)))).some((e) => e.status === "rejected") ? "error" : "success"), W(/* @__PURE__ */ new Set()));
57
- }, Q = (e, t) => {
58
- W((n) => {
57
+ (i === null ? window.confirm(e) : i) && (W(null), r((await Promise.allSettled(q.map((e) => z(e.id)))).some((e) => e.status === "rejected") ? "error" : "success"), K(/* @__PURE__ */ new Set()));
58
+ }, ee = (e, t) => {
59
+ K((n) => {
59
60
  let r = new Set(n);
60
61
  return t ? r.add(e) : r.delete(e), r;
61
62
  });
62
- }, $ = (e) => {
63
- W((t) => {
63
+ }, te = (e) => {
64
+ K((t) => {
64
65
  let n = new Set(t);
65
- return O.forEach((t) => {
66
+ return A.forEach((t) => {
66
67
  e ? n.add(t.id) : n.delete(t.id);
67
68
  }), n;
68
69
  });
69
70
  };
70
- return D ? /* @__PURE__ */ _("div", {
71
+ return k ? /* @__PURE__ */ _("div", {
71
72
  className: "flex h-64 items-center justify-center",
72
73
  children: /* @__PURE__ */ _("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
73
- }) : E(i.TEMPLATE_LIST) || J || Y || E(i.TEMPLATE_UPDATE) ? k && O.length === 0 ? /* @__PURE__ */ v("div", {
74
+ }) : O(i.TEMPLATE_LIST) || X || Z || O(i.TEMPLATE_UPDATE) ? j && A.length === 0 ? /* @__PURE__ */ v("div", {
74
75
  className: "flex flex-col items-center justify-center h-64 gap-3",
75
76
  children: [/* @__PURE__ */ _(d, {
76
77
  size: 28,
77
78
  className: "animate-spin text-accent-primary"
78
79
  }), /* @__PURE__ */ _("p", {
79
80
  className: "text-sm text-secondary",
80
- children: w("notifTemplates.loading", "Loading templates...")
81
+ children: E("notifTemplates.loading", "Loading templates...")
81
82
  })]
82
- }) : j && O.length === 0 ? /* @__PURE__ */ v("div", {
83
+ }) : N && A.length === 0 ? /* @__PURE__ */ v("div", {
83
84
  className: "flex flex-col items-center justify-center h-64 gap-4",
84
85
  children: [
85
86
  /* @__PURE__ */ _(l, {
@@ -88,36 +89,36 @@ function C() {
88
89
  }),
89
90
  /* @__PURE__ */ _("p", {
90
91
  className: "text-sm text-error",
91
- children: j
92
+ children: N
92
93
  }),
93
94
  /* @__PURE__ */ v("button", {
94
- onClick: F,
95
+ onClick: L,
95
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",
96
- children: [/* @__PURE__ */ _(p, { size: 14 }), w("notifTemplates.retry", "Retry")]
97
+ children: [/* @__PURE__ */ _(p, { size: 14 }), E("notifTemplates.retry", "Retry")]
97
98
  })
98
99
  ]
99
100
  }) : /* @__PURE__ */ v("div", {
100
- className: "space-y-4 sm:space-y-6 p-3 sm:p-6 animate-in fade-in duration-300",
101
+ className: "space-y-4 sm:space-y-6 p-3 sm:p-6 animate-in fade-in duration-200",
101
102
  children: [
102
103
  /* @__PURE__ */ v("div", {
103
104
  className: "flex flex-col gap-4 sm:flex-row sm:items-center sm:justify-between",
104
105
  children: [/* @__PURE__ */ v("div", { children: [/* @__PURE__ */ _("h1", {
105
106
  className: "text-xl sm:text-2xl font-bold text-primary",
106
- children: w("notifTemplates.title", "Notification Templates")
107
+ children: E("notifTemplates.title", "Notification Templates")
107
108
  }), /* @__PURE__ */ v("p", {
108
109
  className: "text-sm text-secondary mt-1",
109
110
  children: [
110
- M,
111
+ P,
111
112
  " ",
112
- w("notifTemplates.templateCount", "template"),
113
- M === 1 ? "" : "s",
113
+ E("notifTemplates.templateCount", "template"),
114
+ P === 1 ? "" : "s",
114
115
  " ",
115
- w("notifTemplates.total", "total")
116
+ E("notifTemplates.total", "total")
116
117
  ]
117
- })] }), J && /* @__PURE__ */ v("button", {
118
- onClick: () => C("new"),
119
- 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 hover:shadow-md",
120
- children: [/* @__PURE__ */ _(f, { size: 16 }), w("notifTemplates.createTemplate", "Create Template")]
118
+ })] }), X && /* @__PURE__ */ v(y, {
119
+ onClick: () => T("new"),
120
+ className: "gap-2",
121
+ children: [/* @__PURE__ */ _(f, { size: 16 }), E("notifTemplates.createTemplate", "Create Template")]
121
122
  })]
122
123
  }),
123
124
  /* @__PURE__ */ v("div", {
@@ -129,107 +130,108 @@ function C() {
129
130
  className: "absolute left-3 top-1/2 -translate-y-1/2 text-tertiary"
130
131
  }), /* @__PURE__ */ _("input", {
131
132
  type: "text",
132
- value: P.search || "",
133
- onChange: (e) => R({ search: e.target.value }),
134
- placeholder: w("notifTemplates.searchPlaceholder", "Search templates..."),
133
+ value: I.search || "",
134
+ onChange: (e) => B({ search: e.target.value }),
135
+ placeholder: E("notifTemplates.searchPlaceholder", "Search templates..."),
135
136
  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"
136
137
  })]
137
138
  }), /* @__PURE__ */ v("select", {
138
- value: P.type || "",
139
- onChange: (e) => R({ type: e.target.value || void 0 }),
139
+ value: I.type || "",
140
+ onChange: (e) => B({ type: e.target.value || void 0 }),
140
141
  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",
141
142
  children: [
142
143
  /* @__PURE__ */ _("option", {
143
144
  value: "",
144
- children: w("notifTemplates.allTypes", "All Types")
145
+ children: E("notifTemplates.allTypes", "All Types")
145
146
  }),
146
147
  /* @__PURE__ */ _("option", {
147
148
  value: "TRANSACTIONAL",
148
- children: w("notifTemplates.typeTransactional", "Transactional")
149
+ children: E("notifTemplates.typeTransactional", "Transactional")
149
150
  }),
150
151
  /* @__PURE__ */ _("option", {
151
152
  value: "MARKETING",
152
- children: w("notifTemplates.typeMarketing", "Marketing")
153
+ children: E("notifTemplates.typeMarketing", "Marketing")
153
154
  }),
154
155
  /* @__PURE__ */ _("option", {
155
156
  value: "SYSTEM",
156
- children: w("notifTemplates.typeSystem", "System")
157
+ children: E("notifTemplates.typeSystem", "System")
157
158
  }),
158
159
  /* @__PURE__ */ _("option", {
159
160
  value: "ALERT",
160
- children: w("notifTemplates.typeAlert", "Alert")
161
+ children: E("notifTemplates.typeAlert", "Alert")
161
162
  })
162
163
  ]
163
164
  })]
164
165
  }),
165
- O.length > 0 && /* @__PURE__ */ v("div", {
166
- className: "flex flex-col gap-3 rounded-lg border border-default bg-surface p-4 sm:flex-row sm:items-center sm:justify-between",
166
+ A.length > 0 && /* @__PURE__ */ v(b, {
167
+ treatment: "plain",
168
+ className: "flex flex-col gap-3 border-border-seam p-4 sm:flex-row sm:items-center sm:justify-between",
167
169
  children: [/* @__PURE__ */ v("label", {
168
170
  className: "flex items-center gap-2 text-sm text-primary",
169
171
  children: [/* @__PURE__ */ _("input", {
170
172
  type: "checkbox",
171
- checked: K,
173
+ checked: J,
172
174
  ref: (e) => {
173
- e && (e.indeterminate = q && !K);
175
+ e && (e.indeterminate = Y && !J);
174
176
  },
175
- onChange: (e) => $(e.target.checked),
176
- "aria-label": w("notifTemplates.selectAllVisibleAria", "Select all notification templates"),
177
+ onChange: (e) => te(e.target.checked),
178
+ "aria-label": E("notifTemplates.selectAllVisibleAria", "Select all notification templates"),
177
179
  className: "h-4 w-4 rounded border-default text-accent-primary"
178
- }), /* @__PURE__ */ _("span", { children: w("notifTemplates.selectAllVisible", "Select all visible") })]
180
+ }), /* @__PURE__ */ _("span", { children: E("notifTemplates.selectAllVisible", "Select all visible") })]
179
181
  }), /* @__PURE__ */ v("div", {
180
182
  className: "flex items-center gap-2",
181
183
  children: [
182
184
  /* @__PURE__ */ v("span", {
183
185
  className: "text-sm text-secondary",
184
186
  children: [
185
- U.size,
187
+ G.size,
186
188
  " ",
187
- w("notifTemplates.selected", "selected")
189
+ E("notifTemplates.selected", "selected")
188
190
  ]
189
191
  }),
190
- U.size > 0 && /* @__PURE__ */ _("button", {
191
- onClick: () => W(/* @__PURE__ */ new Set()),
192
+ G.size > 0 && /* @__PURE__ */ _("button", {
193
+ onClick: () => K(/* @__PURE__ */ new Set()),
192
194
  className: "text-sm text-secondary hover:text-primary",
193
- children: w("notifTemplates.clearSelection", "Clear selection")
195
+ children: E("notifTemplates.clearSelection", "Clear selection")
194
196
  }),
195
- Y && /* @__PURE__ */ v("button", {
196
- onClick: Z,
197
- disabled: G.length === 0 || A,
197
+ Z && /* @__PURE__ */ v("button", {
198
+ onClick: $,
199
+ disabled: q.length === 0 || M,
198
200
  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",
199
201
  children: [
200
202
  /* @__PURE__ */ _(h, { size: 14 }),
201
- w("notifTemplates.deleteSelected", "Delete Selected"),
202
- G.length > 0 ? ` (${G.length})` : ""
203
+ E("notifTemplates.deleteSelected", "Delete Selected"),
204
+ q.length > 0 ? ` (${q.length})` : ""
203
205
  ]
204
206
  })
205
207
  ]
206
208
  })]
207
209
  }),
208
- V && /* @__PURE__ */ v("div", {
210
+ U && /* @__PURE__ */ v("div", {
209
211
  className: "flex items-center gap-3 p-3 bg-error/10 border border-error/30 rounded-lg",
210
212
  children: [/* @__PURE__ */ _(l, {
211
213
  size: 16,
212
214
  className: "text-error shrink-0"
213
215
  }), /* @__PURE__ */ _("p", {
214
216
  className: "text-sm text-error",
215
- children: V
217
+ children: U
216
218
  })]
217
219
  }),
218
- O.length === 0 && !k && /* @__PURE__ */ v("div", {
220
+ A.length === 0 && !j && /* @__PURE__ */ v("div", {
219
221
  className: "flex flex-col items-center justify-center h-48 gap-3",
220
222
  children: [/* @__PURE__ */ _(u, {
221
223
  size: 32,
222
224
  className: "text-tertiary"
223
225
  }), /* @__PURE__ */ _("p", {
224
226
  className: "text-sm text-secondary",
225
- children: P.search || P.type ? w("notifTemplates.noMatchingTemplates", "No templates match your filters") : w("notifTemplates.noTemplatesYet", "No templates yet. Create your first one!")
227
+ children: I.search || I.type ? E("notifTemplates.noMatchingTemplates", "No templates match your filters") : E("notifTemplates.noTemplatesYet", "No templates yet. Create your first one!")
226
228
  })]
227
229
  }),
228
230
  /* @__PURE__ */ _("div", {
229
231
  className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
230
- children: O.map((e) => /* @__PURE__ */ v("div", {
231
- onClick: () => C(e.slug),
232
- className: `group relative p-4 bg-surface border rounded-lg cursor-pointer transition-all duration-200 hover:bg-bg-sunken hover:shadow-md ${U.has(e.id) ? "border-accent-primary/50 ring-1 ring-accent-primary/20" : "border-default"}`,
232
+ children: A.map((e) => /* @__PURE__ */ v("div", {
233
+ onClick: () => T(e.slug),
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 ${G.has(e.id) ? "border-accent-primary/50 ring-1 ring-accent-primary/20" : "border-border-seam"}`,
233
235
  children: [
234
236
  /* @__PURE__ */ v("div", {
235
237
  className: "flex items-start justify-between mb-3",
@@ -237,12 +239,12 @@ function C() {
237
239
  className: "flex items-center gap-2",
238
240
  children: [/* @__PURE__ */ _("input", {
239
241
  type: "checkbox",
240
- checked: U.has(e.id),
242
+ checked: G.has(e.id),
241
243
  onChange: (t) => {
242
- t.stopPropagation(), Q(e.id, t.target.checked);
244
+ t.stopPropagation(), ee(e.id, t.target.checked);
243
245
  },
244
246
  onClick: (e) => e.stopPropagation(),
245
- "aria-label": w("notifTemplates.selectTemplateAria", "Select template {{name}}").replace("{{name}}", e.name),
247
+ "aria-label": E("notifTemplates.selectTemplateAria", "Select template {{name}}").replace("{{name}}", e.name),
246
248
  className: "h-4 w-4 rounded border-default text-accent-primary"
247
249
  }), /* @__PURE__ */ _(u, {
248
250
  size: 20,
@@ -251,14 +253,14 @@ function C() {
251
253
  }), /* @__PURE__ */ v("div", {
252
254
  className: "flex items-center gap-2",
253
255
  children: [/* @__PURE__ */ _("span", {
254
- className: `px-2 py-0.5 text-[10px] font-semibold rounded-full border ${b[e.type] || "text-tertiary bg-bg-sunken border-default"}`,
255
- children: w(`notifTemplates.type.${e.type}`, x[e.type] || e.type)
256
- }), Y && /* @__PURE__ */ _("button", {
257
- onClick: (t) => X(t, e),
258
- disabled: A && z === e.id,
256
+ className: `px-2 py-0.5 text-[10px] font-semibold rounded-full border ${S[e.type] || "text-tertiary bg-bg-sunken border-default"}`,
257
+ children: E(`notifTemplates.type.${e.type}`, C[e.type] || e.type)
258
+ }), Z && /* @__PURE__ */ _("button", {
259
+ onClick: (t) => Q(t, e),
260
+ disabled: M && V === e.id,
259
261
  className: "opacity-0 group-hover:opacity-100 p-1 text-tertiary hover:text-error rounded transition-all duration-150",
260
- title: w("notifTemplates.deleteTemplate", "Delete template"),
261
- children: A && z === e.id ? /* @__PURE__ */ _(d, {
262
+ title: E("notifTemplates.deleteTemplate", "Delete template"),
263
+ children: M && V === e.id ? /* @__PURE__ */ _(d, {
262
264
  size: 14,
263
265
  className: "animate-spin"
264
266
  }) : /* @__PURE__ */ _(h, { size: 14 })
@@ -285,40 +287,40 @@ function C() {
285
287
  /* @__PURE__ */ _("span", { children: "•" }),
286
288
  /* @__PURE__ */ _("span", {
287
289
  className: e.enabled ? "text-success" : "text-tertiary",
288
- children: e.enabled ? w("notifTemplates.enabled", "Enabled") : w("notifTemplates.disabled", "Disabled")
290
+ children: e.enabled ? E("notifTemplates.enabled", "Enabled") : E("notifTemplates.disabled", "Disabled")
289
291
  })
290
292
  ]
291
293
  }),
292
294
  /* @__PURE__ */ v("p", {
293
295
  className: "text-[10px] text-tertiary mt-1.5",
294
296
  children: [
295
- w("notifTemplates.updated", "Updated"),
297
+ E("notifTemplates.updated", "Updated"),
296
298
  " ",
297
- S(e.updatedAt, T)
299
+ w(e.updatedAt, D)
298
300
  ]
299
301
  })
300
302
  ]
301
303
  }, e.id))
302
304
  }),
303
- N && /* @__PURE__ */ _("div", {
305
+ F && /* @__PURE__ */ _("div", {
304
306
  className: "flex justify-center pt-2",
305
307
  children: /* @__PURE__ */ v("button", {
306
- onClick: I,
307
- disabled: k,
308
+ onClick: R,
309
+ disabled: j,
308
310
  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",
309
- children: [k ? /* @__PURE__ */ _(d, {
311
+ children: [j ? /* @__PURE__ */ _(d, {
310
312
  size: 14,
311
313
  className: "animate-spin"
312
- }) : null, w("notifTemplates.loadMore", "Load More")]
314
+ }) : null, E("notifTemplates.loadMore", "Load More")]
313
315
  })
314
316
  })
315
317
  ]
316
318
  }) : /* @__PURE__ */ _("div", {
317
319
  className: "p-8 text-center text-text-secondary",
318
- children: w("notifTemplates.noPermissionView", "You don't have permission to view notification templates.")
320
+ children: E("notifTemplates.noPermissionView", "You don't have permission to view notification templates.")
319
321
  });
320
322
  }
321
323
  //#endregion
322
- export { C as NotificationTemplatesPage };
324
+ export { T as NotificationTemplatesPage };
323
325
 
324
326
  //# 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 { 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-300\">\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\n onClick={() => navigate('new')}\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 hover:shadow-md\"\n >\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 <div className=\"flex flex-col gap-3 rounded-lg border border-default bg-surface p-4 sm:flex-row sm:items-center sm:justify-between\">\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 </div>\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 <div className=\"flex flex-col items-center justify-center h-48 gap-3\">\n <FileText size={32} className=\"text-tertiary\" />\n <p className=\"text-sm text-secondary\">\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 </p>\n </div>\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-surface border rounded-lg cursor-pointer transition-all duration-200 hover:bg-bg-sunken hover:shadow-md ${selectedTemplateIds.has(template.id) ? 'border-accent-primary/50 ring-1 ring-accent-primary/20' : 'border-default'}`}\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":";;;;;;;;;;;AAcA,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,I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S,KACrC,kBAAC,GAAD;UAAS,MAAM;UAAI,WAAU;UAAiB,CAAA,GAE9C,kBAAC,GAAD,EAAQ,MAAM,IAAM,CAAA;SAEf,CAAA,CAEP;UACF;;MAGN,kBAAC,MAAD;OAAI,WAAU;iBAAoD,EAAS;OAAU,CAAA;MAGpF,EAAS,eACR,kBAAC,KAAD;OAAG,WAAU;iBAA4C,EAAS;OAAgB,CAAA;MAIpF,kBAAC,OAAD;OAAK,WAAU;iBAAf;QACE,kBAAC,QAAD;SAAM,WAAU;mBAAkD,EAAS;SAAY,CAAA;QACvF,kBAAC,QAAD,EAAA,UAAM,KAAQ,CAAA;QACd,kBAAC,QAAD,EAAA,UAAO,EAAS,UAAU,MAAY,CAAA;QACtC,kBAAC,QAAD,EAAA,UAAM,KAAQ,CAAA;QACd,kBAAC,QAAD;SAAM,WAAW,EAAS,UAAU,iBAAiB;mBAClD,EAAS,UACN,EAAG,0BAA0B,UAAU,GACvC,EAAG,2BAA2B,WAAW;SACxC,CAAA;QACH;;MAGN,kBAAC,KAAD;OAAG,WAAU;iBAAb;QACG,EAAG,0BAA0B,UAAU;QAAC;QAAE,EAAW,EAAS,WAAW,EAAO;QAC/E;;MACA;OA7EC,EAAS,GA6EV,CACN;IACE,CAAA;GAGL,KACC,kBAAC,OAAD;IAAK,WAAU;cACb,kBAAC,UAAD;KACE,SAAS;KACT,UAAU;KACV,WAAU;eAHZ,CAKG,IAAY,kBAAC,GAAD;MAAS,MAAM;MAAI,WAAU;MAAiB,CAAA,GAAG,MAC7D,EAAG,2BAA2B,YAAY,CACpC;;IACL,CAAA;GAEJ;MArQJ,kBAAC,OAAD;EAAK,WAAU;YACZ,EACC,mCACA,4DACD;EACG,CAAA"}
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 } 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 <div className=\"flex flex-col items-center justify-center h-48 gap-3\">\n <FileText size={32} className=\"text-tertiary\" />\n <p className=\"text-sm text-secondary\">\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 </p>\n </div>\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,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