@burdenoff/microfe-notification 2026.625.1 → 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.
@@ -6,9 +6,9 @@ import { useMemo as r, useState as i } from "react";
6
6
  import { usePermissions as a } from "@burdenoff/fe-libs/shared/providers/shell";
7
7
  import { Plus as o, Save as s, Search as c, Trash2 as l } from "lucide-react";
8
8
  import { jsx as u, jsxs as d } from "react/jsx-runtime";
9
- import { GlassCard as f } from "@burdenoff/fe-libs/ui";
9
+ import { EmphasisPanel as f, GlassCard as p, IllustratedEmptyState as m, NextSteps as h, PagePurpose as g } from "@burdenoff/fe-libs/ui";
10
10
  //#region src/pages/NotificationTopicsPage.tsx
11
- var p = [
11
+ var _ = [
12
12
  {
13
13
  value: "MARKETING",
14
14
  label: "Marketing"
@@ -26,231 +26,280 @@ var p = [
26
26
  label: "Alert"
27
27
  }
28
28
  ];
29
- function m(e) {
29
+ function v(e) {
30
30
  return e.toLowerCase().trim().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-").replace(/-+/g, "-");
31
31
  }
32
- function h() {
33
- let h = t(), { hasPermission: g, isLoading: _ } = a(), { topics: v, isLoading: y, createTopic: b, updateTopic: x, deleteTopic: S } = e(), [C, w] = i(""), [T, E] = i(null), [D, O] = i({
32
+ function y() {
33
+ let y = t(), { hasPermission: b, isLoading: x } = a(), { topics: S, isLoading: C, createTopic: w, updateTopic: T, deleteTopic: E } = e(), [D, O] = i(""), [k, A] = i(null), [j, M] = i({
34
34
  name: "",
35
35
  slug: "",
36
36
  description: "",
37
37
  type: "MARKETING",
38
38
  isActive: !0
39
- }), k = g(n.NOTIFICATION_CREATE), A = r(() => {
40
- if (!C.trim()) return v;
41
- let e = C.toLowerCase();
42
- return v.filter((t) => t.name.toLowerCase().includes(e) || t.slug.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e));
43
- }, [C, v]);
44
- return _ ? /* @__PURE__ */ u("div", {
39
+ }), N = b(n.NOTIFICATION_CREATE), P = r(() => {
40
+ if (!D.trim()) return S;
41
+ let e = D.toLowerCase();
42
+ return S.filter((t) => t.name.toLowerCase().includes(e) || t.slug.toLowerCase().includes(e) || t.description?.toLowerCase().includes(e));
43
+ }, [D, S]);
44
+ return x ? /* @__PURE__ */ u("div", {
45
45
  className: "flex h-64 items-center justify-center",
46
46
  children: /* @__PURE__ */ u("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent" })
47
- }) : k ? /* @__PURE__ */ d("div", {
47
+ }) : N ? /* @__PURE__ */ d("div", {
48
48
  className: "space-y-6 p-4 sm:p-6",
49
- children: [/* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("h1", {
50
- className: "text-2xl font-bold text-primary",
51
- children: h("notifications.topicsTitle", "Notification Topics")
52
- }), /* @__PURE__ */ u("p", {
53
- className: "mt-1 text-sm text-secondary",
54
- children: h("notifications.topicsSubtitle", "Create topics for campaigns so users can subscribe or unsubscribe with precision.")
55
- })] }), /* @__PURE__ */ d("div", {
56
- className: "grid gap-6 xl:grid-cols-[380px,1fr]",
57
- children: [/* @__PURE__ */ d("form", {
58
- className: "space-y-4 rounded-lg border border-border-seam bg-gloss-card p-4",
59
- onSubmit: async (e) => {
60
- e.preventDefault(), !(!D.name.trim() || !D.slug.trim()) && (T ? await x(T, D) : await b(D), E(null), O({
61
- name: "",
62
- slug: "",
63
- description: "",
64
- type: "MARKETING",
65
- isActive: !0
66
- }));
67
- },
68
- children: [
69
- /* @__PURE__ */ d("div", {
70
- className: "flex items-center gap-2",
71
- children: [/* @__PURE__ */ u(o, {
72
- size: 18,
73
- className: "text-accent-primary"
74
- }), /* @__PURE__ */ u("h2", {
75
- className: "text-base font-semibold text-primary",
76
- children: T ? h("notifications.editTopic", "Edit Topic") : h("notifications.createTopic", "Create Topic")
77
- })]
78
- }),
79
- /* @__PURE__ */ d("label", {
80
- className: "block space-y-1 text-sm text-secondary",
81
- children: [/* @__PURE__ */ u("span", { children: h("notifications.topicName", "Name") }), /* @__PURE__ */ u("input", {
82
- type: "text",
83
- value: D.name,
84
- onChange: (e) => O((t) => ({
85
- ...t,
86
- name: e.target.value,
87
- slug: T ? t.slug : m(e.target.value)
88
- })),
89
- className: "w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent"
90
- })]
91
- }),
92
- /* @__PURE__ */ d("label", {
93
- className: "block space-y-1 text-sm text-secondary",
94
- children: [/* @__PURE__ */ u("span", { children: h("notifications.topicSlug", "Slug") }), /* @__PURE__ */ u("input", {
49
+ children: [
50
+ /* @__PURE__ */ d("div", { children: [/* @__PURE__ */ u("h1", {
51
+ className: "text-2xl font-bold text-primary",
52
+ children: y("notifications.topicsTitle", "Notification Topics")
53
+ }), /* @__PURE__ */ u("p", {
54
+ className: "mt-1 text-sm text-secondary",
55
+ children: y("notifications.topicsSubtitle", "Create topics for campaigns so users can subscribe or unsubscribe with precision.")
56
+ })] }),
57
+ /* @__PURE__ */ u(g, {
58
+ icon: /* @__PURE__ */ u(o, { size: 16 }),
59
+ children: y("notifications.topicsPurpose", "Topics group related notifications (e.g. \"Product updates\", \"Billing reminders\", \"Weekly digest\") so people can opt in or out of exactly what they care about. Create a topic here, then target it when sending a campaign and let users manage their own subscriptions in Preferences.")
60
+ }),
61
+ /* @__PURE__ */ u(h, {
62
+ storageKey: "notification-topics",
63
+ steps: [
64
+ {
65
+ id: "name-topic",
66
+ label: y("notifications.topicsNextNameLabel", "Name your first topic"),
67
+ description: y("notifications.topicsNextNameDesc", "Use the form to add a clear topic like \"Product updates\" — the slug is generated for you."),
68
+ onClick: () => {
69
+ A(null), M((e) => ({
70
+ ...e,
71
+ name: "",
72
+ slug: "",
73
+ type: "MARKETING"
74
+ })), document.getElementById("notification-topic-name")?.scrollIntoView({
75
+ behavior: "smooth",
76
+ block: "center"
77
+ }), document.getElementById("notification-topic-name")?.focus();
78
+ }
79
+ },
80
+ {
81
+ id: "set-type",
82
+ label: y("notifications.topicsNextTypeLabel", "Pick the right type"),
83
+ description: y("notifications.topicsNextTypeDesc", "Marketing topics are opt-in for users; Transactional, System and Alert reach everyone."),
84
+ onClick: () => document.getElementById("notification-topic-type")?.scrollIntoView({
85
+ behavior: "smooth",
86
+ block: "center"
87
+ })
88
+ },
89
+ {
90
+ id: "let-subscribe",
91
+ label: y("notifications.topicsNextSubscribeLabel", "Let people subscribe"),
92
+ description: y("notifications.topicsNextSubscribeDesc", "Once a topic is active, users manage their own opt-ins from the Preferences page."),
93
+ href: "../preferences"
94
+ }
95
+ ]
96
+ }),
97
+ /* @__PURE__ */ d("div", {
98
+ className: "grid gap-6 xl:grid-cols-[380px,1fr]",
99
+ children: [/* @__PURE__ */ u(f, {
100
+ className: "p-4",
101
+ children: /* @__PURE__ */ d("form", {
102
+ className: "space-y-4",
103
+ onSubmit: async (e) => {
104
+ e.preventDefault(), !(!j.name.trim() || !j.slug.trim()) && (k ? await T(k, j) : await w(j), A(null), M({
105
+ name: "",
106
+ slug: "",
107
+ description: "",
108
+ type: "MARKETING",
109
+ isActive: !0
110
+ }));
111
+ },
112
+ children: [
113
+ /* @__PURE__ */ d("div", {
114
+ className: "flex items-center gap-2",
115
+ children: [/* @__PURE__ */ u(o, {
116
+ size: 18,
117
+ className: "text-accent-primary"
118
+ }), /* @__PURE__ */ u("h2", {
119
+ className: "text-base font-semibold text-primary",
120
+ children: k ? y("notifications.editTopic", "Edit Topic") : y("notifications.createTopic", "Create Topic")
121
+ })]
122
+ }),
123
+ /* @__PURE__ */ d("label", {
124
+ className: "block space-y-1 text-sm text-secondary",
125
+ children: [/* @__PURE__ */ u("span", { children: y("notifications.topicName", "Name") }), /* @__PURE__ */ u("input", {
126
+ id: "notification-topic-name",
127
+ type: "text",
128
+ value: j.name,
129
+ onChange: (e) => M((t) => ({
130
+ ...t,
131
+ name: e.target.value,
132
+ slug: k ? t.slug : v(e.target.value)
133
+ })),
134
+ className: "w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent"
135
+ })]
136
+ }),
137
+ /* @__PURE__ */ d("label", {
138
+ className: "block space-y-1 text-sm text-secondary",
139
+ children: [/* @__PURE__ */ u("span", { children: y("notifications.topicSlug", "Slug") }), /* @__PURE__ */ u("input", {
140
+ type: "text",
141
+ value: j.slug,
142
+ onChange: (e) => M((t) => ({
143
+ ...t,
144
+ slug: v(e.target.value)
145
+ })),
146
+ className: "w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent"
147
+ })]
148
+ }),
149
+ /* @__PURE__ */ d("label", {
150
+ className: "block space-y-1 text-sm text-secondary",
151
+ children: [/* @__PURE__ */ u("span", { children: y("notifications.topicType", "Type") }), /* @__PURE__ */ u("select", {
152
+ id: "notification-topic-type",
153
+ value: j.type,
154
+ onChange: (e) => M((t) => ({
155
+ ...t,
156
+ type: e.target.value
157
+ })),
158
+ className: "w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent",
159
+ children: _.map((e) => /* @__PURE__ */ u("option", {
160
+ value: e.value,
161
+ children: e.label
162
+ }, e.value))
163
+ })]
164
+ }),
165
+ /* @__PURE__ */ d("label", {
166
+ className: "block space-y-1 text-sm text-secondary",
167
+ children: [/* @__PURE__ */ u("span", { children: y("notifications.topicDescription", "Description") }), /* @__PURE__ */ u("textarea", {
168
+ value: j.description,
169
+ onChange: (e) => M((t) => ({
170
+ ...t,
171
+ description: e.target.value
172
+ })),
173
+ rows: 4,
174
+ className: "w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent"
175
+ })]
176
+ }),
177
+ /* @__PURE__ */ d("label", {
178
+ className: "flex items-center gap-2 text-sm text-secondary",
179
+ children: [/* @__PURE__ */ u("input", {
180
+ type: "checkbox",
181
+ checked: j.isActive,
182
+ onChange: (e) => M((t) => ({
183
+ ...t,
184
+ isActive: e.target.checked
185
+ }))
186
+ }), /* @__PURE__ */ u("span", { children: y("notifications.topicIsActive", "Active topic") })]
187
+ }),
188
+ /* @__PURE__ */ d("div", {
189
+ className: "flex items-center gap-3",
190
+ children: [/* @__PURE__ */ d("button", {
191
+ type: "submit",
192
+ className: "inline-flex items-center gap-2 rounded-md bg-accent-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90",
193
+ children: [/* @__PURE__ */ u(s, { size: 16 }), k ? y("notifications.saveTopic", "Save Topic") : y("notifications.createTopicButton", "Create Topic")]
194
+ }), k && /* @__PURE__ */ u("button", {
195
+ type: "button",
196
+ onClick: () => {
197
+ A(null), M({
198
+ name: "",
199
+ slug: "",
200
+ description: "",
201
+ type: "MARKETING",
202
+ isActive: !0
203
+ });
204
+ },
205
+ className: "rounded-md border border-default px-4 py-2 text-sm text-secondary hover:bg-bg-sunken",
206
+ children: y("notifications.cancelTopicEdit", "Cancel")
207
+ })]
208
+ })
209
+ ]
210
+ })
211
+ }), /* @__PURE__ */ d(p, {
212
+ treatment: "plain",
213
+ className: "space-y-4 border-border-seam p-4",
214
+ children: [/* @__PURE__ */ d("div", {
215
+ className: "relative max-w-md",
216
+ children: [/* @__PURE__ */ u(c, {
217
+ size: 16,
218
+ className: "absolute left-3 top-1/2 -translate-y-1/2 text-tertiary"
219
+ }), /* @__PURE__ */ u("input", {
95
220
  type: "text",
96
- value: D.slug,
97
- onChange: (e) => O((t) => ({
98
- ...t,
99
- slug: m(e.target.value)
100
- })),
101
- className: "w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent"
102
- })]
103
- }),
104
- /* @__PURE__ */ d("label", {
105
- className: "block space-y-1 text-sm text-secondary",
106
- children: [/* @__PURE__ */ u("span", { children: h("notifications.topicType", "Type") }), /* @__PURE__ */ u("select", {
107
- value: D.type,
108
- onChange: (e) => O((t) => ({
109
- ...t,
110
- type: e.target.value
111
- })),
112
- className: "w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent",
113
- children: p.map((e) => /* @__PURE__ */ u("option", {
114
- value: e.value,
115
- children: e.label
116
- }, e.value))
117
- })]
118
- }),
119
- /* @__PURE__ */ d("label", {
120
- className: "block space-y-1 text-sm text-secondary",
121
- children: [/* @__PURE__ */ u("span", { children: h("notifications.topicDescription", "Description") }), /* @__PURE__ */ u("textarea", {
122
- value: D.description,
123
- onChange: (e) => O((t) => ({
124
- ...t,
125
- description: e.target.value
126
- })),
127
- rows: 4,
128
- className: "w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent"
221
+ value: D,
222
+ onChange: (e) => O(e.target.value),
223
+ placeholder: y("notifications.searchTopics", "Search topics..."),
224
+ className: "w-full rounded-md border border-default bg-bg-canvas py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent"
129
225
  })]
130
- }),
131
- /* @__PURE__ */ d("label", {
132
- className: "flex items-center gap-2 text-sm text-secondary",
133
- children: [/* @__PURE__ */ u("input", {
134
- type: "checkbox",
135
- checked: D.isActive,
136
- onChange: (e) => O((t) => ({
137
- ...t,
138
- isActive: e.target.checked
139
- }))
140
- }), /* @__PURE__ */ u("span", { children: h("notifications.topicIsActive", "Active topic") })]
141
- }),
142
- /* @__PURE__ */ d("div", {
143
- className: "flex items-center gap-3",
144
- children: [/* @__PURE__ */ d("button", {
145
- type: "submit",
146
- className: "inline-flex items-center gap-2 rounded-md bg-accent-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90",
147
- children: [/* @__PURE__ */ u(s, { size: 16 }), T ? h("notifications.saveTopic", "Save Topic") : h("notifications.createTopicButton", "Create Topic")]
148
- }), T && /* @__PURE__ */ u("button", {
149
- type: "button",
150
- onClick: () => {
151
- E(null), O({
152
- name: "",
153
- slug: "",
154
- description: "",
155
- type: "MARKETING",
156
- isActive: !0
157
- });
158
- },
159
- className: "rounded-md border border-default px-4 py-2 text-sm text-secondary hover:bg-bg-sunken",
160
- children: h("notifications.cancelTopicEdit", "Cancel")
161
- })]
162
- })
163
- ]
164
- }), /* @__PURE__ */ d(f, {
165
- treatment: "plain",
166
- className: "space-y-4 border-border-seam p-4",
167
- children: [/* @__PURE__ */ d("div", {
168
- className: "relative max-w-md",
169
- children: [/* @__PURE__ */ u(c, {
170
- size: 16,
171
- className: "absolute left-3 top-1/2 -translate-y-1/2 text-tertiary"
172
- }), /* @__PURE__ */ u("input", {
173
- type: "text",
174
- value: C,
175
- onChange: (e) => w(e.target.value),
176
- placeholder: h("notifications.searchTopics", "Search topics..."),
177
- className: "w-full rounded-md border border-default bg-bg-canvas py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent"
178
- })]
179
- }), /* @__PURE__ */ u("div", {
180
- className: "space-y-3",
181
- children: y ? /* @__PURE__ */ u("div", {
182
- className: "text-sm text-secondary",
183
- children: h("notifications.loadingTopics", "Loading topics...")
184
- }) : A.length === 0 ? /* @__PURE__ */ u("div", {
185
- className: "text-sm text-secondary",
186
- children: h("notifications.noTopicsFound", "No topics found.")
187
- }) : A.map((e) => /* @__PURE__ */ d("div", {
188
- className: "flex flex-col gap-3 rounded-lg border border-border-seam bg-surface p-4 transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)] sm:flex-row sm:items-start sm:justify-between",
189
- children: [/* @__PURE__ */ d("div", {
190
- className: "space-y-1",
191
- children: [
192
- /* @__PURE__ */ d("div", {
193
- className: "flex flex-wrap items-center gap-2",
194
- children: [
195
- /* @__PURE__ */ u("h3", {
196
- className: "text-sm font-semibold text-primary",
197
- children: e.name
198
- }),
199
- /* @__PURE__ */ u("span", {
200
- className: "rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary",
201
- children: e.slug
202
- }),
203
- /* @__PURE__ */ u("span", {
204
- className: "rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary",
205
- children: e.type
206
- })
207
- ]
208
- }),
209
- e.description && /* @__PURE__ */ u("p", {
210
- className: "text-sm text-secondary",
211
- children: e.description
212
- }),
213
- /* @__PURE__ */ d("p", {
214
- className: "text-xs text-tertiary",
215
- children: [
216
- h("notifications.topicSubscribers", "Subscribers"),
217
- ": ",
218
- e.subscriberCount
219
- ]
220
- })
221
- ]
222
- }), /* @__PURE__ */ d("div", {
223
- className: "flex items-center gap-2",
224
- children: [/* @__PURE__ */ u("button", {
225
- type: "button",
226
- onClick: () => {
227
- E(e.id), O({
228
- name: e.name,
229
- slug: e.slug,
230
- description: e.description || "",
231
- type: e.type,
232
- isActive: e.isActive
233
- });
234
- },
235
- className: "rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-bg-sunken",
236
- children: h("notifications.edit", "Edit")
237
- }), /* @__PURE__ */ d("button", {
238
- type: "button",
239
- onClick: () => S(e.id),
240
- className: "inline-flex items-center gap-2 rounded-md border border-status-error-border px-3 py-2 text-sm text-status-error-text hover:bg-status-error-bg-subtle",
241
- children: [/* @__PURE__ */ u(l, { size: 14 }), h("notifications.delete", "Delete")]
226
+ }), /* @__PURE__ */ u("div", {
227
+ className: "space-y-3",
228
+ children: C ? /* @__PURE__ */ u("div", {
229
+ className: "text-sm text-secondary",
230
+ children: y("notifications.loadingTopics", "Loading topics...")
231
+ }) : P.length === 0 ? /* @__PURE__ */ u(m, {
232
+ illustration: D.trim() ? "empty-search" : "empty-data",
233
+ title: y("notifications.noTopicsFound", "No topics found."),
234
+ description: D.trim() ? y("notifications.adjustSearchOrDateRange", "Try adjusting your filters") : y("notifications.noTopicsYet", "No notification topics have been created yet.")
235
+ }) : P.map((e) => /* @__PURE__ */ d("div", {
236
+ className: "flex flex-col gap-3 rounded-lg border border-border-seam bg-surface p-4 transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)] sm:flex-row sm:items-start sm:justify-between",
237
+ children: [/* @__PURE__ */ d("div", {
238
+ className: "space-y-1",
239
+ children: [
240
+ /* @__PURE__ */ d("div", {
241
+ className: "flex flex-wrap items-center gap-2",
242
+ children: [
243
+ /* @__PURE__ */ u("h3", {
244
+ className: "text-sm font-semibold text-primary",
245
+ children: e.name
246
+ }),
247
+ /* @__PURE__ */ u("span", {
248
+ className: "rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary",
249
+ children: e.slug
250
+ }),
251
+ /* @__PURE__ */ u("span", {
252
+ className: "rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary",
253
+ children: e.type
254
+ })
255
+ ]
256
+ }),
257
+ e.description && /* @__PURE__ */ u("p", {
258
+ className: "text-sm text-secondary",
259
+ children: e.description
260
+ }),
261
+ /* @__PURE__ */ d("p", {
262
+ className: "text-xs text-tertiary",
263
+ children: [
264
+ y("notifications.topicSubscribers", "Subscribers"),
265
+ ": ",
266
+ e.subscriberCount
267
+ ]
268
+ })
269
+ ]
270
+ }), /* @__PURE__ */ d("div", {
271
+ className: "flex items-center gap-2",
272
+ children: [/* @__PURE__ */ u("button", {
273
+ type: "button",
274
+ onClick: () => {
275
+ A(e.id), M({
276
+ name: e.name,
277
+ slug: e.slug,
278
+ description: e.description || "",
279
+ type: e.type,
280
+ isActive: e.isActive
281
+ });
282
+ },
283
+ className: "rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-bg-sunken",
284
+ children: y("notifications.edit", "Edit")
285
+ }), /* @__PURE__ */ d("button", {
286
+ type: "button",
287
+ onClick: () => E(e.id),
288
+ className: "inline-flex items-center gap-2 rounded-md border border-status-error-border px-3 py-2 text-sm text-status-error-text hover:bg-status-error-bg-subtle",
289
+ children: [/* @__PURE__ */ u(l, { size: 14 }), y("notifications.delete", "Delete")]
290
+ })]
242
291
  })]
243
- })]
244
- }, e.id))
292
+ }, e.id))
293
+ })]
245
294
  })]
246
- })]
247
- })]
295
+ })
296
+ ]
248
297
  }) : /* @__PURE__ */ u("div", {
249
298
  className: "p-8 text-center text-text-secondary",
250
- children: h("notifications.noPermissionTopics", "You don't have permission to manage notification topics.")
299
+ children: y("notifications.noPermissionTopics", "You don't have permission to manage notification topics.")
251
300
  });
252
301
  }
253
302
  //#endregion
254
- export { h as NotificationTopicsPage };
303
+ export { y as NotificationTopicsPage };
255
304
 
256
305
  //# sourceMappingURL=NotificationTopicsPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"NotificationTopicsPage.js","names":[],"sources":["../../src/pages/NotificationTopicsPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { Plus, Save, Search, Trash2 } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport { GlassCard } from '@burdenoff/fe-libs/ui';\nimport { useNotificationTopics } from '../hooks';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\n\nconst topicTypeOptions = [\n { value: 'MARKETING', label: 'Marketing' },\n { value: 'TRANSACTIONAL', label: 'Transactional' },\n { value: 'SYSTEM', label: 'System' },\n { value: 'ALERT', label: 'Alert' },\n];\n\nfunction slugify(value: string) {\n return value\n .toLowerCase()\n .trim()\n .replace(/[^a-z0-9\\s-]/g, '')\n .replace(/\\s+/g, '-')\n .replace(/-+/g, '-');\n}\n\nexport function NotificationTopicsPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { topics, isLoading, createTopic, updateTopic, deleteTopic } = useNotificationTopics();\n const [search, setSearch] = useState('');\n const [editingId, setEditingId] = useState<string | null>(null);\n const [form, setForm] = useState({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n\n // Topics live under the `notification` resource type in the backend (see\n // `global-notification-svc/src/modules/notification/schema/mutations.gql`),\n // and create/update/delete all require `notification:create` per the\n // @rbac directive. SUPER_ADMIN bypass is inherited from PermissionProvider.\n const canManage = hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_CREATE);\n\n const filteredTopics = useMemo(() => {\n if (!search.trim()) {\n return topics;\n }\n\n const query = search.toLowerCase();\n return topics.filter(\n (topic) =>\n topic.name.toLowerCase().includes(query) ||\n topic.slug.toLowerCase().includes(query) ||\n topic.description?.toLowerCase().includes(query)\n );\n }, [search, topics]);\n\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!canManage) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionTopics',\n \"You don't have permission to manage notification topics.\"\n )}\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-4 sm:p-6\">\n <div>\n <h1 className=\"text-2xl font-bold text-primary\">\n {tr('notifications.topicsTitle', 'Notification Topics')}\n </h1>\n <p className=\"mt-1 text-sm text-secondary\">\n {tr(\n 'notifications.topicsSubtitle',\n 'Create topics for campaigns so users can subscribe or unsubscribe with precision.'\n )}\n </p>\n </div>\n\n <div className=\"grid gap-6 xl:grid-cols-[380px,1fr]\">\n <form\n className=\"space-y-4 rounded-lg border border-border-seam bg-gloss-card p-4\"\n onSubmit={async (event) => {\n event.preventDefault();\n\n if (!form.name.trim() || !form.slug.trim()) {\n return;\n }\n\n if (editingId) {\n await updateTopic(editingId, form);\n } else {\n await createTopic(form);\n }\n\n setEditingId(null);\n setForm({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n }}\n >\n <div className=\"flex items-center gap-2\">\n <Plus size={18} className=\"text-accent-primary\" />\n <h2 className=\"text-base font-semibold text-primary\">\n {editingId\n ? tr('notifications.editTopic', 'Edit Topic')\n : tr('notifications.createTopic', 'Create Topic')}\n </h2>\n </div>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicName', 'Name')}</span>\n <input\n type=\"text\"\n value={form.name}\n onChange={(event) =>\n setForm((prev) => ({\n ...prev,\n name: event.target.value,\n slug: editingId ? prev.slug : slugify(event.target.value),\n }))\n }\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicSlug', 'Slug')}</span>\n <input\n type=\"text\"\n value={form.slug}\n onChange={(event) =>\n setForm((prev) => ({ ...prev, slug: slugify(event.target.value) }))\n }\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicType', 'Type')}</span>\n <select\n value={form.type}\n onChange={(event) => setForm((prev) => ({ ...prev, type: event.target.value }))}\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n >\n {topicTypeOptions.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicDescription', 'Description')}</span>\n <textarea\n value={form.description}\n onChange={(event) =>\n setForm((prev) => ({ ...prev, description: event.target.value }))\n }\n rows={4}\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"flex items-center gap-2 text-sm text-secondary\">\n <input\n type=\"checkbox\"\n checked={form.isActive}\n onChange={(event) => setForm((prev) => ({ ...prev, isActive: event.target.checked }))}\n />\n <span>{tr('notifications.topicIsActive', 'Active topic')}</span>\n </label>\n\n <div className=\"flex items-center gap-3\">\n <button\n type=\"submit\"\n className=\"inline-flex items-center gap-2 rounded-md bg-accent-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90\"\n >\n <Save size={16} />\n {editingId\n ? tr('notifications.saveTopic', 'Save Topic')\n : tr('notifications.createTopicButton', 'Create Topic')}\n </button>\n\n {editingId && (\n <button\n type=\"button\"\n onClick={() => {\n setEditingId(null);\n setForm({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n }}\n className=\"rounded-md border border-default px-4 py-2 text-sm text-secondary hover:bg-bg-sunken\"\n >\n {tr('notifications.cancelTopicEdit', 'Cancel')}\n </button>\n )}\n </div>\n </form>\n\n <GlassCard treatment=\"plain\" className=\"space-y-4 border-border-seam p-4\">\n <div className=\"relative max-w-md\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n placeholder={tr('notifications.searchTopics', 'Search topics...')}\n className=\"w-full rounded-md border border-default bg-bg-canvas py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </div>\n\n <div className=\"space-y-3\">\n {isLoading ? (\n <div className=\"text-sm text-secondary\">\n {tr('notifications.loadingTopics', 'Loading topics...')}\n </div>\n ) : filteredTopics.length === 0 ? (\n <div className=\"text-sm text-secondary\">\n {tr('notifications.noTopicsFound', 'No topics found.')}\n </div>\n ) : (\n filteredTopics.map((topic) => (\n <div\n key={topic.id}\n className=\"flex flex-col gap-3 rounded-lg border border-border-seam bg-surface p-4 transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)] sm:flex-row sm:items-start sm:justify-between\"\n >\n <div className=\"space-y-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h3 className=\"text-sm font-semibold text-primary\">{topic.name}</h3>\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {topic.slug}\n </span>\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {topic.type}\n </span>\n </div>\n {topic.description && (\n <p className=\"text-sm text-secondary\">{topic.description}</p>\n )}\n <p className=\"text-xs text-tertiary\">\n {tr('notifications.topicSubscribers', 'Subscribers')}: {topic.subscriberCount}\n </p>\n </div>\n\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => {\n setEditingId(topic.id);\n setForm({\n name: topic.name,\n slug: topic.slug,\n description: topic.description || '',\n type: topic.type,\n isActive: topic.isActive,\n });\n }}\n className=\"rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-bg-sunken\"\n >\n {tr('notifications.edit', 'Edit')}\n </button>\n <button\n type=\"button\"\n onClick={() => deleteTopic(topic.id)}\n className=\"inline-flex items-center gap-2 rounded-md border border-status-error-border px-3 py-2 text-sm text-status-error-text hover:bg-status-error-bg-subtle\"\n >\n <Trash2 size={14} />\n {tr('notifications.delete', 'Delete')}\n </button>\n </div>\n </div>\n ))\n )}\n </div>\n </GlassCard>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAQA,IAAM,IAAmB;CACvB;EAAE,OAAO;EAAa,OAAO;EAAa;CAC1C;EAAE,OAAO;EAAiB,OAAO;EAAiB;CAClD;EAAE,OAAO;EAAU,OAAO;EAAU;CACpC;EAAE,OAAO;EAAS,OAAO;EAAS;CACnC;AAED,SAAS,EAAQ,GAAe;AAC9B,QAAO,EACJ,aAAa,CACb,MAAM,CACN,QAAQ,iBAAiB,GAAG,CAC5B,QAAQ,QAAQ,IAAI,CACpB,QAAQ,OAAO,IAAI;;AAGxB,SAAgB,IAAyB;CACvC,IAAM,IAAK,GAAO,EACZ,EAAE,kBAAe,WAAW,MAAuB,GAAgB,EACnE,EAAE,WAAQ,cAAW,gBAAa,gBAAa,mBAAgB,GAAuB,EACtF,CAAC,GAAQ,KAAa,EAAS,GAAG,EAClC,CAAC,GAAW,KAAgB,EAAwB,KAAK,EACzD,CAAC,GAAM,KAAW,EAAS;EAC/B,MAAM;EACN,MAAM;EACN,aAAa;EACb,MAAM;EACN,UAAU;EACX,CAAC,EAMI,IAAY,EAAc,EAAyB,oBAAoB,EAEvE,IAAiB,QAAc;AACnC,MAAI,CAAC,EAAO,MAAM,CAChB,QAAO;EAGT,IAAM,IAAQ,EAAO,aAAa;AAClC,SAAO,EAAO,QACX,MACC,EAAM,KAAK,aAAa,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;QAE/D,kBAAC,KAAD;SAAG,WAAU;mBAAb;UACG,EAAG,kCAAkC,cAAc;UAAC;UAAG,EAAM;UAC5D;;QACA;UAEN,kBAAC,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,UAAD;QACE,MAAK;QACL,eAAe;AAEb,SADA,EAAa,EAAM,GAAG,EACtB,EAAQ;UACN,MAAM,EAAM;UACZ,MAAM,EAAM;UACZ,aAAa,EAAM,eAAe;UAClC,MAAM,EAAM;UACZ,UAAU,EAAM;UACjB,CAAC;;QAEJ,WAAU;kBAET,EAAG,sBAAsB,OAAO;QAC1B,CAAA,EACT,kBAAC,UAAD;QACE,MAAK;QACL,eAAe,EAAY,EAAM,GAAG;QACpC,WAAU;kBAHZ,CAKE,kBAAC,GAAD,EAAQ,MAAM,IAAM,CAAA,EACnB,EAAG,wBAAwB,SAAS,CAC9B;UACL;SACF;QA/CC,EAAM,GA+CP,CACN;KAEA,CAAA,CACI;MACR;KACF;MAvOJ,kBAAC,OAAD;EAAK,WAAU;YACZ,EACC,oCACA,2DACD;EACG,CAAA"}
1
+ {"version":3,"file":"NotificationTopicsPage.js","names":[],"sources":["../../src/pages/NotificationTopicsPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { Plus, Save, Search, Trash2 } from 'lucide-react';\nimport { usePermissions } from '@burdenoff/fe-libs/shared/providers/shell';\nimport {\n EmphasisPanel,\n GlassCard,\n IllustratedEmptyState,\n NextSteps,\n PagePurpose,\n} from '@burdenoff/fe-libs/ui';\nimport { useNotificationTopics } from '../hooks';\nimport { NOTIFICATION_PERMISSIONS } from '../constants/permissions';\nimport { useTr } from '../shared/hooks/useTr';\n\nconst topicTypeOptions = [\n { value: 'MARKETING', label: 'Marketing' },\n { value: 'TRANSACTIONAL', label: 'Transactional' },\n { value: 'SYSTEM', label: 'System' },\n { value: 'ALERT', label: 'Alert' },\n];\n\nfunction slugify(value: string) {\n return value\n .toLowerCase()\n .trim()\n .replace(/[^a-z0-9\\s-]/g, '')\n .replace(/\\s+/g, '-')\n .replace(/-+/g, '-');\n}\n\nexport function NotificationTopicsPage() {\n const tr = useTr();\n const { hasPermission, isLoading: permissionsLoading } = usePermissions();\n const { topics, isLoading, createTopic, updateTopic, deleteTopic } = useNotificationTopics();\n const [search, setSearch] = useState('');\n const [editingId, setEditingId] = useState<string | null>(null);\n const [form, setForm] = useState({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n\n // Topics live under the `notification` resource type in the backend (see\n // `global-notification-svc/src/modules/notification/schema/mutations.gql`),\n // and create/update/delete all require `notification:create` per the\n // @rbac directive. SUPER_ADMIN bypass is inherited from PermissionProvider.\n const canManage = hasPermission(NOTIFICATION_PERMISSIONS.NOTIFICATION_CREATE);\n\n const filteredTopics = useMemo(() => {\n if (!search.trim()) {\n return topics;\n }\n\n const query = search.toLowerCase();\n return topics.filter(\n (topic) =>\n topic.name.toLowerCase().includes(query) ||\n topic.slug.toLowerCase().includes(query) ||\n topic.description?.toLowerCase().includes(query)\n );\n }, [search, topics]);\n\n if (permissionsLoading) {\n return (\n <div className=\"flex h-64 items-center justify-center\">\n <div className=\"h-8 w-8 animate-spin rounded-full border-4 border-primary border-t-transparent\" />\n </div>\n );\n }\n\n if (!canManage) {\n return (\n <div className=\"p-8 text-center text-text-secondary\">\n {tr(\n 'notifications.noPermissionTopics',\n \"You don't have permission to manage notification topics.\"\n )}\n </div>\n );\n }\n\n return (\n <div className=\"space-y-6 p-4 sm:p-6\">\n <div>\n <h1 className=\"text-2xl font-bold text-primary\">\n {tr('notifications.topicsTitle', 'Notification Topics')}\n </h1>\n <p className=\"mt-1 text-sm text-secondary\">\n {tr(\n 'notifications.topicsSubtitle',\n 'Create topics for campaigns so users can subscribe or unsubscribe with precision.'\n )}\n </p>\n </div>\n\n <PagePurpose icon={<Plus size={16} />}>\n {tr(\n 'notifications.topicsPurpose',\n 'Topics group related notifications (e.g. \"Product updates\", \"Billing reminders\", \"Weekly digest\") so people can opt in or out of exactly what they care about. Create a topic here, then target it when sending a campaign and let users manage their own subscriptions in Preferences.'\n )}\n </PagePurpose>\n\n <NextSteps\n storageKey=\"notification-topics\"\n steps={[\n {\n id: 'name-topic',\n label: tr('notifications.topicsNextNameLabel', 'Name your first topic'),\n description: tr(\n 'notifications.topicsNextNameDesc',\n 'Use the form to add a clear topic like \"Product updates\" — the slug is generated for you.'\n ),\n onClick: () => {\n setEditingId(null);\n setForm((prev) => ({ ...prev, name: '', slug: '', type: 'MARKETING' }));\n document\n .getElementById('notification-topic-name')\n ?.scrollIntoView({ behavior: 'smooth', block: 'center' });\n document.getElementById('notification-topic-name')?.focus();\n },\n },\n {\n id: 'set-type',\n label: tr('notifications.topicsNextTypeLabel', 'Pick the right type'),\n description: tr(\n 'notifications.topicsNextTypeDesc',\n 'Marketing topics are opt-in for users; Transactional, System and Alert reach everyone.'\n ),\n onClick: () =>\n document\n .getElementById('notification-topic-type')\n ?.scrollIntoView({ behavior: 'smooth', block: 'center' }),\n },\n {\n id: 'let-subscribe',\n label: tr('notifications.topicsNextSubscribeLabel', 'Let people subscribe'),\n description: tr(\n 'notifications.topicsNextSubscribeDesc',\n 'Once a topic is active, users manage their own opt-ins from the Preferences page.'\n ),\n href: '../preferences',\n },\n ]}\n />\n\n <div className=\"grid gap-6 xl:grid-cols-[380px,1fr]\">\n {/* Single emphasis zone — the create/edit form is the primary action on this page. */}\n <EmphasisPanel className=\"p-4\">\n <form\n className=\"space-y-4\"\n onSubmit={async (event) => {\n event.preventDefault();\n\n if (!form.name.trim() || !form.slug.trim()) {\n return;\n }\n\n if (editingId) {\n await updateTopic(editingId, form);\n } else {\n await createTopic(form);\n }\n\n setEditingId(null);\n setForm({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n }}\n >\n <div className=\"flex items-center gap-2\">\n <Plus size={18} className=\"text-accent-primary\" />\n <h2 className=\"text-base font-semibold text-primary\">\n {editingId\n ? tr('notifications.editTopic', 'Edit Topic')\n : tr('notifications.createTopic', 'Create Topic')}\n </h2>\n </div>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicName', 'Name')}</span>\n <input\n id=\"notification-topic-name\"\n type=\"text\"\n value={form.name}\n onChange={(event) =>\n setForm((prev) => ({\n ...prev,\n name: event.target.value,\n slug: editingId ? prev.slug : slugify(event.target.value),\n }))\n }\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicSlug', 'Slug')}</span>\n <input\n type=\"text\"\n value={form.slug}\n onChange={(event) =>\n setForm((prev) => ({ ...prev, slug: slugify(event.target.value) }))\n }\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicType', 'Type')}</span>\n <select\n id=\"notification-topic-type\"\n value={form.type}\n onChange={(event) => setForm((prev) => ({ ...prev, type: event.target.value }))}\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n >\n {topicTypeOptions.map((option) => (\n <option key={option.value} value={option.value}>\n {option.label}\n </option>\n ))}\n </select>\n </label>\n\n <label className=\"block space-y-1 text-sm text-secondary\">\n <span>{tr('notifications.topicDescription', 'Description')}</span>\n <textarea\n value={form.description}\n onChange={(event) =>\n setForm((prev) => ({ ...prev, description: event.target.value }))\n }\n rows={4}\n className=\"w-full rounded-md border border-default bg-bg-canvas px-3 py-2 text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </label>\n\n <label className=\"flex items-center gap-2 text-sm text-secondary\">\n <input\n type=\"checkbox\"\n checked={form.isActive}\n onChange={(event) => setForm((prev) => ({ ...prev, isActive: event.target.checked }))}\n />\n <span>{tr('notifications.topicIsActive', 'Active topic')}</span>\n </label>\n\n <div className=\"flex items-center gap-3\">\n <button\n type=\"submit\"\n className=\"inline-flex items-center gap-2 rounded-md bg-accent-primary px-4 py-2 text-sm font-medium text-white hover:opacity-90\"\n >\n <Save size={16} />\n {editingId\n ? tr('notifications.saveTopic', 'Save Topic')\n : tr('notifications.createTopicButton', 'Create Topic')}\n </button>\n\n {editingId && (\n <button\n type=\"button\"\n onClick={() => {\n setEditingId(null);\n setForm({\n name: '',\n slug: '',\n description: '',\n type: 'MARKETING',\n isActive: true,\n });\n }}\n className=\"rounded-md border border-default px-4 py-2 text-sm text-secondary hover:bg-bg-sunken\"\n >\n {tr('notifications.cancelTopicEdit', 'Cancel')}\n </button>\n )}\n </div>\n </form>\n </EmphasisPanel>\n\n <GlassCard treatment=\"plain\" className=\"space-y-4 border-border-seam p-4\">\n <div className=\"relative max-w-md\">\n <Search size={16} className=\"absolute left-3 top-1/2 -translate-y-1/2 text-tertiary\" />\n <input\n type=\"text\"\n value={search}\n onChange={(event) => setSearch(event.target.value)}\n placeholder={tr('notifications.searchTopics', 'Search topics...')}\n className=\"w-full rounded-md border border-default bg-bg-canvas py-2 pl-9 pr-4 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-accent\"\n />\n </div>\n\n <div className=\"space-y-3\">\n {isLoading ? (\n <div className=\"text-sm text-secondary\">\n {tr('notifications.loadingTopics', 'Loading topics...')}\n </div>\n ) : filteredTopics.length === 0 ? (\n <IllustratedEmptyState\n illustration={search.trim() ? 'empty-search' : 'empty-data'}\n title={tr('notifications.noTopicsFound', 'No topics found.')}\n description={\n search.trim()\n ? tr('notifications.adjustSearchOrDateRange', 'Try adjusting your filters')\n : tr('notifications.noTopicsYet', 'No notification topics have been created yet.')\n }\n />\n ) : (\n filteredTopics.map((topic) => (\n <div\n key={topic.id}\n className=\"flex flex-col gap-3 rounded-lg border border-border-seam bg-surface p-4 transition-[box-shadow,border-color] duration-200 hover:shadow-[var(--shadow-pop)] sm:flex-row sm:items-start sm:justify-between\"\n >\n <div className=\"space-y-1\">\n <div className=\"flex flex-wrap items-center gap-2\">\n <h3 className=\"text-sm font-semibold text-primary\">{topic.name}</h3>\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {topic.slug}\n </span>\n <span className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-secondary\">\n {topic.type}\n </span>\n </div>\n {topic.description && (\n <p className=\"text-sm text-secondary\">{topic.description}</p>\n )}\n <p className=\"text-xs text-tertiary\">\n {tr('notifications.topicSubscribers', 'Subscribers')}: {topic.subscriberCount}\n </p>\n </div>\n\n <div className=\"flex items-center gap-2\">\n <button\n type=\"button\"\n onClick={() => {\n setEditingId(topic.id);\n setForm({\n name: topic.name,\n slug: topic.slug,\n description: topic.description || '',\n type: topic.type,\n isActive: topic.isActive,\n });\n }}\n className=\"rounded-md border border-default px-3 py-2 text-sm text-secondary hover:bg-bg-sunken\"\n >\n {tr('notifications.edit', 'Edit')}\n </button>\n <button\n type=\"button\"\n onClick={() => deleteTopic(topic.id)}\n className=\"inline-flex items-center gap-2 rounded-md border border-status-error-border px-3 py-2 text-sm text-status-error-text hover:bg-status-error-bg-subtle\"\n >\n <Trash2 size={14} />\n {tr('notifications.delete', 'Delete')}\n </button>\n </div>\n </div>\n ))\n )}\n </div>\n </GlassCard>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAcA,IAAM,IAAmB;CACvB;EAAE,OAAO;EAAa,OAAO;EAAa;CAC1C;EAAE,OAAO;EAAiB,OAAO;EAAiB;CAClD;EAAE,OAAO;EAAU,OAAO;EAAU;CACpC;EAAE,OAAO;EAAS,OAAO;EAAS;CACnC;AAED,SAAS,EAAQ,GAAe;AAC9B,QAAO,EACJ,aAAa,CACb,MAAM,CACN,QAAQ,iBAAiB,GAAG,CAC5B,QAAQ,QAAQ,IAAI,CACpB,QAAQ,OAAO,IAAI;;AAGxB,SAAgB,IAAyB;CACvC,IAAM,IAAK,GAAO,EACZ,EAAE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