@burdenoff/microfe-billing 2026.1114.10 → 2026.1115.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.
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { useBilling as e } from "../../../providers/BillingProvider.js";
|
|
2
2
|
import { AccessDenied as t } from "../../../shared/components/AccessDenied.js";
|
|
3
3
|
import { PageHeader as n } from "../../../shared/components/PageHeader.js";
|
|
4
|
-
import { StatCard as
|
|
5
|
-
import { ServerError as
|
|
6
|
-
import { MoneyActionDialog as
|
|
7
|
-
import { useBillingEventEmitter as
|
|
8
|
-
import { HeaderActions as
|
|
9
|
-
import { useBillingPermissions as
|
|
10
|
-
import { useIsFluidgridsVariant as
|
|
4
|
+
import { StatCard as ee } from "../../../shared/components/StatCard.js";
|
|
5
|
+
import { ServerError as r } from "../../../shared/components/ServerError.js";
|
|
6
|
+
import { MoneyActionDialog as i } from "../../../shared/components/MoneyActionDialog.js";
|
|
7
|
+
import { useBillingEventEmitter as a } from "../../../hooks/useBillingEventEmitter.js";
|
|
8
|
+
import { HeaderActions as o } from "../../../shared/components/HeaderActions.js";
|
|
9
|
+
import { useBillingPermissions as s } from "../../../hooks/useBillingPermissions.js";
|
|
10
|
+
import { useIsFluidgridsVariant as te } from "../../../hooks/useBillingVariant.js";
|
|
11
11
|
import { formatCurrency as c, formatDateTime as l } from "../../../shared/utils/format.js";
|
|
12
12
|
import { isServerError as u } from "../../../shared/utils/error.js";
|
|
13
13
|
import "../../../shared/components/index.js";
|
|
14
14
|
import "../../../shared/utils/index.js";
|
|
15
|
-
import { addAffiliateCodeNote as
|
|
16
|
-
import { useCallback as
|
|
17
|
-
import { EmphasisPanel as
|
|
18
|
-
import { Link2 as
|
|
19
|
-
import { jsx as
|
|
15
|
+
import { addAffiliateCodeNote as ne, createAffiliateCode as re, deactivateAffiliateCode as d, fetchMyAffiliateAnalytics as ie, fetchMyAffiliateCodes as ae, fetchMyAffiliateJourneys as f, updateAffiliateCode as p } from "../api.js";
|
|
16
|
+
import { useCallback as m, useEffect as h, useMemo as g, useState as _ } from "react";
|
|
17
|
+
import { EmphasisPanel as v, IllustratedEmptyState as y, PagePurpose as b, ResponsiveTable as oe } from "@burdenoff/fe-libs/ui";
|
|
18
|
+
import { Link2 as x, Plus as se, RefreshCw as ce, StickyNote as le, Ticket as ue, TrendingUp as de, Users as fe } from "lucide-react";
|
|
19
|
+
import { jsx as S, jsxs as C } from "react/jsx-runtime";
|
|
20
20
|
// src/billing/modules/affiliate/pages/AffiliateDashboardPage.tsx
|
|
21
|
-
var
|
|
21
|
+
var w = [
|
|
22
22
|
{
|
|
23
23
|
key: "code",
|
|
24
24
|
header: "Code",
|
|
@@ -50,88 +50,88 @@ var T = [
|
|
|
50
50
|
header: "Visited",
|
|
51
51
|
cell: (e) => l(e.lastVisitedAt)
|
|
52
52
|
}
|
|
53
|
-
],
|
|
54
|
-
let l =
|
|
53
|
+
], T = () => {
|
|
54
|
+
let l = s(), T = te(), [E, D] = _(null), [O, k] = _(!1), [A, j] = _(null), [M, N] = _(null), { emit: P } = a(), { apiGatewayUrl: F, authToken: I, orgId: L } = e(), [R, z] = _([]), [B, V] = _([]), [H, pe] = _(null), [U, W] = _(!0), [G, K] = _(null), [me, q] = _(null), [J, Y] = _({
|
|
55
55
|
label: "",
|
|
56
56
|
description: "",
|
|
57
57
|
notes: "",
|
|
58
58
|
productSlug: "",
|
|
59
59
|
destinationPath: "",
|
|
60
60
|
destinationUrl: ""
|
|
61
|
-
}),
|
|
62
|
-
apiGatewayUrl:
|
|
63
|
-
authToken:
|
|
64
|
-
orgId:
|
|
61
|
+
}), X = g(() => ({
|
|
62
|
+
apiGatewayUrl: F,
|
|
63
|
+
authToken: I,
|
|
64
|
+
orgId: L
|
|
65
65
|
}), [
|
|
66
|
-
P,
|
|
67
66
|
F,
|
|
68
|
-
I
|
|
69
|
-
|
|
70
|
-
|
|
67
|
+
I,
|
|
68
|
+
L
|
|
69
|
+
]), Z = m(async () => {
|
|
70
|
+
W(!0), K(null);
|
|
71
71
|
try {
|
|
72
72
|
let [e, t, n] = await Promise.all([
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
73
|
+
ae(X),
|
|
74
|
+
ie(X),
|
|
75
|
+
f(X)
|
|
76
76
|
]);
|
|
77
|
-
|
|
77
|
+
z(e), pe(t), V(n);
|
|
78
78
|
} catch (e) {
|
|
79
|
-
|
|
79
|
+
K(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load affiliate dashboard"));
|
|
80
80
|
} finally {
|
|
81
|
-
|
|
81
|
+
W(!1);
|
|
82
82
|
}
|
|
83
|
-
}, [
|
|
84
|
-
if (
|
|
85
|
-
|
|
86
|
-
}, [
|
|
87
|
-
if (
|
|
83
|
+
}, [X]);
|
|
84
|
+
if (h(() => {
|
|
85
|
+
Z();
|
|
86
|
+
}, [Z]), !l.canViewBillingAccount) return /* @__PURE__ */ S(t, { message: "You don't have permission to view affiliate analytics." });
|
|
87
|
+
if (G && u(G)) return /* @__PURE__ */ S(r, {
|
|
88
88
|
title: "Affiliate service unavailable",
|
|
89
|
-
message:
|
|
90
|
-
onRetry: () => void
|
|
89
|
+
message: G.message,
|
|
90
|
+
onRetry: () => void Z(),
|
|
91
91
|
showRetry: !0
|
|
92
92
|
});
|
|
93
|
-
let
|
|
94
|
-
if (!
|
|
93
|
+
let Q = R.find((e) => e.id === me) ?? null, he = async () => {
|
|
94
|
+
if (!J.productSlug.trim()) K(/* @__PURE__ */ Error("Product slug is required"));
|
|
95
95
|
else try {
|
|
96
|
-
if (
|
|
97
|
-
label:
|
|
98
|
-
description:
|
|
99
|
-
notes:
|
|
100
|
-
destinationPath:
|
|
101
|
-
destinationUrl:
|
|
102
|
-
},
|
|
96
|
+
if (Q) await p(Q.id, {
|
|
97
|
+
label: J.label,
|
|
98
|
+
description: J.description,
|
|
99
|
+
notes: J.notes,
|
|
100
|
+
destinationPath: J.destinationPath,
|
|
101
|
+
destinationUrl: J.destinationUrl
|
|
102
|
+
}, X), P("billing.affiliate_code.updated", {
|
|
103
103
|
route: "/billing/affiliate",
|
|
104
|
-
entityId:
|
|
104
|
+
entityId: Q.id,
|
|
105
105
|
source: "affiliate-dashboard"
|
|
106
106
|
});
|
|
107
107
|
else {
|
|
108
|
-
let e = await
|
|
109
|
-
label:
|
|
110
|
-
description:
|
|
111
|
-
notes:
|
|
112
|
-
productSlug:
|
|
113
|
-
destinationPath:
|
|
114
|
-
destinationUrl:
|
|
115
|
-
},
|
|
116
|
-
|
|
108
|
+
let e = await re({
|
|
109
|
+
label: J.label,
|
|
110
|
+
description: J.description,
|
|
111
|
+
notes: J.notes,
|
|
112
|
+
productSlug: J.productSlug,
|
|
113
|
+
destinationPath: J.destinationPath,
|
|
114
|
+
destinationUrl: J.destinationUrl
|
|
115
|
+
}, X);
|
|
116
|
+
P("billing.affiliate_code.created", {
|
|
117
117
|
route: "/billing/affiliate",
|
|
118
118
|
entityId: e.id,
|
|
119
119
|
source: "affiliate-dashboard"
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
-
|
|
122
|
+
q(null), Y({
|
|
123
123
|
label: "",
|
|
124
124
|
description: "",
|
|
125
125
|
notes: "",
|
|
126
126
|
productSlug: "",
|
|
127
127
|
destinationPath: "",
|
|
128
128
|
destinationUrl: ""
|
|
129
|
-
}), await
|
|
129
|
+
}), await Z();
|
|
130
130
|
} catch (e) {
|
|
131
|
-
|
|
131
|
+
K(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to save affiliate code"));
|
|
132
132
|
}
|
|
133
|
-
},
|
|
134
|
-
|
|
133
|
+
}, ge = (e) => {
|
|
134
|
+
q(e.id), Y({
|
|
135
135
|
label: e.label ?? "",
|
|
136
136
|
description: e.description ?? "",
|
|
137
137
|
notes: e.notes ?? "",
|
|
@@ -139,168 +139,173 @@ var T = [
|
|
|
139
139
|
destinationPath: e.destinationPath ?? "",
|
|
140
140
|
destinationUrl: e.destinationUrl ?? ""
|
|
141
141
|
});
|
|
142
|
-
},
|
|
143
|
-
if (
|
|
144
|
-
|
|
142
|
+
}, _e = async () => {
|
|
143
|
+
if (E) {
|
|
144
|
+
k(!0), j(null);
|
|
145
145
|
try {
|
|
146
|
-
await
|
|
146
|
+
await $(E.id), N(E.label), D(null);
|
|
147
147
|
} catch (e) {
|
|
148
|
-
|
|
148
|
+
j(e instanceof Error ? e.message : "Could not deactivate this code.");
|
|
149
149
|
} finally {
|
|
150
|
-
|
|
150
|
+
k(!1);
|
|
151
151
|
}
|
|
152
152
|
}
|
|
153
|
-
},
|
|
154
|
-
await
|
|
153
|
+
}, $ = async (e) => {
|
|
154
|
+
await d(e, X), P("billing.affiliate_code.deactivated", {
|
|
155
155
|
route: "/billing/affiliate",
|
|
156
156
|
entityId: e,
|
|
157
157
|
source: "affiliate-dashboard"
|
|
158
|
-
}), await
|
|
159
|
-
},
|
|
158
|
+
}), await Z();
|
|
159
|
+
}, ve = async (e) => {
|
|
160
160
|
let t = window.prompt("Add an internal note for this affiliate code");
|
|
161
|
-
t && (await
|
|
161
|
+
t && (await ne(e, t, X), P("billing.affiliate_code.note_added", {
|
|
162
162
|
route: "/billing/affiliate",
|
|
163
163
|
entityId: e,
|
|
164
164
|
source: "affiliate-dashboard"
|
|
165
|
-
}), await
|
|
166
|
-
},
|
|
165
|
+
}), await Z());
|
|
166
|
+
}, ye = H ? [
|
|
167
167
|
{
|
|
168
168
|
title: "Codes",
|
|
169
|
-
value:
|
|
170
|
-
icon: /* @__PURE__ */
|
|
169
|
+
value: H.totalCodes,
|
|
170
|
+
icon: /* @__PURE__ */ S(ue, { className: "size-5" })
|
|
171
171
|
},
|
|
172
172
|
{
|
|
173
173
|
title: "Visits",
|
|
174
|
-
value:
|
|
175
|
-
icon: /* @__PURE__ */
|
|
174
|
+
value: H.totalVisits,
|
|
175
|
+
icon: /* @__PURE__ */ S(fe, { className: "size-5" })
|
|
176
176
|
},
|
|
177
177
|
{
|
|
178
178
|
title: "Journeys",
|
|
179
|
-
value:
|
|
180
|
-
icon: /* @__PURE__ */
|
|
179
|
+
value: H.totalJourneys,
|
|
180
|
+
icon: /* @__PURE__ */ S(x, { className: "size-5" })
|
|
181
181
|
},
|
|
182
182
|
{
|
|
183
183
|
title: "Revenue influenced",
|
|
184
|
-
value: c(
|
|
185
|
-
icon: /* @__PURE__ */
|
|
184
|
+
value: c(H.totalRevenueAmount, "USD"),
|
|
185
|
+
icon: /* @__PURE__ */ S(de, { className: "size-5" })
|
|
186
186
|
}
|
|
187
187
|
] : [];
|
|
188
|
-
return /* @__PURE__ */
|
|
188
|
+
return /* @__PURE__ */ C("div", {
|
|
189
189
|
className: "space-y-6 p-6",
|
|
190
190
|
children: [
|
|
191
|
-
|
|
192
|
-
|
|
191
|
+
T && M ? /* @__PURE__ */ S("div", {
|
|
192
|
+
role: "status",
|
|
193
|
+
className: "rounded-lg border border-border-subtle bg-status-info-bg-subtle p-4 text-sm text-status-info-text",
|
|
194
|
+
children: `"${M}" was deactivated.`
|
|
195
|
+
}) : null,
|
|
196
|
+
T && /* @__PURE__ */ S(i, {
|
|
197
|
+
open: E !== null,
|
|
193
198
|
tone: "danger",
|
|
194
199
|
title: "Deactivate this affiliate code?",
|
|
195
200
|
description: "The code stops tracking new visits straight away. Visits and journeys already recorded are kept.",
|
|
196
201
|
details: [{
|
|
197
202
|
label: "Code",
|
|
198
|
-
value:
|
|
203
|
+
value: E?.label ?? ""
|
|
199
204
|
}],
|
|
200
205
|
confirmLabel: "Deactivate code",
|
|
201
206
|
busyLabel: "Deactivating…",
|
|
202
|
-
isBusy:
|
|
203
|
-
error:
|
|
204
|
-
onConfirm: () => void
|
|
205
|
-
onCancel: () =>
|
|
207
|
+
isBusy: O,
|
|
208
|
+
error: A,
|
|
209
|
+
onConfirm: () => void _e(),
|
|
210
|
+
onCancel: () => D(null)
|
|
206
211
|
}),
|
|
207
|
-
/* @__PURE__ */
|
|
212
|
+
/* @__PURE__ */ S(n, {
|
|
208
213
|
title: "Affiliate codes",
|
|
209
214
|
description: "Create referral codes, add internal notes, and monitor attributed journeys.",
|
|
210
|
-
actions: /* @__PURE__ */
|
|
215
|
+
actions: /* @__PURE__ */ S(o, { actions: [{
|
|
211
216
|
label: "Refresh",
|
|
212
|
-
onSelect: () => void
|
|
213
|
-
icon: /* @__PURE__ */
|
|
217
|
+
onSelect: () => void Z(),
|
|
218
|
+
icon: /* @__PURE__ */ S(ce, { className: "size-4" })
|
|
214
219
|
}] })
|
|
215
220
|
}),
|
|
216
|
-
/* @__PURE__ */
|
|
217
|
-
|
|
221
|
+
/* @__PURE__ */ S(b, { children: "Generate referral links for any product, share them, and see exactly what they drive — visits, signups, paid conversions and the rewards you have earned. Create and manage your codes on the left and watch attributed visitor journeys on the right." }),
|
|
222
|
+
U ? /* @__PURE__ */ S("div", {
|
|
218
223
|
className: "grid gap-4 md:grid-cols-2 xl:grid-cols-4",
|
|
219
224
|
children: [
|
|
220
225
|
1,
|
|
221
226
|
2,
|
|
222
227
|
3,
|
|
223
228
|
4
|
|
224
|
-
].map((e) => /* @__PURE__ */
|
|
225
|
-
}) :
|
|
229
|
+
].map((e) => /* @__PURE__ */ S("div", { className: "h-28 animate-pulse rounded-lg border border-border-subtle bg-bg-surface" }, e))
|
|
230
|
+
}) : H ? /* @__PURE__ */ S(v, {
|
|
226
231
|
className: "p-4 sm:p-5",
|
|
227
|
-
children: /* @__PURE__ */
|
|
232
|
+
children: /* @__PURE__ */ S("div", {
|
|
228
233
|
className: "grid gap-4 md:grid-cols-2 xl:grid-cols-4",
|
|
229
|
-
children:
|
|
234
|
+
children: ye.map((e) => /* @__PURE__ */ S(ee, {
|
|
230
235
|
label: e.title,
|
|
231
236
|
value: e.value,
|
|
232
237
|
icon: e.icon
|
|
233
238
|
}, e.title))
|
|
234
239
|
})
|
|
235
240
|
}) : null,
|
|
236
|
-
|
|
241
|
+
G && !u(G) ? /* @__PURE__ */ S("div", {
|
|
237
242
|
className: "rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm text-status-error-text",
|
|
238
|
-
children:
|
|
243
|
+
children: G.message
|
|
239
244
|
}) : null,
|
|
240
|
-
/* @__PURE__ */
|
|
245
|
+
/* @__PURE__ */ C("div", {
|
|
241
246
|
className: "grid gap-6 xl:grid-cols-[1.1fr,1.9fr]",
|
|
242
|
-
children: [/* @__PURE__ */
|
|
247
|
+
children: [/* @__PURE__ */ C("section", {
|
|
243
248
|
className: "rounded-lg border border-border-seam bg-bg-surface p-4 xl:sticky xl:top-6 xl:self-start",
|
|
244
249
|
children: [
|
|
245
|
-
/* @__PURE__ */
|
|
250
|
+
/* @__PURE__ */ C("div", {
|
|
246
251
|
className: "mb-4 flex items-center justify-between",
|
|
247
|
-
children: [/* @__PURE__ */
|
|
252
|
+
children: [/* @__PURE__ */ S("h2", {
|
|
248
253
|
className: "text-lg font-semibold text-text-primary",
|
|
249
|
-
children:
|
|
250
|
-
}),
|
|
254
|
+
children: Q ? "Update affiliate code" : "Create affiliate code"
|
|
255
|
+
}), Q ? null : /* @__PURE__ */ S(se, { className: "size-4 text-text-secondary" })]
|
|
251
256
|
}),
|
|
252
|
-
/* @__PURE__ */
|
|
257
|
+
/* @__PURE__ */ C("div", {
|
|
253
258
|
className: "space-y-3",
|
|
254
259
|
children: [
|
|
255
|
-
/* @__PURE__ */
|
|
256
|
-
value:
|
|
257
|
-
onChange: (e) =>
|
|
260
|
+
/* @__PURE__ */ S("input", {
|
|
261
|
+
value: J.label,
|
|
262
|
+
onChange: (e) => Y((t) => ({
|
|
258
263
|
...t,
|
|
259
264
|
label: e.target.value
|
|
260
265
|
})),
|
|
261
266
|
placeholder: "Label",
|
|
262
267
|
className: "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary"
|
|
263
268
|
}),
|
|
264
|
-
/* @__PURE__ */
|
|
265
|
-
value:
|
|
266
|
-
onChange: (e) =>
|
|
269
|
+
/* @__PURE__ */ S("input", {
|
|
270
|
+
value: J.productSlug,
|
|
271
|
+
onChange: (e) => Y((t) => ({
|
|
267
272
|
...t,
|
|
268
273
|
productSlug: e.target.value
|
|
269
274
|
})),
|
|
270
275
|
placeholder: "Product slug (eg. bigconsole)",
|
|
271
276
|
className: "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary",
|
|
272
|
-
disabled: !!
|
|
277
|
+
disabled: !!Q
|
|
273
278
|
}),
|
|
274
|
-
/* @__PURE__ */
|
|
275
|
-
value:
|
|
276
|
-
onChange: (e) =>
|
|
279
|
+
/* @__PURE__ */ S("input", {
|
|
280
|
+
value: J.destinationPath,
|
|
281
|
+
onChange: (e) => Y((t) => ({
|
|
277
282
|
...t,
|
|
278
283
|
destinationPath: e.target.value
|
|
279
284
|
})),
|
|
280
285
|
placeholder: "Destination path (eg. /pricing)",
|
|
281
286
|
className: "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary"
|
|
282
287
|
}),
|
|
283
|
-
/* @__PURE__ */
|
|
284
|
-
value:
|
|
285
|
-
onChange: (e) =>
|
|
288
|
+
/* @__PURE__ */ S("input", {
|
|
289
|
+
value: J.destinationUrl,
|
|
290
|
+
onChange: (e) => Y((t) => ({
|
|
286
291
|
...t,
|
|
287
292
|
destinationUrl: e.target.value
|
|
288
293
|
})),
|
|
289
294
|
placeholder: "Absolute destination URL (optional)",
|
|
290
295
|
className: "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary"
|
|
291
296
|
}),
|
|
292
|
-
/* @__PURE__ */
|
|
293
|
-
value:
|
|
294
|
-
onChange: (e) =>
|
|
297
|
+
/* @__PURE__ */ S("textarea", {
|
|
298
|
+
value: J.description,
|
|
299
|
+
onChange: (e) => Y((t) => ({
|
|
295
300
|
...t,
|
|
296
301
|
description: e.target.value
|
|
297
302
|
})),
|
|
298
303
|
placeholder: "Description",
|
|
299
304
|
className: "min-h-24 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary"
|
|
300
305
|
}),
|
|
301
|
-
/* @__PURE__ */
|
|
302
|
-
value:
|
|
303
|
-
onChange: (e) =>
|
|
306
|
+
/* @__PURE__ */ S("textarea", {
|
|
307
|
+
value: J.notes,
|
|
308
|
+
onChange: (e) => Y((t) => ({
|
|
304
309
|
...t,
|
|
305
310
|
notes: e.target.value
|
|
306
311
|
})),
|
|
@@ -309,17 +314,17 @@ var T = [
|
|
|
309
314
|
})
|
|
310
315
|
]
|
|
311
316
|
}),
|
|
312
|
-
/* @__PURE__ */
|
|
317
|
+
/* @__PURE__ */ C("div", {
|
|
313
318
|
className: "mt-4 flex flex-wrap gap-3",
|
|
314
|
-
children: [/* @__PURE__ */
|
|
319
|
+
children: [/* @__PURE__ */ S("button", {
|
|
315
320
|
type: "button",
|
|
316
|
-
onClick: () => void
|
|
321
|
+
onClick: () => void he(),
|
|
317
322
|
className: "rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text",
|
|
318
|
-
children:
|
|
319
|
-
}),
|
|
323
|
+
children: Q ? "Save changes" : "Create code"
|
|
324
|
+
}), Q ? /* @__PURE__ */ S("button", {
|
|
320
325
|
type: "button",
|
|
321
326
|
onClick: () => {
|
|
322
|
-
|
|
327
|
+
q(null), Y({
|
|
323
328
|
label: "",
|
|
324
329
|
description: "",
|
|
325
330
|
notes: "",
|
|
@@ -333,32 +338,32 @@ var T = [
|
|
|
333
338
|
}) : null]
|
|
334
339
|
})
|
|
335
340
|
]
|
|
336
|
-
}), /* @__PURE__ */
|
|
341
|
+
}), /* @__PURE__ */ C("section", {
|
|
337
342
|
className: "space-y-4",
|
|
338
|
-
children: [/* @__PURE__ */
|
|
343
|
+
children: [/* @__PURE__ */ C("div", {
|
|
339
344
|
className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
|
|
340
|
-
children: [/* @__PURE__ */
|
|
345
|
+
children: [/* @__PURE__ */ S("h2", {
|
|
341
346
|
className: "mb-4 text-lg font-semibold text-text-primary",
|
|
342
347
|
children: "My codes"
|
|
343
|
-
}),
|
|
348
|
+
}), R.length === 0 && !U ? /* @__PURE__ */ S(y, {
|
|
344
349
|
illustration: "empty-data",
|
|
345
350
|
title: "No affiliate codes yet",
|
|
346
351
|
description: "Create your first code to start tracking attributable journeys."
|
|
347
|
-
}) : /* @__PURE__ */
|
|
352
|
+
}) : /* @__PURE__ */ S("div", {
|
|
348
353
|
className: "space-y-4",
|
|
349
|
-
children:
|
|
354
|
+
children: R.map((e) => {
|
|
350
355
|
let t = e.destinationUrl || `https://${e.productSlug}.com${e.destinationPath || ""}?ref=${e.code}`;
|
|
351
|
-
return /* @__PURE__ */
|
|
356
|
+
return /* @__PURE__ */ C("div", {
|
|
352
357
|
className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
|
|
353
358
|
children: [
|
|
354
|
-
/* @__PURE__ */
|
|
359
|
+
/* @__PURE__ */ C("div", {
|
|
355
360
|
className: "flex flex-wrap items-start justify-between gap-4",
|
|
356
|
-
children: [/* @__PURE__ */
|
|
357
|
-
/* @__PURE__ */
|
|
361
|
+
children: [/* @__PURE__ */ C("div", { children: [
|
|
362
|
+
/* @__PURE__ */ S("p", {
|
|
358
363
|
className: "text-sm font-semibold text-text-primary",
|
|
359
364
|
children: e.label || e.code
|
|
360
365
|
}),
|
|
361
|
-
/* @__PURE__ */
|
|
366
|
+
/* @__PURE__ */ C("p", {
|
|
362
367
|
className: "text-xs text-text-secondary",
|
|
363
368
|
children: [
|
|
364
369
|
e.code,
|
|
@@ -366,83 +371,83 @@ var T = [
|
|
|
366
371
|
e.productSlug
|
|
367
372
|
]
|
|
368
373
|
}),
|
|
369
|
-
/* @__PURE__ */
|
|
374
|
+
/* @__PURE__ */ S("p", {
|
|
370
375
|
className: "mt-1 break-all text-xs text-text-secondary",
|
|
371
376
|
children: t
|
|
372
377
|
})
|
|
373
|
-
] }), /* @__PURE__ */
|
|
378
|
+
] }), /* @__PURE__ */ C("div", {
|
|
374
379
|
className: "flex flex-wrap gap-2",
|
|
375
380
|
children: [
|
|
376
|
-
/* @__PURE__ */
|
|
381
|
+
/* @__PURE__ */ S("button", {
|
|
377
382
|
type: "button",
|
|
378
|
-
onClick: () =>
|
|
383
|
+
onClick: () => ge(e),
|
|
379
384
|
className: "rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary",
|
|
380
385
|
children: "Edit"
|
|
381
386
|
}),
|
|
382
|
-
/* @__PURE__ */
|
|
387
|
+
/* @__PURE__ */ C("button", {
|
|
383
388
|
type: "button",
|
|
384
|
-
onClick: () => void
|
|
389
|
+
onClick: () => void ve(e.id),
|
|
385
390
|
className: "inline-flex items-center gap-1 rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary",
|
|
386
|
-
children: [/* @__PURE__ */
|
|
391
|
+
children: [/* @__PURE__ */ S(le, { className: "size-3.5" }), "Note"]
|
|
387
392
|
}),
|
|
388
|
-
e.status === "ACTIVE" ? /* @__PURE__ */
|
|
393
|
+
e.status === "ACTIVE" ? /* @__PURE__ */ S("button", {
|
|
389
394
|
type: "button",
|
|
390
|
-
onClick: () =>
|
|
395
|
+
onClick: () => T ? (j(null), D({
|
|
391
396
|
id: e.id,
|
|
392
397
|
label: e.label || e.code
|
|
393
|
-
})) : void
|
|
398
|
+
})) : void $(e.id),
|
|
394
399
|
className: "rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-status-error-text",
|
|
395
400
|
children: "Deactivate"
|
|
396
401
|
}) : null
|
|
397
402
|
]
|
|
398
403
|
})]
|
|
399
404
|
}),
|
|
400
|
-
/* @__PURE__ */
|
|
405
|
+
/* @__PURE__ */ C("div", {
|
|
401
406
|
className: "mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4",
|
|
402
407
|
children: [
|
|
403
|
-
/* @__PURE__ */
|
|
408
|
+
/* @__PURE__ */ C("div", {
|
|
404
409
|
className: "rounded-md border border-border-subtle bg-bg-surface p-3",
|
|
405
|
-
children: [/* @__PURE__ */
|
|
410
|
+
children: [/* @__PURE__ */ S("p", {
|
|
406
411
|
className: "text-xs text-text-secondary",
|
|
407
412
|
children: "Visits"
|
|
408
|
-
}), /* @__PURE__ */
|
|
413
|
+
}), /* @__PURE__ */ S("p", {
|
|
409
414
|
className: "text-lg font-semibold text-text-primary",
|
|
410
415
|
children: e.totalVisits
|
|
411
416
|
})]
|
|
412
417
|
}),
|
|
413
|
-
/* @__PURE__ */
|
|
418
|
+
/* @__PURE__ */ C("div", {
|
|
414
419
|
className: "rounded-md border border-border-subtle bg-bg-surface p-3",
|
|
415
|
-
children: [/* @__PURE__ */
|
|
420
|
+
children: [/* @__PURE__ */ S("p", {
|
|
416
421
|
className: "text-xs text-text-secondary",
|
|
417
422
|
children: "Signups"
|
|
418
|
-
}), /* @__PURE__ */
|
|
423
|
+
}), /* @__PURE__ */ S("p", {
|
|
419
424
|
className: "text-lg font-semibold text-text-primary",
|
|
420
425
|
children: e.totalSignups
|
|
421
426
|
})]
|
|
422
427
|
}),
|
|
423
|
-
/* @__PURE__ */
|
|
428
|
+
/* @__PURE__ */ C("div", {
|
|
424
429
|
className: "rounded-md border border-border-subtle bg-bg-surface p-3",
|
|
425
|
-
children: [/* @__PURE__ */
|
|
430
|
+
children: [/* @__PURE__ */ S("p", {
|
|
426
431
|
className: "text-xs text-text-secondary",
|
|
427
432
|
children: "Paid conversions"
|
|
428
|
-
}), /* @__PURE__ */
|
|
433
|
+
}), /* @__PURE__ */ S("p", {
|
|
429
434
|
className: "text-lg font-semibold text-text-primary",
|
|
430
435
|
children: e.totalPaidConversions + e.totalStorePurchases
|
|
431
436
|
})]
|
|
432
437
|
}),
|
|
433
|
-
/* @__PURE__ */
|
|
438
|
+
/* @__PURE__ */ C("div", {
|
|
434
439
|
className: "rounded-md border border-border-subtle bg-bg-surface p-3",
|
|
435
|
-
children: [/* @__PURE__ */
|
|
440
|
+
children: [/* @__PURE__ */ S("p", {
|
|
436
441
|
className: "text-xs text-text-secondary",
|
|
437
442
|
children: "Rewards earned"
|
|
438
|
-
}), /* @__PURE__ */
|
|
443
|
+
}), /* @__PURE__ */ S("p", {
|
|
439
444
|
className: "text-lg font-semibold text-text-primary",
|
|
440
445
|
children: c(e.totalRewardAmount, "USD")
|
|
441
446
|
})]
|
|
442
447
|
})
|
|
443
448
|
]
|
|
444
449
|
}),
|
|
445
|
-
e.notes ? /* @__PURE__ */
|
|
450
|
+
e.notes ? /* @__PURE__ */ S("p", {
|
|
446
451
|
className: "mt-3 text-sm text-text-secondary",
|
|
447
452
|
children: e.notes
|
|
448
453
|
}) : null
|
|
@@ -450,19 +455,19 @@ var T = [
|
|
|
450
455
|
}, e.id);
|
|
451
456
|
})
|
|
452
457
|
})]
|
|
453
|
-
}), /* @__PURE__ */
|
|
458
|
+
}), /* @__PURE__ */ C("div", {
|
|
454
459
|
className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
|
|
455
|
-
children: [/* @__PURE__ */
|
|
460
|
+
children: [/* @__PURE__ */ S("h2", {
|
|
456
461
|
className: "mb-4 text-lg font-semibold text-text-primary",
|
|
457
462
|
children: "Recent attributed journeys"
|
|
458
|
-
}),
|
|
463
|
+
}), B.length === 0 ? /* @__PURE__ */ S(y, {
|
|
459
464
|
illustration: "empty-people",
|
|
460
465
|
title: "No journeys yet",
|
|
461
466
|
description: "Journeys will appear as visitors land on your affiliate links."
|
|
462
|
-
}) : /* @__PURE__ */
|
|
463
|
-
data:
|
|
467
|
+
}) : /* @__PURE__ */ S(oe, {
|
|
468
|
+
data: B,
|
|
464
469
|
rowKey: (e) => e.id,
|
|
465
|
-
columns:
|
|
470
|
+
columns: w
|
|
466
471
|
})]
|
|
467
472
|
})]
|
|
468
473
|
})]
|
|
@@ -470,6 +475,6 @@ var T = [
|
|
|
470
475
|
]
|
|
471
476
|
});
|
|
472
477
|
};
|
|
473
|
-
export {
|
|
478
|
+
export { T as AffiliateDashboardPage };
|
|
474
479
|
|
|
475
480
|
//# sourceMappingURL=AffiliateDashboardPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AffiliateDashboardPage.js","names":["journeyColumns","journey","formatDateTime","AffiliateDashboardPage","permissions","useBillingPermissions","isFluidgrids","useIsFluidgridsVariant","codeToDeactivate","setCodeToDeactivate","useState","isDeactivating","setIsDeactivating","deactivateError","setDeactivateError","useBillingEventEmitter","useBilling","codes","setCodes","journeys","setJourneys","analytics","setAnalytics","loading","setLoading","error","setError","selectedCodeId","setSelectedCodeId","form","setForm","requestContext","useMemo","apiGatewayUrl","authToken","orgId","loadData","useCallback","loadedCodes","loadedAnalytics","loadedJourneys","fetchMyAffiliateCodes","fetchMyAffiliateAnalytics","fetchMyAffiliateJourneys","loadError","useEffect","AccessDenied","isServerError","ServerError","selectedCode","item","handleSubmit","updateAffiliateCode","emit","createdCode","createAffiliateCode","submitError","handleEdit","code","confirmDeactivate","handleDeactivate","err","deactivateAffiliateCode","codeId","handleQuickNote","note","addAffiliateCodeNote","metricCards","Ticket","Users","Link2","formatCurrency","TrendingUp","MoneyActionDialog","PageHeader","HeaderActions","RefreshCw","PagePurpose","EmphasisPanel","StatCard","card","Plus","current","event","IllustratedEmptyState","shareUrl","StickyNote","ResponsiveTable"],"sources":["../../../../../src/billing/modules/affiliate/pages/AffiliateDashboardPage.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport { Link2, Plus, RefreshCw, StickyNote, Ticket, TrendingUp, Users } from 'lucide-react';\nimport { ResponsiveTable, type ResponsiveTableColumn } from '@burdenoff/fe-libs/ui';\n\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport { MoneyActionDialog } from '../../../shared/components';\nimport {\n AccessDenied,\n HeaderActions,\n PageHeader,\n ServerError,\n StatCard,\n} from '../../../shared/components';\nimport { PagePurpose, EmphasisPanel, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\nimport { formatCurrency, formatDateTime, isServerError } from '../../../shared/utils';\n\nconst journeyColumns: ResponsiveTableColumn<AffiliateJourney>[] = [\n { key: 'code', header: 'Code', priority: 'primary', cell: (journey) => journey.codeValue },\n { key: 'product', header: 'Product', cell: (journey) => journey.productSlug },\n {\n key: 'path',\n header: 'Path',\n cell: (journey) => journey.currentPath || journey.landingPath || '-',\n },\n { key: 'country', header: 'Country', cell: (journey) => journey.geographyCountry || '-' },\n { key: 'status', header: 'Status', cell: (journey) => journey.status },\n {\n key: 'visited',\n header: 'Visited',\n cell: (journey) => formatDateTime(journey.lastVisitedAt),\n },\n];\nimport {\n addAffiliateCodeNote,\n createAffiliateCode,\n deactivateAffiliateCode,\n fetchMyAffiliateAnalytics,\n fetchMyAffiliateCodes,\n fetchMyAffiliateJourneys,\n updateAffiliateCode,\n type AffiliateCode,\n type AffiliateJourney,\n type AffiliateAnalyticsSummary,\n} from '../api';\n\nexport const AffiliateDashboardPage: FC = () => {\n const permissions = useBillingPermissions();\n const isFluidgrids = useIsFluidgridsVariant();\n const [codeToDeactivate, setCodeToDeactivate] = useState<{ id: string; label: string } | null>(\n null\n );\n const [isDeactivating, setIsDeactivating] = useState(false);\n const [deactivateError, setDeactivateError] = useState<string | null>(null);\n const { emit } = useBillingEventEmitter();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n\n const [codes, setCodes] = useState<AffiliateCode[]>([]);\n const [journeys, setJourneys] = useState<AffiliateJourney[]>([]);\n const [analytics, setAnalytics] = useState<AffiliateAnalyticsSummary | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [selectedCodeId, setSelectedCodeId] = useState<string | null>(null);\n const [form, setForm] = useState({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n\n const requestContext = useMemo(\n () => ({\n apiGatewayUrl,\n authToken,\n orgId,\n }),\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadData = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const [loadedCodes, loadedAnalytics, loadedJourneys] = await Promise.all([\n fetchMyAffiliateCodes(requestContext),\n fetchMyAffiliateAnalytics(requestContext),\n fetchMyAffiliateJourneys(requestContext),\n ]);\n setCodes(loadedCodes);\n setAnalytics(loadedAnalytics);\n setJourneys(loadedJourneys);\n } catch (loadError) {\n setError(\n loadError instanceof Error ? loadError : new Error('Failed to load affiliate dashboard')\n );\n } finally {\n setLoading(false);\n }\n }, [requestContext]);\n\n useEffect(() => {\n void loadData();\n }, [loadData]);\n\n if (!permissions.canViewBillingAccount) {\n return <AccessDenied message=\"You don't have permission to view affiliate analytics.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <ServerError\n title=\"Affiliate service unavailable\"\n message={error.message}\n onRetry={() => void loadData()}\n showRetry\n />\n );\n }\n\n const selectedCode = codes.find((item) => item.id === selectedCodeId) ?? null;\n\n const handleSubmit = async () => {\n if (!form.productSlug.trim()) {\n setError(new Error('Product slug is required'));\n return;\n }\n\n try {\n if (selectedCode) {\n await updateAffiliateCode(\n selectedCode.id,\n {\n label: form.label,\n description: form.description,\n notes: form.notes,\n destinationPath: form.destinationPath,\n destinationUrl: form.destinationUrl,\n },\n requestContext\n );\n emit('billing.affiliate_code.updated', {\n route: '/billing/affiliate',\n entityId: selectedCode.id,\n source: 'affiliate-dashboard',\n });\n } else {\n const createdCode = await createAffiliateCode(\n {\n label: form.label,\n description: form.description,\n notes: form.notes,\n productSlug: form.productSlug,\n destinationPath: form.destinationPath,\n destinationUrl: form.destinationUrl,\n },\n requestContext\n );\n emit('billing.affiliate_code.created', {\n route: '/billing/affiliate',\n entityId: createdCode.id,\n source: 'affiliate-dashboard',\n });\n }\n\n setSelectedCodeId(null);\n setForm({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n await loadData();\n } catch (submitError) {\n setError(\n submitError instanceof Error ? submitError : new Error('Failed to save affiliate code')\n );\n }\n };\n\n const handleEdit = (code: AffiliateCode) => {\n setSelectedCodeId(code.id);\n setForm({\n label: code.label ?? '',\n description: code.description ?? '',\n notes: code.notes ?? '',\n productSlug: code.productSlug,\n destinationPath: code.destinationPath ?? '',\n destinationUrl: code.destinationUrl ?? '',\n });\n };\n\n const confirmDeactivate = async () => {\n if (!codeToDeactivate) return;\n setIsDeactivating(true);\n setDeactivateError(null);\n try {\n await handleDeactivate(codeToDeactivate.id);\n setCodeToDeactivate(null);\n } catch (err) {\n setDeactivateError(err instanceof Error ? err.message : 'Could not deactivate this code.');\n } finally {\n setIsDeactivating(false);\n }\n };\n\n const handleDeactivate = async (codeId: string) => {\n await deactivateAffiliateCode(codeId, requestContext);\n emit('billing.affiliate_code.deactivated', {\n route: '/billing/affiliate',\n entityId: codeId,\n source: 'affiliate-dashboard',\n });\n await loadData();\n };\n\n const handleQuickNote = async (codeId: string) => {\n const note = window.prompt('Add an internal note for this affiliate code');\n if (!note) return;\n await addAffiliateCodeNote(codeId, note, requestContext);\n emit('billing.affiliate_code.note_added', {\n route: '/billing/affiliate',\n entityId: codeId,\n source: 'affiliate-dashboard',\n });\n await loadData();\n };\n\n const metricCards = analytics\n ? [\n { title: 'Codes', value: analytics.totalCodes, icon: <Ticket className=\"size-5\" /> },\n { title: 'Visits', value: analytics.totalVisits, icon: <Users className=\"size-5\" /> },\n { title: 'Journeys', value: analytics.totalJourneys, icon: <Link2 className=\"size-5\" /> },\n {\n title: 'Revenue influenced',\n value: formatCurrency(analytics.totalRevenueAmount, 'USD'),\n icon: <TrendingUp className=\"size-5\" />,\n },\n ]\n : [];\n\n return (\n <div className=\"space-y-6 p-6\">\n {isFluidgrids && (\n <MoneyActionDialog\n open={codeToDeactivate !== null}\n tone=\"danger\"\n title=\"Deactivate this affiliate code?\"\n description=\"The code stops tracking new visits straight away. Visits and journeys already recorded are kept.\"\n details={[{ label: 'Code', value: codeToDeactivate?.label ?? '' }]}\n confirmLabel=\"Deactivate code\"\n busyLabel=\"Deactivating…\"\n isBusy={isDeactivating}\n error={deactivateError}\n onConfirm={() => void confirmDeactivate()}\n onCancel={() => setCodeToDeactivate(null)}\n />\n )}\n <PageHeader\n title=\"Affiliate codes\"\n description=\"Create referral codes, add internal notes, and monitor attributed journeys.\"\n actions={\n <HeaderActions\n actions={[\n {\n label: 'Refresh',\n onSelect: () => void loadData(),\n icon: <RefreshCw className=\"size-4\" />,\n },\n ]}\n />\n }\n />\n\n <PagePurpose>\n Generate referral links for any product, share them, and see exactly what they drive —\n visits, signups, paid conversions and the rewards you have earned. Create and manage your\n codes on the left and watch attributed visitor journeys on the right.\n </PagePurpose>\n\n {loading ? (\n <div className=\"grid gap-4 md:grid-cols-2 xl:grid-cols-4\">\n {[1, 2, 3, 4].map((item) => (\n <div\n key={item}\n className=\"h-28 animate-pulse rounded-lg border border-border-subtle bg-bg-surface\"\n />\n ))}\n </div>\n ) : analytics ? (\n <EmphasisPanel className=\"p-4 sm:p-5\">\n <div className=\"grid gap-4 md:grid-cols-2 xl:grid-cols-4\">\n {metricCards.map((card) => (\n <StatCard key={card.title} label={card.title} value={card.value} icon={card.icon} />\n ))}\n </div>\n </EmphasisPanel>\n ) : null}\n\n {error && !isServerError(error) ? (\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm text-status-error-text\">\n {error.message}\n </div>\n ) : null}\n\n <div className=\"grid gap-6 xl:grid-cols-[1.1fr,1.9fr]\">\n <section className=\"rounded-lg border border-border-seam bg-bg-surface p-4 xl:sticky xl:top-6 xl:self-start\">\n <div className=\"mb-4 flex items-center justify-between\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {selectedCode ? 'Update affiliate code' : 'Create affiliate code'}\n </h2>\n {!selectedCode ? <Plus className=\"size-4 text-text-secondary\" /> : null}\n </div>\n\n <div className=\"space-y-3\">\n <input\n value={form.label}\n onChange={(event) =>\n setForm((current) => ({ ...current, label: event.target.value }))\n }\n placeholder=\"Label\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={form.productSlug}\n onChange={(event) =>\n setForm((current) => ({ ...current, productSlug: event.target.value }))\n }\n placeholder=\"Product slug (eg. bigconsole)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n disabled={Boolean(selectedCode)}\n />\n <input\n value={form.destinationPath}\n onChange={(event) =>\n setForm((current) => ({ ...current, destinationPath: event.target.value }))\n }\n placeholder=\"Destination path (eg. /pricing)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={form.destinationUrl}\n onChange={(event) =>\n setForm((current) => ({ ...current, destinationUrl: event.target.value }))\n }\n placeholder=\"Absolute destination URL (optional)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <textarea\n value={form.description}\n onChange={(event) =>\n setForm((current) => ({ ...current, description: event.target.value }))\n }\n placeholder=\"Description\"\n className=\"min-h-24 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <textarea\n value={form.notes}\n onChange={(event) =>\n setForm((current) => ({ ...current, notes: event.target.value }))\n }\n placeholder=\"Internal notes\"\n className=\"min-h-24 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n </div>\n\n <div className=\"mt-4 flex flex-wrap gap-3\">\n <button\n type=\"button\"\n onClick={() => void handleSubmit()}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text\"\n >\n {selectedCode ? 'Save changes' : 'Create code'}\n </button>\n {selectedCode ? (\n <button\n type=\"button\"\n onClick={() => {\n setSelectedCodeId(null);\n setForm({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n }}\n className=\"rounded-md border border-border-subtle bg-bg-surface px-4 py-2 text-sm font-medium text-text-primary\"\n >\n Cancel\n </button>\n ) : null}\n </div>\n </section>\n\n <section className=\"space-y-4\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">My codes</h2>\n {codes.length === 0 && !loading ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title=\"No affiliate codes yet\"\n description=\"Create your first code to start tracking attributable journeys.\"\n />\n ) : (\n <div className=\"space-y-4\">\n {codes.map((code) => {\n const shareUrl =\n code.destinationUrl ||\n `https://${code.productSlug}.com${code.destinationPath || ''}?ref=${code.code}`;\n return (\n <div\n key={code.id}\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\"\n >\n <div className=\"flex flex-wrap items-start justify-between gap-4\">\n <div>\n <p className=\"text-sm font-semibold text-text-primary\">\n {code.label || code.code}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {code.code} · {code.productSlug}\n </p>\n <p className=\"mt-1 break-all text-xs text-text-secondary\">{shareUrl}</p>\n </div>\n <div className=\"flex flex-wrap gap-2\">\n <button\n type=\"button\"\n onClick={() => handleEdit(code)}\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n Edit\n </button>\n <button\n type=\"button\"\n onClick={() => void handleQuickNote(code.id)}\n className=\"inline-flex items-center gap-1 rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n <StickyNote className=\"size-3.5\" />\n Note\n </button>\n {code.status === 'ACTIVE' ? (\n <button\n type=\"button\"\n onClick={() =>\n isFluidgrids\n ? (setDeactivateError(null),\n setCodeToDeactivate({\n id: code.id,\n label: code.label || code.code,\n }))\n : void handleDeactivate(code.id)\n }\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-status-error-text\"\n >\n Deactivate\n </button>\n ) : null}\n </div>\n </div>\n <div className=\"mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4\">\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Visits</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalVisits}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Signups</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalSignups}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Paid conversions</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalPaidConversions + code.totalStorePurchases}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Rewards earned</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {formatCurrency(code.totalRewardAmount, 'USD')}\n </p>\n </div>\n </div>\n {code.notes ? (\n <p className=\"mt-3 text-sm text-text-secondary\">{code.notes}</p>\n ) : null}\n </div>\n );\n })}\n </div>\n )}\n </div>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">\n Recent attributed journeys\n </h2>\n {journeys.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-people\"\n title=\"No journeys yet\"\n description=\"Journeys will appear as visitors land on your affiliate links.\"\n />\n ) : (\n <ResponsiveTable\n data={journeys}\n rowKey={(journey) => journey.id}\n columns={journeyColumns}\n />\n )}\n </div>\n </section>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,IAAMA,IAA4D;CAChE;EAAE,KAAK;EAAQ,QAAQ;EAAQ,UAAU;EAAW,OAAO,MAAYC,EAAQ;CAAU;CACzF;EAAE,KAAK;EAAW,QAAQ;EAAW,OAAO,MAAYA,EAAQ;CAAY;CAC5E;EACE,KAAK;EACL,QAAQ;EACR,OAAO,MAAYA,EAAQ,eAAeA,EAAQ,eAAe;CACnE;CACA;EAAE,KAAK;EAAW,QAAQ;EAAW,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K,QACJ,kBAAC,KAAD;WAAG,WAAU;WAAoC,UAAAA,EAAK;UAAS,CAAA,IAC7D;SACD;QA7EE,GAAAA,EAAK,EA6EP;OAET,CAAC;MACE,CAAA,CAEJ;KAEL,CAAA,GAAA,kBAAC,OAAD;MAAK,WAAU;MAAf,UAAA,CACE,kBAAC,MAAD;OAAI,WAAU;OAA+C,UAAA;MAEzD,CAAA,GACHvC,EAAS,WAAW,IACnB,kBAACiE,GAAD;OACE,cAAa;OACb,OAAM;OACN,aAAY;MACb,CAAA,IAED,kBAACG,IAAD;OACE,MAAMpE;OACN,SAAS,MAAYlB,EAAQ;OAC7B,SAASD;MACV,CAAA,CAEA;KACE,CAAA,CAAA;IACN,CAAA,CAAA;;EACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"AffiliateDashboardPage.js","names":["journeyColumns","journey","formatDateTime","AffiliateDashboardPage","permissions","useBillingPermissions","isFluidgrids","useIsFluidgridsVariant","codeToDeactivate","setCodeToDeactivate","useState","isDeactivating","setIsDeactivating","deactivateError","setDeactivateError","deactivatedLabel","setDeactivatedLabel","useBillingEventEmitter","useBilling","codes","setCodes","journeys","setJourneys","analytics","setAnalytics","loading","setLoading","error","setError","selectedCodeId","setSelectedCodeId","form","setForm","requestContext","useMemo","apiGatewayUrl","authToken","orgId","loadData","useCallback","loadedCodes","loadedAnalytics","loadedJourneys","fetchMyAffiliateCodes","fetchMyAffiliateAnalytics","fetchMyAffiliateJourneys","loadError","useEffect","AccessDenied","isServerError","ServerError","selectedCode","item","handleSubmit","updateAffiliateCode","emit","createdCode","createAffiliateCode","submitError","handleEdit","code","confirmDeactivate","handleDeactivate","err","deactivateAffiliateCode","codeId","handleQuickNote","note","addAffiliateCodeNote","metricCards","Ticket","Users","Link2","formatCurrency","TrendingUp","MoneyActionDialog","PageHeader","HeaderActions","RefreshCw","PagePurpose","EmphasisPanel","StatCard","card","Plus","current","event","IllustratedEmptyState","shareUrl","StickyNote","ResponsiveTable"],"sources":["../../../../../src/billing/modules/affiliate/pages/AffiliateDashboardPage.tsx"],"sourcesContent":["import { useCallback, useEffect, useMemo, useState, type FC } from 'react';\nimport { Link2, Plus, RefreshCw, StickyNote, Ticket, TrendingUp, Users } from 'lucide-react';\nimport { ResponsiveTable, type ResponsiveTableColumn } from '@burdenoff/fe-libs/ui';\n\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useIsFluidgridsVariant } from '../../../hooks/useBillingVariant';\nimport { MoneyActionDialog } from '../../../shared/components';\nimport {\n AccessDenied,\n HeaderActions,\n PageHeader,\n ServerError,\n StatCard,\n} from '../../../shared/components';\nimport { PagePurpose, EmphasisPanel, IllustratedEmptyState } from '@burdenoff/fe-libs/ui';\nimport { formatCurrency, formatDateTime, isServerError } from '../../../shared/utils';\n\nconst journeyColumns: ResponsiveTableColumn<AffiliateJourney>[] = [\n { key: 'code', header: 'Code', priority: 'primary', cell: (journey) => journey.codeValue },\n { key: 'product', header: 'Product', cell: (journey) => journey.productSlug },\n {\n key: 'path',\n header: 'Path',\n cell: (journey) => journey.currentPath || journey.landingPath || '-',\n },\n { key: 'country', header: 'Country', cell: (journey) => journey.geographyCountry || '-' },\n { key: 'status', header: 'Status', cell: (journey) => journey.status },\n {\n key: 'visited',\n header: 'Visited',\n cell: (journey) => formatDateTime(journey.lastVisitedAt),\n },\n];\nimport {\n addAffiliateCodeNote,\n createAffiliateCode,\n deactivateAffiliateCode,\n fetchMyAffiliateAnalytics,\n fetchMyAffiliateCodes,\n fetchMyAffiliateJourneys,\n updateAffiliateCode,\n type AffiliateCode,\n type AffiliateJourney,\n type AffiliateAnalyticsSummary,\n} from '../api';\n\nexport const AffiliateDashboardPage: FC = () => {\n const permissions = useBillingPermissions();\n const isFluidgrids = useIsFluidgridsVariant();\n const [codeToDeactivate, setCodeToDeactivate] = useState<{ id: string; label: string } | null>(\n null\n );\n const [isDeactivating, setIsDeactivating] = useState(false);\n const [deactivateError, setDeactivateError] = useState<string | null>(null);\n const [deactivatedLabel, setDeactivatedLabel] = useState<string | null>(null);\n const { emit } = useBillingEventEmitter();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n\n const [codes, setCodes] = useState<AffiliateCode[]>([]);\n const [journeys, setJourneys] = useState<AffiliateJourney[]>([]);\n const [analytics, setAnalytics] = useState<AffiliateAnalyticsSummary | null>(null);\n const [loading, setLoading] = useState(true);\n const [error, setError] = useState<Error | null>(null);\n const [selectedCodeId, setSelectedCodeId] = useState<string | null>(null);\n const [form, setForm] = useState({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n\n const requestContext = useMemo(\n () => ({\n apiGatewayUrl,\n authToken,\n orgId,\n }),\n [apiGatewayUrl, authToken, orgId]\n );\n\n const loadData = useCallback(async () => {\n setLoading(true);\n setError(null);\n try {\n const [loadedCodes, loadedAnalytics, loadedJourneys] = await Promise.all([\n fetchMyAffiliateCodes(requestContext),\n fetchMyAffiliateAnalytics(requestContext),\n fetchMyAffiliateJourneys(requestContext),\n ]);\n setCodes(loadedCodes);\n setAnalytics(loadedAnalytics);\n setJourneys(loadedJourneys);\n } catch (loadError) {\n setError(\n loadError instanceof Error ? loadError : new Error('Failed to load affiliate dashboard')\n );\n } finally {\n setLoading(false);\n }\n }, [requestContext]);\n\n useEffect(() => {\n void loadData();\n }, [loadData]);\n\n if (!permissions.canViewBillingAccount) {\n return <AccessDenied message=\"You don't have permission to view affiliate analytics.\" />;\n }\n\n if (error && isServerError(error)) {\n return (\n <ServerError\n title=\"Affiliate service unavailable\"\n message={error.message}\n onRetry={() => void loadData()}\n showRetry\n />\n );\n }\n\n const selectedCode = codes.find((item) => item.id === selectedCodeId) ?? null;\n\n const handleSubmit = async () => {\n if (!form.productSlug.trim()) {\n setError(new Error('Product slug is required'));\n return;\n }\n\n try {\n if (selectedCode) {\n await updateAffiliateCode(\n selectedCode.id,\n {\n label: form.label,\n description: form.description,\n notes: form.notes,\n destinationPath: form.destinationPath,\n destinationUrl: form.destinationUrl,\n },\n requestContext\n );\n emit('billing.affiliate_code.updated', {\n route: '/billing/affiliate',\n entityId: selectedCode.id,\n source: 'affiliate-dashboard',\n });\n } else {\n const createdCode = await createAffiliateCode(\n {\n label: form.label,\n description: form.description,\n notes: form.notes,\n productSlug: form.productSlug,\n destinationPath: form.destinationPath,\n destinationUrl: form.destinationUrl,\n },\n requestContext\n );\n emit('billing.affiliate_code.created', {\n route: '/billing/affiliate',\n entityId: createdCode.id,\n source: 'affiliate-dashboard',\n });\n }\n\n setSelectedCodeId(null);\n setForm({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n await loadData();\n } catch (submitError) {\n setError(\n submitError instanceof Error ? submitError : new Error('Failed to save affiliate code')\n );\n }\n };\n\n const handleEdit = (code: AffiliateCode) => {\n setSelectedCodeId(code.id);\n setForm({\n label: code.label ?? '',\n description: code.description ?? '',\n notes: code.notes ?? '',\n productSlug: code.productSlug,\n destinationPath: code.destinationPath ?? '',\n destinationUrl: code.destinationUrl ?? '',\n });\n };\n\n const confirmDeactivate = async () => {\n if (!codeToDeactivate) return;\n setIsDeactivating(true);\n setDeactivateError(null);\n try {\n await handleDeactivate(codeToDeactivate.id);\n setDeactivatedLabel(codeToDeactivate.label);\n setCodeToDeactivate(null);\n } catch (err) {\n setDeactivateError(err instanceof Error ? err.message : 'Could not deactivate this code.');\n } finally {\n setIsDeactivating(false);\n }\n };\n\n const handleDeactivate = async (codeId: string) => {\n await deactivateAffiliateCode(codeId, requestContext);\n emit('billing.affiliate_code.deactivated', {\n route: '/billing/affiliate',\n entityId: codeId,\n source: 'affiliate-dashboard',\n });\n await loadData();\n };\n\n const handleQuickNote = async (codeId: string) => {\n const note = window.prompt('Add an internal note for this affiliate code');\n if (!note) return;\n await addAffiliateCodeNote(codeId, note, requestContext);\n emit('billing.affiliate_code.note_added', {\n route: '/billing/affiliate',\n entityId: codeId,\n source: 'affiliate-dashboard',\n });\n await loadData();\n };\n\n const metricCards = analytics\n ? [\n { title: 'Codes', value: analytics.totalCodes, icon: <Ticket className=\"size-5\" /> },\n { title: 'Visits', value: analytics.totalVisits, icon: <Users className=\"size-5\" /> },\n { title: 'Journeys', value: analytics.totalJourneys, icon: <Link2 className=\"size-5\" /> },\n {\n title: 'Revenue influenced',\n value: formatCurrency(analytics.totalRevenueAmount, 'USD'),\n icon: <TrendingUp className=\"size-5\" />,\n },\n ]\n : [];\n\n return (\n <div className=\"space-y-6 p-6\">\n {isFluidgrids && deactivatedLabel ? (\n <div\n role=\"status\"\n className=\"rounded-lg border border-border-subtle bg-status-info-bg-subtle p-4 text-sm text-status-info-text\"\n >\n {`\"${deactivatedLabel}\" was deactivated.`}\n </div>\n ) : null}\n {isFluidgrids && (\n <MoneyActionDialog\n open={codeToDeactivate !== null}\n tone=\"danger\"\n title=\"Deactivate this affiliate code?\"\n description=\"The code stops tracking new visits straight away. Visits and journeys already recorded are kept.\"\n details={[{ label: 'Code', value: codeToDeactivate?.label ?? '' }]}\n confirmLabel=\"Deactivate code\"\n busyLabel=\"Deactivating…\"\n isBusy={isDeactivating}\n error={deactivateError}\n onConfirm={() => void confirmDeactivate()}\n onCancel={() => setCodeToDeactivate(null)}\n />\n )}\n <PageHeader\n title=\"Affiliate codes\"\n description=\"Create referral codes, add internal notes, and monitor attributed journeys.\"\n actions={\n <HeaderActions\n actions={[\n {\n label: 'Refresh',\n onSelect: () => void loadData(),\n icon: <RefreshCw className=\"size-4\" />,\n },\n ]}\n />\n }\n />\n\n <PagePurpose>\n Generate referral links for any product, share them, and see exactly what they drive —\n visits, signups, paid conversions and the rewards you have earned. Create and manage your\n codes on the left and watch attributed visitor journeys on the right.\n </PagePurpose>\n\n {loading ? (\n <div className=\"grid gap-4 md:grid-cols-2 xl:grid-cols-4\">\n {[1, 2, 3, 4].map((item) => (\n <div\n key={item}\n className=\"h-28 animate-pulse rounded-lg border border-border-subtle bg-bg-surface\"\n />\n ))}\n </div>\n ) : analytics ? (\n <EmphasisPanel className=\"p-4 sm:p-5\">\n <div className=\"grid gap-4 md:grid-cols-2 xl:grid-cols-4\">\n {metricCards.map((card) => (\n <StatCard key={card.title} label={card.title} value={card.value} icon={card.icon} />\n ))}\n </div>\n </EmphasisPanel>\n ) : null}\n\n {error && !isServerError(error) ? (\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm text-status-error-text\">\n {error.message}\n </div>\n ) : null}\n\n <div className=\"grid gap-6 xl:grid-cols-[1.1fr,1.9fr]\">\n <section className=\"rounded-lg border border-border-seam bg-bg-surface p-4 xl:sticky xl:top-6 xl:self-start\">\n <div className=\"mb-4 flex items-center justify-between\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {selectedCode ? 'Update affiliate code' : 'Create affiliate code'}\n </h2>\n {!selectedCode ? <Plus className=\"size-4 text-text-secondary\" /> : null}\n </div>\n\n <div className=\"space-y-3\">\n <input\n value={form.label}\n onChange={(event) =>\n setForm((current) => ({ ...current, label: event.target.value }))\n }\n placeholder=\"Label\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={form.productSlug}\n onChange={(event) =>\n setForm((current) => ({ ...current, productSlug: event.target.value }))\n }\n placeholder=\"Product slug (eg. bigconsole)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n disabled={Boolean(selectedCode)}\n />\n <input\n value={form.destinationPath}\n onChange={(event) =>\n setForm((current) => ({ ...current, destinationPath: event.target.value }))\n }\n placeholder=\"Destination path (eg. /pricing)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <input\n value={form.destinationUrl}\n onChange={(event) =>\n setForm((current) => ({ ...current, destinationUrl: event.target.value }))\n }\n placeholder=\"Absolute destination URL (optional)\"\n className=\"w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <textarea\n value={form.description}\n onChange={(event) =>\n setForm((current) => ({ ...current, description: event.target.value }))\n }\n placeholder=\"Description\"\n className=\"min-h-24 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n <textarea\n value={form.notes}\n onChange={(event) =>\n setForm((current) => ({ ...current, notes: event.target.value }))\n }\n placeholder=\"Internal notes\"\n className=\"min-h-24 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary\"\n />\n </div>\n\n <div className=\"mt-4 flex flex-wrap gap-3\">\n <button\n type=\"button\"\n onClick={() => void handleSubmit()}\n className=\"rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text\"\n >\n {selectedCode ? 'Save changes' : 'Create code'}\n </button>\n {selectedCode ? (\n <button\n type=\"button\"\n onClick={() => {\n setSelectedCodeId(null);\n setForm({\n label: '',\n description: '',\n notes: '',\n productSlug: '',\n destinationPath: '',\n destinationUrl: '',\n });\n }}\n className=\"rounded-md border border-border-subtle bg-bg-surface px-4 py-2 text-sm font-medium text-text-primary\"\n >\n Cancel\n </button>\n ) : null}\n </div>\n </section>\n\n <section className=\"space-y-4\">\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">My codes</h2>\n {codes.length === 0 && !loading ? (\n <IllustratedEmptyState\n illustration=\"empty-data\"\n title=\"No affiliate codes yet\"\n description=\"Create your first code to start tracking attributable journeys.\"\n />\n ) : (\n <div className=\"space-y-4\">\n {codes.map((code) => {\n const shareUrl =\n code.destinationUrl ||\n `https://${code.productSlug}.com${code.destinationPath || ''}?ref=${code.code}`;\n return (\n <div\n key={code.id}\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\"\n >\n <div className=\"flex flex-wrap items-start justify-between gap-4\">\n <div>\n <p className=\"text-sm font-semibold text-text-primary\">\n {code.label || code.code}\n </p>\n <p className=\"text-xs text-text-secondary\">\n {code.code} · {code.productSlug}\n </p>\n <p className=\"mt-1 break-all text-xs text-text-secondary\">{shareUrl}</p>\n </div>\n <div className=\"flex flex-wrap gap-2\">\n <button\n type=\"button\"\n onClick={() => handleEdit(code)}\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n Edit\n </button>\n <button\n type=\"button\"\n onClick={() => void handleQuickNote(code.id)}\n className=\"inline-flex items-center gap-1 rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary\"\n >\n <StickyNote className=\"size-3.5\" />\n Note\n </button>\n {code.status === 'ACTIVE' ? (\n <button\n type=\"button\"\n onClick={() =>\n isFluidgrids\n ? (setDeactivateError(null),\n setCodeToDeactivate({\n id: code.id,\n label: code.label || code.code,\n }))\n : void handleDeactivate(code.id)\n }\n className=\"rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-status-error-text\"\n >\n Deactivate\n </button>\n ) : null}\n </div>\n </div>\n <div className=\"mt-4 grid gap-3 sm:grid-cols-2 xl:grid-cols-4\">\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Visits</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalVisits}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Signups</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalSignups}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Paid conversions</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {code.totalPaidConversions + code.totalStorePurchases}\n </p>\n </div>\n <div className=\"rounded-md border border-border-subtle bg-bg-surface p-3\">\n <p className=\"text-xs text-text-secondary\">Rewards earned</p>\n <p className=\"text-lg font-semibold text-text-primary\">\n {formatCurrency(code.totalRewardAmount, 'USD')}\n </p>\n </div>\n </div>\n {code.notes ? (\n <p className=\"mt-3 text-sm text-text-secondary\">{code.notes}</p>\n ) : null}\n </div>\n );\n })}\n </div>\n )}\n </div>\n\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-4\">\n <h2 className=\"mb-4 text-lg font-semibold text-text-primary\">\n Recent attributed journeys\n </h2>\n {journeys.length === 0 ? (\n <IllustratedEmptyState\n illustration=\"empty-people\"\n title=\"No journeys yet\"\n description=\"Journeys will appear as visitors land on your affiliate links.\"\n />\n ) : (\n <ResponsiveTable\n data={journeys}\n rowKey={(journey) => journey.id}\n columns={journeyColumns}\n />\n )}\n </div>\n </section>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAmBA,IAAMA,IAA4D;CAChE;EAAE,KAAK;EAAQ,QAAQ;EAAQ,UAAU;EAAW,OAAO,MAAYC,EAAQ;CAAU;CACzF;EAAE,KAAK;EAAW,QAAQ;EAAW,OAAO,MAAYA,EAAQ;CAAY;CAC5E;EACE,KAAK;EACL,QAAQ;EACR,OAAO,MAAYA,EAAQ,eAAeA,EAAQ,eAAe;CACnE;CACA;EAAE,KAAK;EAAW,QAAQ;EAAW,OAAO,MAAYA,EAAQ,oBAAoB;CAAI;CACxF;EAAE,KAAK;EAAU,QAAQ;EAAU,OAAO,MAAYA,EAAQ;CAAO;CACrE;EACE,KAAK;EACL,QAAQ;EACR,OAAO,MAAYC,EAAeD,EAAQ,aAAa;CACzD;AACF,GAcaE,UAAmC;CAC9C,IAAMC,IAAcC,EAAsB,GACpCC,IAAeC,GAAuB,GACtC,CAACC,GAAkBC,KAAuBC,EAC9C,IACF,GACM,CAACC,GAAgBC,KAAqBF,EAAS,EAAK,GACpD,CAACG,GAAiBC,KAAsBJ,EAAwB,IAAI,GACpE,CAACK,GAAkBC,KAAuBN,EAAwB,IAAI,GACtE,EAAE,YAASO,EAAuB,GAClC,EAAE,kBAAe,cAAW,aAAUC,EAAW,GAEjD,CAACC,GAAOC,KAAYV,E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