@burdenoff/microfe-newsletter 2026.1113.1 → 2026.1119.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/newsletter/AdminNewsletterRoot.js +73 -72
- package/dist/newsletter/AdminNewsletterRoot.js.map +1 -1
- package/dist/newsletter/pages/ABTestingPage.js +34 -34
- package/dist/newsletter/pages/ABTestingPage.js.map +1 -1
- package/dist/newsletter/pages/AnalyticsDashboardPage.js +84 -84
- package/dist/newsletter/pages/AnalyticsDashboardPage.js.map +1 -1
- package/dist/newsletter/pages/CampaignsListPage.js +41 -41
- package/dist/newsletter/pages/CampaignsListPage.js.map +1 -1
- package/dist/newsletter/pages/CompliancePage.js +19 -19
- package/dist/newsletter/pages/CompliancePage.js.map +1 -1
- package/dist/newsletter/pages/SubscribersListPage.js +48 -48
- package/dist/newsletter/pages/SubscribersListPage.js.map +1 -1
- package/dist/newsletter/pages/TemplateEditorPage.js +21 -21
- package/dist/newsletter/pages/TemplateEditorPage.js.map +1 -1
- package/dist/newsletter/pages/TemplateLibraryPage.js +139 -139
- package/dist/newsletter/pages/TemplateLibraryPage.js.map +1 -1
- package/dist/newsletter/pages/WaitlistListPage.js +164 -164
- package/dist/newsletter/pages/WaitlistListPage.js.map +1 -1
- package/package.json +9 -9
|
@@ -9,131 +9,132 @@ import { useSearchParams as c } from "react-router";
|
|
|
9
9
|
import { getActiveContext as l } from "@burdenoff/fe-libs/shared/providers/shell/ProfileStorageManager";
|
|
10
10
|
import { BarChart3 as u, Calendar as d, ClipboardList as f, Layout as p, Package as m, Send as h, ShieldCheck as g, TestTube2 as _, Users as v } from "lucide-react";
|
|
11
11
|
import { jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
12
|
+
import { ThemedSelect as x } from "@burdenoff/fe-libs/ui";
|
|
12
13
|
// src/newsletter/AdminNewsletterRoot.tsx
|
|
13
|
-
var
|
|
14
|
-
let { registerNavItems:
|
|
14
|
+
var S = "productId", C = "newsletter:selected-product-id", w = (w) => {
|
|
15
|
+
let { registerNavItems: T, registerFooterItems: E, basePath: D = "/" } = w, O = r(), [k, A] = c(), { products: j, loading: M, error: N } = e(), P = w.productId && w.productId !== "admin" ? w.productId : void 0, F = k.get(S) || void 0, I = F || P, L = j.find((e) => e.id === I), R = k.get("workspace"), z = (() => {
|
|
15
16
|
try {
|
|
16
17
|
return l()?.workspaceId ?? null;
|
|
17
18
|
} catch {
|
|
18
19
|
return null;
|
|
19
20
|
}
|
|
20
|
-
})(),
|
|
21
|
+
})(), B = R || z;
|
|
21
22
|
i(() => {
|
|
22
|
-
if (
|
|
23
|
-
let e = window.localStorage.getItem(
|
|
23
|
+
if (F || P || typeof window > "u") return;
|
|
24
|
+
let e = window.localStorage.getItem(C);
|
|
24
25
|
if (!e) return;
|
|
25
|
-
let t = new URLSearchParams(
|
|
26
|
-
t.set(
|
|
26
|
+
let t = new URLSearchParams(k);
|
|
27
|
+
t.set(S, e), A(t, { replace: !0 });
|
|
27
28
|
}, [
|
|
28
|
-
N,
|
|
29
29
|
P,
|
|
30
|
-
|
|
31
|
-
k
|
|
30
|
+
F,
|
|
31
|
+
k,
|
|
32
|
+
A
|
|
32
33
|
]), i(() => {
|
|
33
|
-
|
|
34
|
-
}, [
|
|
35
|
-
let
|
|
34
|
+
I && typeof window < "u" && window.localStorage.setItem(C, I);
|
|
35
|
+
}, [I]);
|
|
36
|
+
let V = s("newsletter.scheduler"), H = s("newsletter.ab-testing"), U = s("newsletter.compliance"), W = s("newsletter.waitlist"), G = V ? !!V.value : !1, K = H ? !!H.value : !1, q = U ? !!U.value : !1, J = W ? !!W.value : !1, Y = (e, t) => (e.endsWith("/") ? e.slice(0, -1) : e) + (t.startsWith("/") ? t : `/${t}`);
|
|
36
37
|
i(() => {
|
|
37
|
-
if (!
|
|
38
|
+
if (!T) return;
|
|
38
39
|
let e = [
|
|
39
40
|
{
|
|
40
41
|
id: "admin-newsletter-campaigns",
|
|
41
|
-
label:
|
|
42
|
-
path:
|
|
42
|
+
label: O("newsletter.nav.campaigns", "Campaigns"),
|
|
43
|
+
path: D === "/" ? "/campaigns" : Y(D, "campaigns"),
|
|
43
44
|
icon: /* @__PURE__ */ y(h, { size: 20 }),
|
|
44
45
|
order: 10,
|
|
45
46
|
group: "newsletter"
|
|
46
47
|
},
|
|
47
48
|
{
|
|
48
49
|
id: "admin-newsletter-templates",
|
|
49
|
-
label:
|
|
50
|
-
path:
|
|
50
|
+
label: O("newsletter.nav.templates", "Templates"),
|
|
51
|
+
path: Y(D, "templates"),
|
|
51
52
|
icon: /* @__PURE__ */ y(p, { size: 20 }),
|
|
52
53
|
order: 20,
|
|
53
54
|
group: "newsletter"
|
|
54
55
|
},
|
|
55
56
|
{
|
|
56
57
|
id: "admin-newsletter-subscribers",
|
|
57
|
-
label:
|
|
58
|
-
path:
|
|
58
|
+
label: O("newsletter.nav.subscribers", "Subscribers"),
|
|
59
|
+
path: Y(D, "subscribers"),
|
|
59
60
|
icon: /* @__PURE__ */ y(v, { size: 20 }),
|
|
60
61
|
order: 30,
|
|
61
62
|
group: "newsletter"
|
|
62
63
|
},
|
|
63
|
-
...
|
|
64
|
+
...G ? [{
|
|
64
65
|
id: "admin-newsletter-scheduler",
|
|
65
|
-
label:
|
|
66
|
-
path:
|
|
66
|
+
label: O("newsletter.nav.scheduler", "Scheduler"),
|
|
67
|
+
path: Y(D, "scheduler"),
|
|
67
68
|
icon: /* @__PURE__ */ y(d, { size: 20 }),
|
|
68
69
|
order: 40,
|
|
69
70
|
group: "newsletter"
|
|
70
71
|
}] : [],
|
|
71
|
-
...
|
|
72
|
+
...K ? [{
|
|
72
73
|
id: "admin-newsletter-ab-testing",
|
|
73
|
-
label:
|
|
74
|
-
path:
|
|
74
|
+
label: O("newsletter.nav.abTesting", "A/B Testing"),
|
|
75
|
+
path: Y(D, "ab-testing"),
|
|
75
76
|
icon: /* @__PURE__ */ y(_, { size: 20 }),
|
|
76
77
|
order: 50,
|
|
77
78
|
group: "newsletter"
|
|
78
79
|
}] : [],
|
|
79
80
|
{
|
|
80
81
|
id: "admin-newsletter-analytics",
|
|
81
|
-
label:
|
|
82
|
-
path:
|
|
82
|
+
label: O("newsletter.nav.analytics", "Analytics"),
|
|
83
|
+
path: Y(D, "analytics"),
|
|
83
84
|
icon: /* @__PURE__ */ y(u, { size: 20 }),
|
|
84
85
|
order: 60,
|
|
85
86
|
group: "newsletter"
|
|
86
87
|
},
|
|
87
|
-
...
|
|
88
|
+
...q ? [{
|
|
88
89
|
id: "admin-newsletter-compliance",
|
|
89
|
-
label:
|
|
90
|
-
path:
|
|
90
|
+
label: O("newsletter.nav.compliance", "Compliance"),
|
|
91
|
+
path: Y(D, "compliance"),
|
|
91
92
|
icon: /* @__PURE__ */ y(g, { size: 20 }),
|
|
92
93
|
order: 70,
|
|
93
94
|
group: "newsletter"
|
|
94
95
|
}] : [],
|
|
95
|
-
...
|
|
96
|
+
...J ? [{
|
|
96
97
|
id: "admin-newsletter-waitlist",
|
|
97
|
-
label:
|
|
98
|
-
path:
|
|
98
|
+
label: O("newsletter.nav.waitlist", "Waitlist"),
|
|
99
|
+
path: Y(D, "waitlist"),
|
|
99
100
|
icon: /* @__PURE__ */ y(f, { size: 20 }),
|
|
100
101
|
order: 80,
|
|
101
102
|
group: "newsletter"
|
|
102
103
|
}] : []
|
|
103
104
|
];
|
|
104
|
-
return
|
|
105
|
+
return T(e);
|
|
105
106
|
}, [
|
|
106
|
-
|
|
107
|
-
E,
|
|
107
|
+
T,
|
|
108
108
|
D,
|
|
109
|
-
|
|
109
|
+
O,
|
|
110
110
|
G,
|
|
111
111
|
K,
|
|
112
|
-
q
|
|
112
|
+
q,
|
|
113
|
+
J
|
|
113
114
|
]), i(() => {
|
|
114
|
-
if (!
|
|
115
|
+
if (!E) return;
|
|
115
116
|
let e = [{
|
|
116
117
|
id: "admin-newsletter-status",
|
|
117
|
-
label:
|
|
118
|
+
label: O("newsletter.status.ready", "Newsletter Ready"),
|
|
118
119
|
type: "status",
|
|
119
120
|
order: 10,
|
|
120
121
|
section: "left"
|
|
121
122
|
}];
|
|
122
|
-
return
|
|
123
|
-
}, [
|
|
124
|
-
let
|
|
125
|
-
let t = new URLSearchParams(
|
|
126
|
-
t.set(
|
|
127
|
-
},
|
|
123
|
+
return E(e);
|
|
124
|
+
}, [E, O]);
|
|
125
|
+
let X = (e) => {
|
|
126
|
+
let t = new URLSearchParams(k);
|
|
127
|
+
t.set(S, e), A(t, { replace: !0 });
|
|
128
|
+
}, Z = () => M ? /* @__PURE__ */ y("div", {
|
|
128
129
|
className: "flex h-full items-center justify-center p-6 text-sm text-text-secondary",
|
|
129
|
-
children:
|
|
130
|
-
}) :
|
|
130
|
+
children: O("newsletter.loadingProducts", "Loading products...")
|
|
131
|
+
}) : N ? /* @__PURE__ */ b("div", {
|
|
131
132
|
className: "flex h-full items-center justify-center p-6 text-sm text-status-error-text",
|
|
132
133
|
children: [
|
|
133
|
-
|
|
134
|
+
O("newsletter.failedToLoadProducts", "Failed to load products"),
|
|
134
135
|
":",
|
|
135
136
|
" ",
|
|
136
|
-
|
|
137
|
+
N.message
|
|
137
138
|
]
|
|
138
139
|
}) : /* @__PURE__ */ y("div", {
|
|
139
140
|
className: "flex h-full items-center justify-center p-6",
|
|
@@ -146,16 +147,16 @@ var x = "productId", S = "newsletter:selected-product-id", C = (C) => {
|
|
|
146
147
|
children: /* @__PURE__ */ y(m, { size: 24 })
|
|
147
148
|
}), /* @__PURE__ */ b("div", { children: [/* @__PURE__ */ y("h2", {
|
|
148
149
|
className: "text-xl font-semibold text-text-primary",
|
|
149
|
-
children:
|
|
150
|
+
children: O("newsletter.selectProductScope", "Select a product to manage")
|
|
150
151
|
}), /* @__PURE__ */ y("p", {
|
|
151
152
|
className: "text-sm text-text-secondary",
|
|
152
|
-
children:
|
|
153
|
+
children: O("newsletter.selectProductScopeDescription", "Newsletter management is scoped per product. Choose the product whose subscribers and campaigns you want to manage.")
|
|
153
154
|
})] })]
|
|
154
155
|
}), /* @__PURE__ */ y("div", {
|
|
155
156
|
className: "grid gap-3",
|
|
156
|
-
children:
|
|
157
|
+
children: j.map((e) => /* @__PURE__ */ b("button", {
|
|
157
158
|
type: "button",
|
|
158
|
-
onClick: () =>
|
|
159
|
+
onClick: () => X(e.id),
|
|
159
160
|
className: "flex items-center justify-between rounded-xl border border-border-subtle px-4 py-3 text-left transition-colors hover:bg-accent",
|
|
160
161
|
children: [/* @__PURE__ */ b("div", { children: [/* @__PURE__ */ y("div", {
|
|
161
162
|
className: "font-medium text-text-primary",
|
|
@@ -170,48 +171,48 @@ var x = "productId", S = "newsletter:selected-product-id", C = (C) => {
|
|
|
170
171
|
}, e.id))
|
|
171
172
|
})]
|
|
172
173
|
})
|
|
173
|
-
}),
|
|
174
|
+
}), Q = I && (M || L) ? I : void 0;
|
|
174
175
|
return /* @__PURE__ */ y(a, {
|
|
175
176
|
fallback: /* @__PURE__ */ y("div", {
|
|
176
177
|
className: "p-6 text-center text-text-secondary",
|
|
177
|
-
children:
|
|
178
|
+
children: O("newsletter.errorBoundaryFallback", "Something went wrong loading this module. Please refresh the page.")
|
|
178
179
|
}),
|
|
179
180
|
children: /* @__PURE__ */ y(o, {
|
|
180
|
-
workspaceId:
|
|
181
|
+
workspaceId: B,
|
|
181
182
|
gateway: "global",
|
|
182
183
|
defaultEnabled: !0,
|
|
183
|
-
children:
|
|
184
|
-
...
|
|
185
|
-
productId:
|
|
184
|
+
children: Q ? /* @__PURE__ */ y(t, {
|
|
185
|
+
...w,
|
|
186
|
+
productId: Q,
|
|
186
187
|
children: /* @__PURE__ */ b("div", {
|
|
187
188
|
className: "flex h-full flex-col",
|
|
188
189
|
children: [/* @__PURE__ */ b("div", {
|
|
189
190
|
className: "flex items-center justify-between gap-4 border-b border-border-subtle bg-bg-surface px-6 py-4",
|
|
190
191
|
children: [/* @__PURE__ */ b("div", { children: [/* @__PURE__ */ y("div", {
|
|
191
192
|
className: "text-sm font-medium text-text-primary",
|
|
192
|
-
children:
|
|
193
|
+
children: O("newsletter.activeProductScope", "Active product scope")
|
|
193
194
|
}), /* @__PURE__ */ y("div", {
|
|
194
195
|
className: "text-xs text-text-secondary",
|
|
195
|
-
children:
|
|
196
|
+
children: O("newsletter.activeProductScopeDescription", "Campaigns, subscribers, templates, and compliance data are filtered to the selected product.")
|
|
196
197
|
})] }), /* @__PURE__ */ b("div", {
|
|
197
198
|
className: "flex min-w-0 items-center gap-3",
|
|
198
199
|
children: [
|
|
199
200
|
/* @__PURE__ */ y("span", {
|
|
200
201
|
className: "text-sm text-text-secondary",
|
|
201
|
-
children:
|
|
202
|
+
children: O("newsletter.product", "Product")
|
|
202
203
|
}),
|
|
203
|
-
/* @__PURE__ */ y(
|
|
204
|
-
value:
|
|
205
|
-
onChange: (e) =>
|
|
204
|
+
/* @__PURE__ */ y(x, {
|
|
205
|
+
value: Q,
|
|
206
|
+
onChange: (e) => X(e.target.value),
|
|
206
207
|
className: "min-w-[220px] rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary",
|
|
207
|
-
children:
|
|
208
|
+
children: j.map((e) => /* @__PURE__ */ y("option", {
|
|
208
209
|
value: e.id,
|
|
209
210
|
children: e.name
|
|
210
211
|
}, e.id))
|
|
211
212
|
}),
|
|
212
|
-
|
|
213
|
+
L && /* @__PURE__ */ y("span", {
|
|
213
214
|
className: "truncate text-xs text-text-secondary",
|
|
214
|
-
children:
|
|
215
|
+
children: L.slug
|
|
215
216
|
})
|
|
216
217
|
]
|
|
217
218
|
})]
|
|
@@ -220,10 +221,10 @@ var x = "productId", S = "newsletter:selected-product-id", C = (C) => {
|
|
|
220
221
|
children: /* @__PURE__ */ y(n, {})
|
|
221
222
|
})]
|
|
222
223
|
})
|
|
223
|
-
}) :
|
|
224
|
+
}) : Z()
|
|
224
225
|
})
|
|
225
226
|
});
|
|
226
227
|
};
|
|
227
|
-
export {
|
|
228
|
+
export { w as AdminNewsletterRoot };
|
|
228
229
|
|
|
229
230
|
//# sourceMappingURL=AdminNewsletterRoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AdminNewsletterRoot.js","names":["getStoredActiveContext","NEWSLETTER_PRODUCT_PARAM","NEWSLETTER_PRODUCT_STORAGE_KEY","AdminNewsletterRoot","props","tr","useTr","searchParams","setSearchParams","useSearchParams","loadingProducts","productsError","usePlatformProducts","productIdFromProps","queryProductId","selectedProductId","selectedProduct","products","product","workspaceIdFromUrl","workspaceIdFromStorage","getActiveContext","featureFlagWorkspaceId","useEffect","storedProductId","nextParams","schedulerDetails","useFeatureFlagDetails","abTestingDetails","complianceDetails","waitlistDetails","schedulerEnabled","abTestingEnabled","complianceEnabled","waitlistEnabled","joinPath","base","path","registerNavItems","navItems","basePath","Send","Layout","Users","Calendar","TestTube2","BarChart3","ShieldCheck","ClipboardList","registerFooterItems","footerItems","handleProductChange","nextProductId","renderProductSelector","Package","resolvedProductId","ErrorBoundary","FeatureFlagProvider","NewsletterProvider","event","AdminNewsletterRoutes"],"sources":["../../src/newsletter/AdminNewsletterRoot.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useEffect } from 'react';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport {\n useFeatureFlagDetails,\n FeatureFlagProvider,\n} from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useSearchParams } from 'react-router';\nimport { getActiveContext as getStoredActiveContext } from '@burdenoff/fe-libs/shared/providers/shell/ProfileStorageManager';\nimport {\n Send,\n Layout,\n Users,\n Calendar,\n TestTube2,\n BarChart3,\n ShieldCheck,\n ClipboardList,\n Package,\n} from 'lucide-react';\nimport { usePlatformProducts } from './hooks/useNewsletterOperations';\nimport { NewsletterProvider } from './providers/NewsletterProvider';\nimport type { NavItem, NewsletterRootProps } from './types';\nimport { AdminNewsletterRoutes } from './AdminNewsletterRoutes';\nimport { useTr } from './shared/hooks/useTr';\n\nconst NEWSLETTER_PRODUCT_PARAM = 'productId';\nconst NEWSLETTER_PRODUCT_STORAGE_KEY = 'newsletter:selected-product-id';\n\n/**\n * Admin-facing Root component for the Newsletter microfrontend.\n *\n * This is the full-surface entry point for the newsletter module, intended\n * for the admin-app shell. It exposes every page including CRUD-capable\n * screens (campaign editor, template editor, subscribers, scheduler, A/B\n * testing, compliance, waitlist) in addition to the read-oriented views.\n *\n * Product shells that should only see a limited surface must use\n * `UserNewsletterRoot` instead.\n *\n * **Features**:\n * - Campaign management (create, schedule, send)\n * - Email template editor (visual and code mode)\n * - Subscriber management (import, segment, export)\n * - Campaign scheduling with timezone support\n * - A/B testing for subject lines and content\n * - Campaign analytics and reporting\n * - Compliance management (GDPR, CAN-SPAM, CASL)\n * - Waitlist management (review, approve, reject entries)\n *\n * @example\n * ```tsx\n * import { AdminNewsletterRoot, type NewsletterRootProps } from '@burdenoff/micro-fe/newsletter';\n *\n * function App() {\n * const props: NewsletterRootProps = {\n * basePath: '/newsletter',\n * navigate: (path) => router.push(path),\n * currentUser: { id: '1', email: 'user@example.com', firstName: 'John', lastName: 'Doe' },\n * productId: 'product-123',\n * apiGatewayUrl: 'https://api.example.com/tenant',\n * authToken: 'token',\n * onCampaignSent: (campaign) => console.log('Campaign sent:', campaign),\n * onSubscribersImported: (count) => console.log('Imported:', count),\n * onABTestComplete: (test) => console.log('A/B test complete:', test),\n * registerNavItems: (items) => { return () => {}; },\n * registerFooterItems: (items) => { return () => {}; },\n * };\n *\n * return <AdminNewsletterRoot {...props} />;\n * }\n * ```\n */\nexport const AdminNewsletterRoot: FC<NewsletterRootProps> = (props) => {\n const { registerNavItems, registerFooterItems, basePath = '/' } = props;\n const tr = useTr();\n const [searchParams, setSearchParams] = useSearchParams();\n const { products, loading: loadingProducts, error: productsError } = usePlatformProducts();\n\n const productIdFromProps =\n props.productId && props.productId !== 'admin' ? props.productId : undefined;\n const queryProductId = searchParams.get(NEWSLETTER_PRODUCT_PARAM) || undefined;\n const selectedProductId = queryProductId || productIdFromProps;\n const selectedProduct = products.find((product) => product.id === selectedProductId);\n const workspaceIdFromUrl = searchParams.get('workspace');\n const workspaceIdFromStorage = (() => {\n try {\n return getStoredActiveContext()?.workspaceId ?? null;\n } catch {\n return null;\n }\n })();\n const featureFlagWorkspaceId = workspaceIdFromUrl || workspaceIdFromStorage;\n\n useEffect(() => {\n if (queryProductId || productIdFromProps || typeof window === 'undefined') {\n return;\n }\n\n const storedProductId = window.localStorage.getItem(NEWSLETTER_PRODUCT_STORAGE_KEY);\n if (!storedProductId) {\n return;\n }\n\n const nextParams = new URLSearchParams(searchParams);\n nextParams.set(NEWSLETTER_PRODUCT_PARAM, storedProductId);\n setSearchParams(nextParams, { replace: true });\n }, [productIdFromProps, queryProductId, searchParams, setSearchParams]);\n\n useEffect(() => {\n if (!selectedProductId || typeof window === 'undefined') {\n return;\n }\n\n window.localStorage.setItem(NEWSLETTER_PRODUCT_STORAGE_KEY, selectedProductId);\n }, [selectedProductId]);\n\n // Component-level feature gates. `newsletter.*` flags are declared as\n // unreleased (defaultValue=false). We use `useFeatureFlagDetails` and\n // explicitly fall back to `false` when the flag is absent from the cache,\n // because the provider's global default-allow would otherwise return `true`\n // for unseeded flags — which would defeat the whole point of the unreleased\n // pattern. Once the flag is seeded with defaultValue=false, the normal path\n // returns false. Users opt in via Feature Previews; admins flip the global\n // default.\n const schedulerDetails = useFeatureFlagDetails('newsletter.scheduler');\n const abTestingDetails = useFeatureFlagDetails('newsletter.ab-testing');\n const complianceDetails = useFeatureFlagDetails('newsletter.compliance');\n const waitlistDetails = useFeatureFlagDetails('newsletter.waitlist');\n const schedulerEnabled = schedulerDetails ? Boolean(schedulerDetails.value) : false;\n const abTestingEnabled = abTestingDetails ? Boolean(abTestingDetails.value) : false;\n const complianceEnabled = complianceDetails ? Boolean(complianceDetails.value) : false;\n const waitlistEnabled = waitlistDetails ? Boolean(waitlistDetails.value) : false;\n\n // Helper to join paths correctly, avoiding double slashes\n const joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n };\n\n // Register navigation items with the shell\n useEffect(() => {\n if (!registerNavItems) return;\n\n const navItems: NavItem[] = [\n {\n id: 'admin-newsletter-campaigns',\n label: tr('newsletter.nav.campaigns', 'Campaigns'),\n path: basePath === '/' ? '/campaigns' : joinPath(basePath, 'campaigns'),\n icon: <Send size={20} />,\n order: 10,\n group: 'newsletter',\n },\n {\n id: 'admin-newsletter-templates',\n label: tr('newsletter.nav.templates', 'Templates'),\n path: joinPath(basePath, 'templates'),\n icon: <Layout size={20} />,\n order: 20,\n group: 'newsletter',\n },\n {\n id: 'admin-newsletter-subscribers',\n label: tr('newsletter.nav.subscribers', 'Subscribers'),\n path: joinPath(basePath, 'subscribers'),\n icon: <Users size={20} />,\n order: 30,\n group: 'newsletter',\n },\n ...(schedulerEnabled\n ? [\n {\n id: 'admin-newsletter-scheduler',\n label: tr('newsletter.nav.scheduler', 'Scheduler'),\n path: joinPath(basePath, 'scheduler'),\n icon: <Calendar size={20} />,\n order: 40,\n group: 'newsletter',\n },\n ]\n : []),\n ...(abTestingEnabled\n ? [\n {\n id: 'admin-newsletter-ab-testing',\n label: tr('newsletter.nav.abTesting', 'A/B Testing'),\n path: joinPath(basePath, 'ab-testing'),\n icon: <TestTube2 size={20} />,\n order: 50,\n group: 'newsletter',\n },\n ]\n : []),\n {\n id: 'admin-newsletter-analytics',\n label: tr('newsletter.nav.analytics', 'Analytics'),\n path: joinPath(basePath, 'analytics'),\n icon: <BarChart3 size={20} />,\n order: 60,\n group: 'newsletter',\n },\n ...(complianceEnabled\n ? [\n {\n id: 'admin-newsletter-compliance',\n label: tr('newsletter.nav.compliance', 'Compliance'),\n path: joinPath(basePath, 'compliance'),\n icon: <ShieldCheck size={20} />,\n order: 70,\n group: 'newsletter',\n },\n ]\n : []),\n ...(waitlistEnabled\n ? [\n {\n id: 'admin-newsletter-waitlist',\n label: tr('newsletter.nav.waitlist', 'Waitlist'),\n path: joinPath(basePath, 'waitlist'),\n icon: <ClipboardList size={20} />,\n order: 80,\n group: 'newsletter',\n },\n ]\n : []),\n ];\n\n // Register and get cleanup function\n const cleanup = registerNavItems(navItems);\n\n // Return cleanup function to unregister on unmount\n return cleanup;\n }, [\n registerNavItems,\n basePath,\n tr,\n schedulerEnabled,\n abTestingEnabled,\n complianceEnabled,\n waitlistEnabled,\n ]);\n\n // Register footer items (status indicator in left section)\n useEffect(() => {\n if (!registerFooterItems) return;\n\n const footerItems = [\n {\n id: 'admin-newsletter-status',\n label: tr('newsletter.status.ready', 'Newsletter Ready'),\n type: 'status' as const,\n order: 10,\n section: 'left' as const,\n },\n ];\n\n const cleanup = registerFooterItems(footerItems);\n return cleanup;\n }, [registerFooterItems, tr]);\n\n const handleProductChange = (nextProductId: string) => {\n const nextParams = new URLSearchParams(searchParams);\n nextParams.set(NEWSLETTER_PRODUCT_PARAM, nextProductId);\n setSearchParams(nextParams, { replace: true });\n };\n\n const renderProductSelector = () => {\n if (loadingProducts) {\n return (\n <div className=\"flex h-full items-center justify-center p-6 text-sm text-text-secondary\">\n {tr('newsletter.loadingProducts', 'Loading products...')}\n </div>\n );\n }\n\n if (productsError) {\n return (\n <div className=\"flex h-full items-center justify-center p-6 text-sm text-status-error-text\">\n {tr('newsletter.failedToLoadProducts', 'Failed to load products')}:{' '}\n {productsError.message}\n </div>\n );\n }\n\n return (\n <div className=\"flex h-full items-center justify-center p-6\">\n <div className=\"w-full max-w-xl rounded-2xl border border-border-subtle bg-bg-surface p-8 shadow-sm\">\n <div className=\"mb-6 flex items-center gap-3\">\n <div className=\"rounded-xl bg-action-primary-bg/10 p-3 text-primary\">\n <Package size={24} />\n </div>\n <div>\n <h2 className=\"text-xl font-semibold text-text-primary\">\n {tr('newsletter.selectProductScope', 'Select a product to manage')}\n </h2>\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'newsletter.selectProductScopeDescription',\n 'Newsletter management is scoped per product. Choose the product whose subscribers and campaigns you want to manage.'\n )}\n </p>\n </div>\n </div>\n\n <div className=\"grid gap-3\">\n {products.map((product) => (\n <button\n key={product.id}\n type=\"button\"\n onClick={() => handleProductChange(product.id)}\n className=\"flex items-center justify-between rounded-xl border border-border-subtle px-4 py-3 text-left transition-colors hover:bg-accent\"\n >\n <div>\n <div className=\"font-medium text-text-primary\">{product.name}</div>\n <div className=\"text-xs text-text-secondary\">{product.slug || product.id}</div>\n </div>\n <span className=\"text-xs uppercase tracking-wide text-text-secondary\">\n {product.status || 'ACTIVE'}\n </span>\n </button>\n ))}\n </div>\n </div>\n </div>\n );\n };\n\n const resolvedProductId =\n selectedProductId && (loadingProducts || selectedProduct) ? selectedProductId : undefined;\n\n return (\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n {tr(\n 'newsletter.errorBoundaryFallback',\n 'Something went wrong loading this module. Please refresh the page.'\n )}\n </div>\n }\n >\n <FeatureFlagProvider\n workspaceId={featureFlagWorkspaceId}\n gateway=\"global\"\n defaultEnabled={true}\n >\n {!resolvedProductId ? (\n renderProductSelector()\n ) : (\n <NewsletterProvider {...props} productId={resolvedProductId}>\n <div className=\"flex h-full flex-col\">\n <div className=\"flex items-center justify-between gap-4 border-b border-border-subtle bg-bg-surface px-6 py-4\">\n <div>\n <div className=\"text-sm font-medium text-text-primary\">\n {tr('newsletter.activeProductScope', 'Active product scope')}\n </div>\n <div className=\"text-xs text-text-secondary\">\n {tr(\n 'newsletter.activeProductScopeDescription',\n 'Campaigns, subscribers, templates, and compliance data are filtered to the selected product.'\n )}\n </div>\n </div>\n\n <div className=\"flex min-w-0 items-center gap-3\">\n <span className=\"text-sm text-text-secondary\">\n {tr('newsletter.product', 'Product')}\n </span>\n <select\n value={resolvedProductId}\n onChange={(event) => handleProductChange(event.target.value)}\n className=\"min-w-[220px] rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n {products.map((product) => (\n <option key={product.id} value={product.id}>\n {product.name}\n </option>\n ))}\n </select>\n {selectedProduct && (\n <span className=\"truncate text-xs text-text-secondary\">\n {selectedProduct.slug}\n </span>\n )}\n </div>\n </div>\n\n <div className=\"min-h-0 flex-1\">\n <AdminNewsletterRoutes />\n </div>\n </div>\n </NewsletterProvider>\n )}\n </FeatureFlagProvider>\n </ErrorBoundary>\n );\n};\n"],"mappings":";;;;;;;;;;;;AA0BA,IAAMC,IAA2B,aAC3BC,IAAiC,kCA8C1BC,KAAgD,MAAU;CACrE,IAAM,EAAE,qBAAkB,wBAAqB,cAAW,QAAQC,GAC5DC,IAAKC,EAAM,GACX,CAACC,GAAcC,KAAmBC,EAAgB,GAClD,EAAE,aAAU,SAASC,GAAiB,OAAOC,MAAkBC,EAAoB,GAEnFC,IACJT,EAAM,aAAaA,EAAM,cAAc,UAAUA,EAAM,YAAY,KAAA,GAC/DU,IAAiBP,EAAa,IAAIN,CAAwB,KAAK,KAAA,GAC/Dc,IAAoBD,KAAkBD,GACtCG,IAAkBC,EAAS,MAAM,MAAYC,EAAQ,OAAOH,CAAiB,GAC7EI,IAAqBZ,EAAa,IAAI,WAAW,GACjDa,WAAgC;EACpC,IAAI;GACF,OAAOpB,EAAuB,CAAC,EAAE,eAAe;EAClD,QAAQ;GACN,OAAO;EACT;CACF,EAAA,CAAG,GACGsB,IAAyBH,KAAsBC;CAiBrD,AAfAG,QAAgB;EACd,IAAIT,KAAkBD,KAAsB,OAAO,SAAW,KAC5D;EAGF,IAAMW,IAAkB,OAAO,aAAa,QAAQtB,CAA8B;EAClF,IAAI,CAACsB,GACH;EAGF,IAAMC,IAAa,IAAI,gBAAgBlB,CAAY;EAEnD,AADAkB,EAAW,IAAIxB,GAA0BuB,CAAe,GACxDhB,EAAgBiB,GAAY,EAAE,SAAS,GAAK,CAAC;CAC/C,GAAG;EAACZ;EAAoBC;EAAgBP;EAAcC;CAAe,CAAC,GAEtEe,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RODUCT_STORAGE_KEY","AdminNewsletterRoot","props","tr","useTr","searchParams","setSearchParams","useSearchParams","loadingProducts","productsError","usePlatformProducts","productIdFromProps","queryProductId","selectedProductId","selectedProduct","products","product","workspaceIdFromUrl","workspaceIdFromStorage","getActiveContext","featureFlagWorkspaceId","useEffect","storedProductId","nextParams","schedulerDetails","useFeatureFlagDetails","abTestingDetails","complianceDetails","waitlistDetails","schedulerEnabled","abTestingEnabled","complianceEnabled","waitlistEnabled","joinPath","base","path","registerNavItems","navItems","basePath","Send","Layout","Users","Calendar","TestTube2","BarChart3","ShieldCheck","ClipboardList","registerFooterItems","footerItems","handleProductChange","nextProductId","renderProductSelector","Package","resolvedProductId","ErrorBoundary","FeatureFlagProvider","NewsletterProvider","ThemedSelect","event","AdminNewsletterRoutes"],"sources":["../../src/newsletter/AdminNewsletterRoot.tsx"],"sourcesContent":["import type { FC } from 'react';\nimport { useEffect } from 'react';\nimport { ErrorBoundary } from '@burdenoff/fe-libs/shared/components';\nimport {\n useFeatureFlagDetails,\n FeatureFlagProvider,\n} from '@burdenoff/fe-libs/shared/feature-flags';\nimport { useSearchParams } from 'react-router';\nimport { getActiveContext as getStoredActiveContext } from '@burdenoff/fe-libs/shared/providers/shell/ProfileStorageManager';\nimport {\n Send,\n Layout,\n Users,\n Calendar,\n TestTube2,\n BarChart3,\n ShieldCheck,\n ClipboardList,\n Package,\n} from 'lucide-react';\nimport { usePlatformProducts } from './hooks/useNewsletterOperations';\nimport { NewsletterProvider } from './providers/NewsletterProvider';\nimport type { NavItem, NewsletterRootProps } from './types';\nimport { AdminNewsletterRoutes } from './AdminNewsletterRoutes';\nimport { useTr } from './shared/hooks/useTr';\nimport { ThemedSelect } from '@burdenoff/fe-libs/ui';\n\nconst NEWSLETTER_PRODUCT_PARAM = 'productId';\nconst NEWSLETTER_PRODUCT_STORAGE_KEY = 'newsletter:selected-product-id';\n\n/**\n * Admin-facing Root component for the Newsletter microfrontend.\n *\n * This is the full-surface entry point for the newsletter module, intended\n * for the admin-app shell. It exposes every page including CRUD-capable\n * screens (campaign editor, template editor, subscribers, scheduler, A/B\n * testing, compliance, waitlist) in addition to the read-oriented views.\n *\n * Product shells that should only see a limited surface must use\n * `UserNewsletterRoot` instead.\n *\n * **Features**:\n * - Campaign management (create, schedule, send)\n * - Email template editor (visual and code mode)\n * - Subscriber management (import, segment, export)\n * - Campaign scheduling with timezone support\n * - A/B testing for subject lines and content\n * - Campaign analytics and reporting\n * - Compliance management (GDPR, CAN-SPAM, CASL)\n * - Waitlist management (review, approve, reject entries)\n *\n * @example\n * ```tsx\n * import { AdminNewsletterRoot, type NewsletterRootProps } from '@burdenoff/micro-fe/newsletter';\n *\n * function App() {\n * const props: NewsletterRootProps = {\n * basePath: '/newsletter',\n * navigate: (path) => router.push(path),\n * currentUser: { id: '1', email: 'user@example.com', firstName: 'John', lastName: 'Doe' },\n * productId: 'product-123',\n * apiGatewayUrl: 'https://api.example.com/tenant',\n * authToken: 'token',\n * onCampaignSent: (campaign) => console.log('Campaign sent:', campaign),\n * onSubscribersImported: (count) => console.log('Imported:', count),\n * onABTestComplete: (test) => console.log('A/B test complete:', test),\n * registerNavItems: (items) => { return () => {}; },\n * registerFooterItems: (items) => { return () => {}; },\n * };\n *\n * return <AdminNewsletterRoot {...props} />;\n * }\n * ```\n */\nexport const AdminNewsletterRoot: FC<NewsletterRootProps> = (props) => {\n const { registerNavItems, registerFooterItems, basePath = '/' } = props;\n const tr = useTr();\n const [searchParams, setSearchParams] = useSearchParams();\n const { products, loading: loadingProducts, error: productsError } = usePlatformProducts();\n\n const productIdFromProps =\n props.productId && props.productId !== 'admin' ? props.productId : undefined;\n const queryProductId = searchParams.get(NEWSLETTER_PRODUCT_PARAM) || undefined;\n const selectedProductId = queryProductId || productIdFromProps;\n const selectedProduct = products.find((product) => product.id === selectedProductId);\n const workspaceIdFromUrl = searchParams.get('workspace');\n const workspaceIdFromStorage = (() => {\n try {\n return getStoredActiveContext()?.workspaceId ?? null;\n } catch {\n return null;\n }\n })();\n const featureFlagWorkspaceId = workspaceIdFromUrl || workspaceIdFromStorage;\n\n useEffect(() => {\n if (queryProductId || productIdFromProps || typeof window === 'undefined') {\n return;\n }\n\n const storedProductId = window.localStorage.getItem(NEWSLETTER_PRODUCT_STORAGE_KEY);\n if (!storedProductId) {\n return;\n }\n\n const nextParams = new URLSearchParams(searchParams);\n nextParams.set(NEWSLETTER_PRODUCT_PARAM, storedProductId);\n setSearchParams(nextParams, { replace: true });\n }, [productIdFromProps, queryProductId, searchParams, setSearchParams]);\n\n useEffect(() => {\n if (!selectedProductId || typeof window === 'undefined') {\n return;\n }\n\n window.localStorage.setItem(NEWSLETTER_PRODUCT_STORAGE_KEY, selectedProductId);\n }, [selectedProductId]);\n\n // Component-level feature gates. `newsletter.*` flags are declared as\n // unreleased (defaultValue=false). We use `useFeatureFlagDetails` and\n // explicitly fall back to `false` when the flag is absent from the cache,\n // because the provider's global default-allow would otherwise return `true`\n // for unseeded flags — which would defeat the whole point of the unreleased\n // pattern. Once the flag is seeded with defaultValue=false, the normal path\n // returns false. Users opt in via Feature Previews; admins flip the global\n // default.\n const schedulerDetails = useFeatureFlagDetails('newsletter.scheduler');\n const abTestingDetails = useFeatureFlagDetails('newsletter.ab-testing');\n const complianceDetails = useFeatureFlagDetails('newsletter.compliance');\n const waitlistDetails = useFeatureFlagDetails('newsletter.waitlist');\n const schedulerEnabled = schedulerDetails ? Boolean(schedulerDetails.value) : false;\n const abTestingEnabled = abTestingDetails ? Boolean(abTestingDetails.value) : false;\n const complianceEnabled = complianceDetails ? Boolean(complianceDetails.value) : false;\n const waitlistEnabled = waitlistDetails ? Boolean(waitlistDetails.value) : false;\n\n // Helper to join paths correctly, avoiding double slashes\n const joinPath = (base: string, path: string): string => {\n const cleanBase = base.endsWith('/') ? base.slice(0, -1) : base;\n const cleanPath = path.startsWith('/') ? path : `/${path}`;\n return cleanBase + cleanPath;\n };\n\n // Register navigation items with the shell\n useEffect(() => {\n if (!registerNavItems) return;\n\n const navItems: NavItem[] = [\n {\n id: 'admin-newsletter-campaigns',\n label: tr('newsletter.nav.campaigns', 'Campaigns'),\n path: basePath === '/' ? '/campaigns' : joinPath(basePath, 'campaigns'),\n icon: <Send size={20} />,\n order: 10,\n group: 'newsletter',\n },\n {\n id: 'admin-newsletter-templates',\n label: tr('newsletter.nav.templates', 'Templates'),\n path: joinPath(basePath, 'templates'),\n icon: <Layout size={20} />,\n order: 20,\n group: 'newsletter',\n },\n {\n id: 'admin-newsletter-subscribers',\n label: tr('newsletter.nav.subscribers', 'Subscribers'),\n path: joinPath(basePath, 'subscribers'),\n icon: <Users size={20} />,\n order: 30,\n group: 'newsletter',\n },\n ...(schedulerEnabled\n ? [\n {\n id: 'admin-newsletter-scheduler',\n label: tr('newsletter.nav.scheduler', 'Scheduler'),\n path: joinPath(basePath, 'scheduler'),\n icon: <Calendar size={20} />,\n order: 40,\n group: 'newsletter',\n },\n ]\n : []),\n ...(abTestingEnabled\n ? [\n {\n id: 'admin-newsletter-ab-testing',\n label: tr('newsletter.nav.abTesting', 'A/B Testing'),\n path: joinPath(basePath, 'ab-testing'),\n icon: <TestTube2 size={20} />,\n order: 50,\n group: 'newsletter',\n },\n ]\n : []),\n {\n id: 'admin-newsletter-analytics',\n label: tr('newsletter.nav.analytics', 'Analytics'),\n path: joinPath(basePath, 'analytics'),\n icon: <BarChart3 size={20} />,\n order: 60,\n group: 'newsletter',\n },\n ...(complianceEnabled\n ? [\n {\n id: 'admin-newsletter-compliance',\n label: tr('newsletter.nav.compliance', 'Compliance'),\n path: joinPath(basePath, 'compliance'),\n icon: <ShieldCheck size={20} />,\n order: 70,\n group: 'newsletter',\n },\n ]\n : []),\n ...(waitlistEnabled\n ? [\n {\n id: 'admin-newsletter-waitlist',\n label: tr('newsletter.nav.waitlist', 'Waitlist'),\n path: joinPath(basePath, 'waitlist'),\n icon: <ClipboardList size={20} />,\n order: 80,\n group: 'newsletter',\n },\n ]\n : []),\n ];\n\n // Register and get cleanup function\n const cleanup = registerNavItems(navItems);\n\n // Return cleanup function to unregister on unmount\n return cleanup;\n }, [\n registerNavItems,\n basePath,\n tr,\n schedulerEnabled,\n abTestingEnabled,\n complianceEnabled,\n waitlistEnabled,\n ]);\n\n // Register footer items (status indicator in left section)\n useEffect(() => {\n if (!registerFooterItems) return;\n\n const footerItems = [\n {\n id: 'admin-newsletter-status',\n label: tr('newsletter.status.ready', 'Newsletter Ready'),\n type: 'status' as const,\n order: 10,\n section: 'left' as const,\n },\n ];\n\n const cleanup = registerFooterItems(footerItems);\n return cleanup;\n }, [registerFooterItems, tr]);\n\n const handleProductChange = (nextProductId: string) => {\n const nextParams = new URLSearchParams(searchParams);\n nextParams.set(NEWSLETTER_PRODUCT_PARAM, nextProductId);\n setSearchParams(nextParams, { replace: true });\n };\n\n const renderProductSelector = () => {\n if (loadingProducts) {\n return (\n <div className=\"flex h-full items-center justify-center p-6 text-sm text-text-secondary\">\n {tr('newsletter.loadingProducts', 'Loading products...')}\n </div>\n );\n }\n\n if (productsError) {\n return (\n <div className=\"flex h-full items-center justify-center p-6 text-sm text-status-error-text\">\n {tr('newsletter.failedToLoadProducts', 'Failed to load products')}:{' '}\n {productsError.message}\n </div>\n );\n }\n\n return (\n <div className=\"flex h-full items-center justify-center p-6\">\n <div className=\"w-full max-w-xl rounded-2xl border border-border-subtle bg-bg-surface p-8 shadow-sm\">\n <div className=\"mb-6 flex items-center gap-3\">\n <div className=\"rounded-xl bg-action-primary-bg/10 p-3 text-primary\">\n <Package size={24} />\n </div>\n <div>\n <h2 className=\"text-xl font-semibold text-text-primary\">\n {tr('newsletter.selectProductScope', 'Select a product to manage')}\n </h2>\n <p className=\"text-sm text-text-secondary\">\n {tr(\n 'newsletter.selectProductScopeDescription',\n 'Newsletter management is scoped per product. Choose the product whose subscribers and campaigns you want to manage.'\n )}\n </p>\n </div>\n </div>\n\n <div className=\"grid gap-3\">\n {products.map((product) => (\n <button\n key={product.id}\n type=\"button\"\n onClick={() => handleProductChange(product.id)}\n className=\"flex items-center justify-between rounded-xl border border-border-subtle px-4 py-3 text-left transition-colors hover:bg-accent\"\n >\n <div>\n <div className=\"font-medium text-text-primary\">{product.name}</div>\n <div className=\"text-xs text-text-secondary\">{product.slug || product.id}</div>\n </div>\n <span className=\"text-xs uppercase tracking-wide text-text-secondary\">\n {product.status || 'ACTIVE'}\n </span>\n </button>\n ))}\n </div>\n </div>\n </div>\n );\n };\n\n const resolvedProductId =\n selectedProductId && (loadingProducts || selectedProduct) ? selectedProductId : undefined;\n\n return (\n <ErrorBoundary\n fallback={\n <div className=\"p-6 text-center text-text-secondary\">\n {tr(\n 'newsletter.errorBoundaryFallback',\n 'Something went wrong loading this module. Please refresh the page.'\n )}\n </div>\n }\n >\n <FeatureFlagProvider\n workspaceId={featureFlagWorkspaceId}\n gateway=\"global\"\n defaultEnabled={true}\n >\n {!resolvedProductId ? (\n renderProductSelector()\n ) : (\n <NewsletterProvider {...props} productId={resolvedProductId}>\n <div className=\"flex h-full flex-col\">\n <div className=\"flex items-center justify-between gap-4 border-b border-border-subtle bg-bg-surface px-6 py-4\">\n <div>\n <div className=\"text-sm font-medium text-text-primary\">\n {tr('newsletter.activeProductScope', 'Active product scope')}\n </div>\n <div className=\"text-xs text-text-secondary\">\n {tr(\n 'newsletter.activeProductScopeDescription',\n 'Campaigns, subscribers, templates, and compliance data are filtered to the selected product.'\n )}\n </div>\n </div>\n\n <div className=\"flex min-w-0 items-center gap-3\">\n <span className=\"text-sm text-text-secondary\">\n {tr('newsletter.product', 'Product')}\n </span>\n <ThemedSelect\n value={resolvedProductId}\n onChange={(event) => handleProductChange(event.target.value)}\n className=\"min-w-[220px] rounded-lg border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary\"\n >\n {products.map((product) => (\n <option key={product.id} value={product.id}>\n {product.name}\n </option>\n ))}\n </ThemedSelect>\n {selectedProduct && (\n <span className=\"truncate text-xs text-text-secondary\">\n {selectedProduct.slug}\n </span>\n )}\n </div>\n </div>\n\n <div className=\"min-h-0 flex-1\">\n <AdminNewsletterRoutes />\n </div>\n </div>\n </NewsletterProvider>\n )}\n </FeatureFlagProvider>\n </ErrorBoundary>\n );\n};\n"],"mappings":";;;;;;;;;;;;;AA2BA,IAAMC,IAA2B,aAC3BC,IAAiC,kCA8C1BC,KAAgD,MAAU;CACrE,IAAM,EAAE,qBAAkB,wBAAqB,cAAW,QAAQC,GAC5DC,IAAKC,EAAM,GACX,CAACC,GAAcC,KAAmBC,EAAgB,GAClD,EAAE,aAAU,SAASC,GAAiB,OAAOC,MAAkBC,EAAoB,GAEnFC,IACJT,EAAM,aAAaA,EAAM,cAAc,UAAUA,EAAM,YAAY,KAAA,GAC/DU,IAAiBP,EAAa,IAAIN,CAAwB,KAAK,KAAA,GAC/Dc,IAAoBD,KAAkBD,GACtCG,IAAkBC,EAAS,MAAM,MAAYC,EAAQ,OAAOH,CAAiB,GAC7EI,IAAqBZ,EAAa,IAAI,WAAW,GACjDa,WAAgC;EACpC,IAAI;GACF,OAAOpB,EAAuB,CAAC,EAAE,eAAe;EAClD,QAAQ;GACN,OAAO;EACT;CACF,EAAA,CAAG,GACGsB,IAAyBH,KAAsBC;CAiBrD,AAfAG,QAAgB;EACd,IAAIT,KAAkBD,KAAsB,OAAO,SAAW,KAC5D;EAGF,IAAMW,IAAkB,OAAO,aAAa,QAAQtB,CAA8B;EAClF,IAAI,CAACsB,GACH;EAGF,IAAMC,IAAa,IAAI,gBAAgBlB,CAAY;EAEnD,AADAkB,EAAW,IAAIxB,GAA0BuB,CAAe,GACxDhB,EAAgBiB,GAAY,EAAE,SAAS,GAAK,CAAC;CAC/C,GAAG;EAACZ;EAAoBC;EAAgBP;EAAcC;CAAe,CAAC,GAEtEe,QAAgB;EACd,AAAKR,KAAqB,OAAO,SAAW,OAI5C,OAAO,aAAa,QAAQb,GAAgCa,CAAiB;CAC/E,GAAG,CAACA,CAAiB,CAAC;CAUtB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oEACF;EACG,CAAA;EAGP,UAAA,kBAACoD,GAAD;GACE,aAAanC;GACb,SAAQ;GACR,gBAAgB;GAEf,UAACiC,IAGA,kBAACG,GAAD;IAAoB,GAAItD;IAAO,WAAWmD;IACxC,UAAA,kBAAC,OAAD;KAAK,WAAU;KAAf,UAAA,CACE,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,OAAD;OAAK,WAAU;OACZ,UAAAlD,EAAG,iCAAiC,sBAAsB;MACxD,CAAA,GACL,kBAAC,OAAD;OAAK,WAAU;OACZ,UAAAA,EACC,4CACA,8FACF;MACG,CAAA,CACF,EAAA,CAAA,GAEL,kBAAC,OAAD;OAAK,WAAU;OAAf,UAAA;QACE,kBAAC,QAAD;SAAM,WAAU;SACb,UAAAA,EAAG,sBAAsB,SAAS;QAC/B,CAAA;QACN,kBAACsD,GAAD;SACE,OAAOJ;SACP,WAAW,MAAUJ,EAAoBS,EAAM,OAAO,KAAK;SAC3D,WAAU;SAET,UAAA3C,EAAS,KAAK,MACb,kBAAC,UAAD;UAAyB,OAAOC,EAAQ;UACrC,UAAAA,EAAQ;SACH,GAFKA,EAAQ,EAEb,CACT;QACW,CAAA;QACbF,KACC,kBAAC,QAAD;SAAM,WAAU;SACb,UAAAA,EAAgB;QACb,CAAA;OAEL;MACF,CAAA,CAAA;KAEL,CAAA,GAAA,kBAAC,OAAD;MAAK,WAAU;MACb,UAAA,kBAAC6C,GAAD,CAAwB,CAAA;KACrB,CAAA,CACF;;GACa,CAAA,IA5CpBR,EAAsB;EA8CL,CAAA;CACR,CAAA;AAEnB"}
|
|
@@ -8,25 +8,25 @@ import { useNavigate as l, useParams as u } from "react-router";
|
|
|
8
8
|
import { AlertCircle as d, ArrowLeft as f, BarChart3 as p, CheckCircle as m, ChevronRight as h, Clock as g, Loader2 as _, Mail as v, MousePointer as y, Play as b, Plus as x, RefreshCw as S, Trash2 as C, Trophy as w, Users as T, X as E } from "lucide-react";
|
|
9
9
|
import { usePermissions as D } from "@burdenoff/fe-libs/shared/providers/shell";
|
|
10
10
|
import { Fragment as O, jsx as k, jsxs as A } from "react/jsx-runtime";
|
|
11
|
-
import { AuroraBackground as j, Button as M, CTAOverflowMenu as N, EmphasisPanel as P, GlassCard as F, GradientText as I, IllustratedEmptyState as L, NextSteps as R, PagePurpose as z } from "@burdenoff/fe-libs/ui";
|
|
11
|
+
import { AuroraBackground as j, Button as M, CTAOverflowMenu as N, EmphasisPanel as P, GlassCard as F, GradientText as I, IllustratedEmptyState as L, NextSteps as R, PagePurpose as z, ThemedSelect as B } from "@burdenoff/fe-libs/ui";
|
|
12
12
|
// src/newsletter/pages/ABTestingPage.tsx
|
|
13
|
-
function
|
|
14
|
-
let { testId: t } = u(), n = l(), { productId: r } = e(), { hasPermission: f, isLoading: p, permissions: b } = D(), C = a(), [w, E] = s(!1), P = !(Array.isArray(b) ? b : b?.permissionStrings)?.some?.((e) => e.startsWith("tenantmodule-newsletter:campaigns:")) || f(o.CAMPAIGN_CREATE), [F, R] = s(null), [
|
|
13
|
+
function V() {
|
|
14
|
+
let { testId: t } = u(), n = l(), { productId: r } = e(), { hasPermission: f, isLoading: p, permissions: b } = D(), C = a(), [w, E] = s(!1), P = !(Array.isArray(b) ? b : b?.permissionStrings)?.some?.((e) => e.startsWith("tenantmodule-newsletter:campaigns:")) || f(o.CAMPAIGN_CREATE), [F, R] = s(null), [V, W] = s("ALL"), { newsletters: G, loading: K, error: q, refetch: J } = i({ platformProductId: r }, 50), Y = G.filter((e) => e.status === "SENT" || e.status === "DRAFT" || e.status === "SCHEDULED"), X = (e, t) => {
|
|
15
15
|
R({
|
|
16
16
|
type: e,
|
|
17
17
|
message: t
|
|
18
18
|
}), setTimeout(() => R(null), 5e3);
|
|
19
|
-
}, X = () => {
|
|
20
|
-
E(!0);
|
|
21
19
|
}, Z = () => {
|
|
20
|
+
E(!0);
|
|
21
|
+
}, Q = () => {
|
|
22
22
|
n("../ab-testing");
|
|
23
|
-
},
|
|
23
|
+
}, $ = (e) => {
|
|
24
24
|
n(e);
|
|
25
|
-
},
|
|
25
|
+
}, ee = (e) => new Date(e).toLocaleDateString("en-US", {
|
|
26
26
|
month: "short",
|
|
27
27
|
day: "numeric",
|
|
28
28
|
year: "numeric"
|
|
29
|
-
}),
|
|
29
|
+
}), te = (e) => {
|
|
30
30
|
let t = {
|
|
31
31
|
DRAFT: {
|
|
32
32
|
color: "bg-bg-sunken text-text-secondary",
|
|
@@ -67,10 +67,10 @@ function B() {
|
|
|
67
67
|
size: 24
|
|
68
68
|
}), /* @__PURE__ */ k("span", { children: C("newsletterCommon.loading", "Loading...") })]
|
|
69
69
|
})
|
|
70
|
-
}) : !p && b && b.permissionStrings?.length > 0 && !P ? /* @__PURE__ */ k(c, {}) : t ? /* @__PURE__ */ k(
|
|
70
|
+
}) : !p && b && b.permissionStrings?.length > 0 && !P ? /* @__PURE__ */ k(c, {}) : t ? /* @__PURE__ */ k(H, {
|
|
71
71
|
testId: t,
|
|
72
|
-
onBack:
|
|
73
|
-
showNotification:
|
|
72
|
+
onBack: Q,
|
|
73
|
+
showNotification: X
|
|
74
74
|
}) : /* @__PURE__ */ A("div", {
|
|
75
75
|
className: "flex flex-col h-full",
|
|
76
76
|
children: [
|
|
@@ -92,17 +92,17 @@ function B() {
|
|
|
92
92
|
/* @__PURE__ */ k(N, {
|
|
93
93
|
primary: P ? {
|
|
94
94
|
label: C("newsletter.createABTest", "Create A/B Test"),
|
|
95
|
-
onSelect:
|
|
95
|
+
onSelect: Z,
|
|
96
96
|
icon: /* @__PURE__ */ k(x, { size: 18 })
|
|
97
97
|
} : void 0,
|
|
98
98
|
actions: [{
|
|
99
99
|
label: C("newsletter.refresh", "Refresh"),
|
|
100
100
|
onSelect: () => {
|
|
101
|
-
|
|
101
|
+
J();
|
|
102
102
|
},
|
|
103
103
|
icon: /* @__PURE__ */ k(S, {
|
|
104
104
|
size: 16,
|
|
105
|
-
className:
|
|
105
|
+
className: K ? "animate-spin" : ""
|
|
106
106
|
})
|
|
107
107
|
}]
|
|
108
108
|
})
|
|
@@ -114,9 +114,9 @@ function B() {
|
|
|
114
114
|
}),
|
|
115
115
|
/* @__PURE__ */ k("div", {
|
|
116
116
|
className: "flex items-center gap-4 p-6 border-b border-border-seam",
|
|
117
|
-
children: /* @__PURE__ */ A(
|
|
118
|
-
value:
|
|
119
|
-
onChange: (e) =>
|
|
117
|
+
children: /* @__PURE__ */ A(B, {
|
|
118
|
+
value: V,
|
|
119
|
+
onChange: (e) => W(e.target.value),
|
|
120
120
|
className: "px-4 py-2 border border-border-seam rounded-lg bg-bg-surface focus:ring-2 focus:ring-primary/50 focus:border-transparent scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary",
|
|
121
121
|
children: [
|
|
122
122
|
/* @__PURE__ */ k("option", {
|
|
@@ -144,19 +144,19 @@ function B() {
|
|
|
144
144
|
}),
|
|
145
145
|
/* @__PURE__ */ k("div", {
|
|
146
146
|
className: "flex-1 overflow-auto p-6",
|
|
147
|
-
children:
|
|
147
|
+
children: q ? /* @__PURE__ */ k("div", {
|
|
148
148
|
className: "flex items-center justify-center h-full",
|
|
149
149
|
children: /* @__PURE__ */ k(L, {
|
|
150
150
|
illustration: "empty-generic",
|
|
151
151
|
title: C("newsletter.failedLoadABTests", "Failed to load A/B tests"),
|
|
152
|
-
description:
|
|
152
|
+
description: q.message,
|
|
153
153
|
action: /* @__PURE__ */ k(M, {
|
|
154
154
|
type: "button",
|
|
155
|
-
onClick: () =>
|
|
155
|
+
onClick: () => J(),
|
|
156
156
|
children: C("newsletterCommon.tryAgain", "Try Again")
|
|
157
157
|
})
|
|
158
158
|
})
|
|
159
|
-
}) :
|
|
159
|
+
}) : K && Y.length === 0 ? /* @__PURE__ */ k("div", {
|
|
160
160
|
className: "flex items-center justify-center h-full",
|
|
161
161
|
children: /* @__PURE__ */ A("div", {
|
|
162
162
|
className: "flex items-center gap-2 text-text-secondary",
|
|
@@ -165,7 +165,7 @@ function B() {
|
|
|
165
165
|
size: 24
|
|
166
166
|
}), /* @__PURE__ */ k("span", { children: C("newsletter.loadingABTests", "Loading A/B tests...") })]
|
|
167
167
|
})
|
|
168
|
-
}) :
|
|
168
|
+
}) : Y.length === 0 ? /* @__PURE__ */ k("div", {
|
|
169
169
|
className: "flex items-center justify-center h-full",
|
|
170
170
|
children: /* @__PURE__ */ k(L, {
|
|
171
171
|
illustration: "empty-data",
|
|
@@ -173,16 +173,16 @@ function B() {
|
|
|
173
173
|
description: C("newsletter.noABTestsDescription", "Create A/B tests to compare different subject lines, content, or send times and optimize your campaign performance."),
|
|
174
174
|
action: P ? /* @__PURE__ */ A(M, {
|
|
175
175
|
type: "button",
|
|
176
|
-
onClick:
|
|
176
|
+
onClick: Z,
|
|
177
177
|
className: "gap-2",
|
|
178
178
|
children: [/* @__PURE__ */ k(x, { size: 18 }), C("newsletter.createFirstABTest", "Create Your First A/B Test")]
|
|
179
179
|
}) : void 0
|
|
180
180
|
})
|
|
181
181
|
}) : /* @__PURE__ */ k("div", {
|
|
182
182
|
className: "space-y-4",
|
|
183
|
-
children:
|
|
183
|
+
children: Y.map((e) => /* @__PURE__ */ k("button", {
|
|
184
184
|
type: "button",
|
|
185
|
-
onClick: () =>
|
|
185
|
+
onClick: () => $(e.id),
|
|
186
186
|
className: "border border-border-seam rounded-card p-4 bg-gloss-card hover:shadow-pop hover:border-border-strong transition-[box-shadow,border-color] cursor-pointer text-left w-full",
|
|
187
187
|
children: /* @__PURE__ */ A("div", {
|
|
188
188
|
className: "flex items-start justify-between",
|
|
@@ -194,7 +194,7 @@ function B() {
|
|
|
194
194
|
children: [/* @__PURE__ */ k("h3", {
|
|
195
195
|
className: "font-medium text-text-primary",
|
|
196
196
|
children: e.title
|
|
197
|
-
}),
|
|
197
|
+
}), te(e.status)]
|
|
198
198
|
}),
|
|
199
199
|
/* @__PURE__ */ A("p", {
|
|
200
200
|
className: "text-sm text-text-secondary mb-3",
|
|
@@ -235,7 +235,7 @@ function B() {
|
|
|
235
235
|
})] }),
|
|
236
236
|
/* @__PURE__ */ A("div", {
|
|
237
237
|
className: "flex items-center gap-2 text-text-secondary",
|
|
238
|
-
children: [/* @__PURE__ */ k(g, { size: 14 }), /* @__PURE__ */ k("span", { children:
|
|
238
|
+
children: [/* @__PURE__ */ k(g, { size: 14 }), /* @__PURE__ */ k("span", { children: ee(e.createdAt) })]
|
|
239
239
|
})
|
|
240
240
|
]
|
|
241
241
|
})
|
|
@@ -248,17 +248,17 @@ function B() {
|
|
|
248
248
|
}, e.id))
|
|
249
249
|
})
|
|
250
250
|
}),
|
|
251
|
-
w && /* @__PURE__ */ k(
|
|
251
|
+
w && /* @__PURE__ */ k(U, {
|
|
252
252
|
onClose: () => E(!1),
|
|
253
253
|
onSuccess: (e) => {
|
|
254
|
-
E(!1),
|
|
254
|
+
E(!1), X("success", C("newsletter.abTestCreatedSuccessfully", "A/B test created successfully")), $(e);
|
|
255
255
|
},
|
|
256
|
-
showNotification:
|
|
256
|
+
showNotification: X
|
|
257
257
|
})
|
|
258
258
|
]
|
|
259
259
|
});
|
|
260
260
|
}
|
|
261
|
-
function
|
|
261
|
+
function H({ testId: e, onBack: r, showNotification: i }) {
|
|
262
262
|
let { variants: o, comparison: c, loading: l, error: u, refetch: h } = n(e), { selectWinner: g, selecting: v } = t(), y = a(), [b, x] = s(null), C = async () => {
|
|
263
263
|
if (b) try {
|
|
264
264
|
await g(b), i("success", y("newsletter.winnerSelectedSuccessfully", "Winner selected successfully")), h(), x(null);
|
|
@@ -632,7 +632,7 @@ function V({ testId: e, onBack: r, showNotification: i }) {
|
|
|
632
632
|
]
|
|
633
633
|
});
|
|
634
634
|
}
|
|
635
|
-
function
|
|
635
|
+
function U({ onClose: n, onSuccess: i, showNotification: o }) {
|
|
636
636
|
let { productId: c } = e(), { createABTest: l, creating: u } = t(), { createNewsletter: d, creating: f } = r(), p = a(), [m, h] = s(""), [g, v] = s(20), [y, x] = s("OPEN_RATE"), [S, w] = s([{
|
|
637
637
|
uid: "variant-a",
|
|
638
638
|
name: `${p("newsletter.variant", "Variant")} A`,
|
|
@@ -749,7 +749,7 @@ function H({ onClose: n, onSuccess: i, showNotification: o }) {
|
|
|
749
749
|
/* @__PURE__ */ A("div", { children: [/* @__PURE__ */ k("label", {
|
|
750
750
|
className: "block text-sm font-medium text-text-primary mb-1",
|
|
751
751
|
children: p("newsletter.winningCriteria", "Winning Criteria")
|
|
752
|
-
}), /* @__PURE__ */ A(
|
|
752
|
+
}), /* @__PURE__ */ A(B, {
|
|
753
753
|
value: y,
|
|
754
754
|
onChange: (e) => x(e.target.value),
|
|
755
755
|
className: "w-full px-4 py-2 border border-border-seam rounded-lg bg-bg-surface focus:ring-2 focus:ring-primary/50 focus:border-transparent scheme-normal dark:scheme-dark [&_option]:bg-bg-surface [&_option]:text-text-primary",
|
|
@@ -838,6 +838,6 @@ function H({ onClose: n, onSuccess: i, showNotification: o }) {
|
|
|
838
838
|
})
|
|
839
839
|
});
|
|
840
840
|
}
|
|
841
|
-
export {
|
|
841
|
+
export { V as ABTestingPage };
|
|
842
842
|
|
|
843
843
|
//# sourceMappingURL=ABTestingPage.js.map
|