@burdenoff/microfe-billing 2026.624.1 → 2026.624.3

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.
Files changed (29) hide show
  1. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js +125 -150
  2. package/dist/billing/modules/affiliate/pages/AffiliateDashboardPage.js.map +1 -1
  3. package/dist/billing/modules/billing/pages/InvoiceDetailPage.js +146 -153
  4. package/dist/billing/modules/billing/pages/InvoiceDetailPage.js.map +1 -1
  5. package/dist/billing/modules/billing/pages/RefundsPage.js +143 -149
  6. package/dist/billing/modules/billing/pages/RefundsPage.js.map +1 -1
  7. package/dist/billing/modules/billing/pages/TransactionsPage.js +232 -252
  8. package/dist/billing/modules/billing/pages/TransactionsPage.js.map +1 -1
  9. package/dist/billing/modules/coupons/pages/CouponDetailPage.js +164 -179
  10. package/dist/billing/modules/coupons/pages/CouponDetailPage.js.map +1 -1
  11. package/dist/billing/modules/coupons/pages/CouponsListPage.js +206 -244
  12. package/dist/billing/modules/coupons/pages/CouponsListPage.js.map +1 -1
  13. package/dist/billing/modules/coupons/pages/CreateCouponPage.js +1 -1
  14. package/dist/billing/modules/coupons/pages/CreateCouponPage.js.map +1 -1
  15. package/dist/billing/modules/earnings/pages/EarningsPage.js +229 -291
  16. package/dist/billing/modules/earnings/pages/EarningsPage.js.map +1 -1
  17. package/dist/billing/modules/earnings/pages/PayoutAdminPage.js +69 -74
  18. package/dist/billing/modules/earnings/pages/PayoutAdminPage.js.map +1 -1
  19. package/dist/billing/modules/earnings/pages/PayoutsPage.js +142 -148
  20. package/dist/billing/modules/earnings/pages/PayoutsPage.js.map +1 -1
  21. package/dist/billing/modules/settings/pages/SettingsPage.js +125 -117
  22. package/dist/billing/modules/settings/pages/SettingsPage.js.map +1 -1
  23. package/dist/billing/modules/settings/pages/TeamPermissionsPage.js +78 -66
  24. package/dist/billing/modules/settings/pages/TeamPermissionsPage.js.map +1 -1
  25. package/dist/billing/modules/subscriptions/components/ManageSeatsModal.js +68 -83
  26. package/dist/billing/modules/subscriptions/components/ManageSeatsModal.js.map +1 -1
  27. package/dist/billing/shared/ui/MetricCard.js +1 -1
  28. package/dist/billing/shared/ui/MetricCard.js.map +1 -1
  29. package/package.json +1 -1
@@ -14,87 +14,120 @@ import { addAffiliateCodeNote as d, createAffiliateCode as f, deactivateAffiliat
14
14
  import { useEffect as v, useMemo as y, useState as b } from "react";
15
15
  import { Link2 as x, Plus as S, RefreshCw as C, StickyNote as w, Ticket as T, TrendingUp as E, Users as D } from "lucide-react";
16
16
  import { jsx as O, jsxs as k } from "react/jsx-runtime";
17
+ import { ResponsiveTable as A } from "@burdenoff/fe-libs/ui";
17
18
  //#region src/billing/modules/affiliate/pages/AffiliateDashboardPage.tsx
18
- var A = () => {
19
- let A = u(), { emit: j } = o(), { apiGatewayUrl: M, authToken: N, orgId: P } = e(), [F, I] = b([]), [L, R] = b([]), [z, B] = b(null), [V, H] = b(!0), [U, W] = b(null), [G, K] = b(null), [q, J] = b({
19
+ var j = [
20
+ {
21
+ key: "code",
22
+ header: "Code",
23
+ priority: "primary",
24
+ cell: (e) => e.codeValue
25
+ },
26
+ {
27
+ key: "product",
28
+ header: "Product",
29
+ cell: (e) => e.productSlug
30
+ },
31
+ {
32
+ key: "path",
33
+ header: "Path",
34
+ cell: (e) => e.currentPath || e.landingPath || "-"
35
+ },
36
+ {
37
+ key: "country",
38
+ header: "Country",
39
+ cell: (e) => e.geographyCountry || "-"
40
+ },
41
+ {
42
+ key: "status",
43
+ header: "Status",
44
+ cell: (e) => e.status
45
+ },
46
+ {
47
+ key: "visited",
48
+ header: "Visited",
49
+ cell: (e) => c(e.lastVisitedAt)
50
+ }
51
+ ], M = () => {
52
+ let c = u(), { emit: M } = o(), { apiGatewayUrl: N, authToken: P, orgId: F } = e(), [I, L] = b([]), [R, z] = b([]), [B, V] = b(null), [H, U] = b(!0), [W, G] = b(null), [K, q] = b(null), [J, Y] = b({
20
53
  label: "",
21
54
  description: "",
22
55
  notes: "",
23
56
  productSlug: "",
24
57
  destinationPath: "",
25
58
  destinationUrl: ""
26
- }), Y = y(() => ({
27
- apiGatewayUrl: M,
28
- authToken: N,
29
- orgId: P
59
+ }), X = y(() => ({
60
+ apiGatewayUrl: N,
61
+ authToken: P,
62
+ orgId: F
30
63
  }), [
31
- M,
32
64
  N,
33
- P
34
- ]), X = async () => {
35
- H(!0), W(null);
65
+ P,
66
+ F
67
+ ]), Z = async () => {
68
+ U(!0), G(null);
36
69
  try {
37
70
  let [e, t, n] = await Promise.all([
38
- h(Y),
39
- m(Y),
40
- g(Y)
71
+ h(X),
72
+ m(X),
73
+ g(X)
41
74
  ]);
42
- I(e), B(t), R(n);
75
+ L(e), V(t), z(n);
43
76
  } catch (e) {
44
- W(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load affiliate dashboard"));
77
+ G(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to load affiliate dashboard"));
45
78
  } finally {
46
- H(!1);
79
+ U(!1);
47
80
  }
48
81
  };
49
82
  if (v(() => {
50
- X();
51
- }, [Y]), !A.canViewBillingAccount) return /* @__PURE__ */ O(t, { message: "You don't have permission to view affiliate analytics." });
52
- if (U && l(U)) return /* @__PURE__ */ O(a, {
83
+ Z();
84
+ }, [X]), !c.canViewBillingAccount) return /* @__PURE__ */ O(t, { message: "You don't have permission to view affiliate analytics." });
85
+ if (W && l(W)) return /* @__PURE__ */ O(a, {
53
86
  title: "Affiliate service unavailable",
54
- message: U.message,
55
- onRetry: () => void X(),
87
+ message: W.message,
88
+ onRetry: () => void Z(),
56
89
  showRetry: !0
57
90
  });
58
- let Z = F.find((e) => e.id === G) ?? null, Q = async () => {
59
- if (!q.productSlug.trim()) {
60
- W(/* @__PURE__ */ Error("Product slug is required"));
91
+ let Q = I.find((e) => e.id === K) ?? null, $ = async () => {
92
+ if (!J.productSlug.trim()) {
93
+ G(/* @__PURE__ */ Error("Product slug is required"));
61
94
  return;
62
95
  }
63
96
  try {
64
- Z ? (await _(Z.id, {
65
- label: q.label,
66
- description: q.description,
67
- notes: q.notes,
68
- destinationPath: q.destinationPath,
69
- destinationUrl: q.destinationUrl
70
- }, Y), j("billing.affiliate_code.updated", {
97
+ Q ? (await _(Q.id, {
98
+ label: J.label,
99
+ description: J.description,
100
+ notes: J.notes,
101
+ destinationPath: J.destinationPath,
102
+ destinationUrl: J.destinationUrl
103
+ }, X), M("billing.affiliate_code.updated", {
71
104
  route: "/billing/affiliate",
72
- entityId: Z.id,
105
+ entityId: Q.id,
73
106
  source: "affiliate-dashboard"
74
- })) : j("billing.affiliate_code.created", {
107
+ })) : M("billing.affiliate_code.created", {
75
108
  route: "/billing/affiliate",
76
109
  entityId: (await f({
77
- label: q.label,
78
- description: q.description,
79
- notes: q.notes,
80
- productSlug: q.productSlug,
81
- destinationPath: q.destinationPath,
82
- destinationUrl: q.destinationUrl
83
- }, Y)).id,
110
+ label: J.label,
111
+ description: J.description,
112
+ notes: J.notes,
113
+ productSlug: J.productSlug,
114
+ destinationPath: J.destinationPath,
115
+ destinationUrl: J.destinationUrl
116
+ }, X)).id,
84
117
  source: "affiliate-dashboard"
85
- }), K(null), J({
118
+ }), q(null), Y({
86
119
  label: "",
87
120
  description: "",
88
121
  notes: "",
89
122
  productSlug: "",
90
123
  destinationPath: "",
91
124
  destinationUrl: ""
92
- }), await X();
125
+ }), await Z();
93
126
  } catch (e) {
94
- W(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to save affiliate code"));
127
+ G(e instanceof Error ? e : /* @__PURE__ */ Error("Failed to save affiliate code"));
95
128
  }
96
- }, $ = (e) => {
97
- K(e.id), J({
129
+ }, ee = (e) => {
130
+ q(e.id), Y({
98
131
  label: e.label ?? "",
99
132
  description: e.description ?? "",
100
133
  notes: e.notes ?? "",
@@ -102,38 +135,38 @@ var A = () => {
102
135
  destinationPath: e.destinationPath ?? "",
103
136
  destinationUrl: e.destinationUrl ?? ""
104
137
  });
105
- }, ee = async (e) => {
106
- await p(e, Y), j("billing.affiliate_code.deactivated", {
138
+ }, te = async (e) => {
139
+ await p(e, X), M("billing.affiliate_code.deactivated", {
107
140
  route: "/billing/affiliate",
108
141
  entityId: e,
109
142
  source: "affiliate-dashboard"
110
- }), await X();
111
- }, te = async (e) => {
143
+ }), await Z();
144
+ }, ne = async (e) => {
112
145
  let t = window.prompt("Add an internal note for this affiliate code");
113
- t && (await d(e, t, Y), j("billing.affiliate_code.note_added", {
146
+ t && (await d(e, t, X), M("billing.affiliate_code.note_added", {
114
147
  route: "/billing/affiliate",
115
148
  entityId: e,
116
149
  source: "affiliate-dashboard"
117
- }), await X());
118
- }, ne = z ? [
150
+ }), await Z());
151
+ }, re = B ? [
119
152
  {
120
153
  title: "Codes",
121
- value: z.totalCodes,
154
+ value: B.totalCodes,
122
155
  icon: /* @__PURE__ */ O(T, { className: "size-5" })
123
156
  },
124
157
  {
125
158
  title: "Visits",
126
- value: z.totalVisits,
159
+ value: B.totalVisits,
127
160
  icon: /* @__PURE__ */ O(D, { className: "size-5" })
128
161
  },
129
162
  {
130
163
  title: "Journeys",
131
- value: z.totalJourneys,
164
+ value: B.totalJourneys,
132
165
  icon: /* @__PURE__ */ O(x, { className: "size-5" })
133
166
  },
134
167
  {
135
168
  title: "Revenue influenced",
136
- value: s(z.totalRevenueAmount, "USD"),
169
+ value: s(B.totalRevenueAmount, "USD"),
137
170
  icon: /* @__PURE__ */ O(E, { className: "size-5" })
138
171
  }
139
172
  ] : [];
@@ -145,12 +178,12 @@ var A = () => {
145
178
  description: "Create referral codes, add internal notes, and monitor attributed journeys.",
146
179
  actions: /* @__PURE__ */ k("button", {
147
180
  type: "button",
148
- onClick: () => void X(),
181
+ onClick: () => void Z(),
149
182
  className: "inline-flex items-center gap-2 rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm font-medium text-text-primary",
150
183
  children: [/* @__PURE__ */ O(C, { className: "size-4" }), "Refresh"]
151
184
  })
152
185
  }),
153
- V ? /* @__PURE__ */ O("div", {
186
+ H ? /* @__PURE__ */ O("div", {
154
187
  className: "grid gap-4 md:grid-cols-2 xl:grid-cols-4",
155
188
  children: [
156
189
  1,
@@ -158,17 +191,17 @@ var A = () => {
158
191
  3,
159
192
  4
160
193
  ].map((e) => /* @__PURE__ */ O("div", { className: "h-28 animate-pulse rounded-lg border border-border-subtle bg-bg-surface" }, e))
161
- }) : z ? /* @__PURE__ */ O("div", {
194
+ }) : B ? /* @__PURE__ */ O("div", {
162
195
  className: "grid gap-4 md:grid-cols-2 xl:grid-cols-4",
163
- children: ne.map((e) => /* @__PURE__ */ O(r, {
196
+ children: re.map((e) => /* @__PURE__ */ O(r, {
164
197
  label: e.title,
165
198
  value: e.value,
166
199
  icon: e.icon
167
200
  }, e.title))
168
201
  }) : null,
169
- U && !l(U) ? /* @__PURE__ */ O("div", {
202
+ W && !l(W) ? /* @__PURE__ */ O("div", {
170
203
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4 text-sm text-status-error-text",
171
- children: U.message
204
+ children: W.message
172
205
  }) : null,
173
206
  /* @__PURE__ */ k("div", {
174
207
  className: "grid gap-6 xl:grid-cols-[1.1fr,1.9fr]",
@@ -179,15 +212,15 @@ var A = () => {
179
212
  className: "mb-4 flex items-center justify-between",
180
213
  children: [/* @__PURE__ */ O("h2", {
181
214
  className: "text-lg font-semibold text-text-primary",
182
- children: Z ? "Update affiliate code" : "Create affiliate code"
183
- }), Z ? null : /* @__PURE__ */ O(S, { className: "size-4 text-text-secondary" })]
215
+ children: Q ? "Update affiliate code" : "Create affiliate code"
216
+ }), Q ? null : /* @__PURE__ */ O(S, { className: "size-4 text-text-secondary" })]
184
217
  }),
185
218
  /* @__PURE__ */ k("div", {
186
219
  className: "space-y-3",
187
220
  children: [
188
221
  /* @__PURE__ */ O("input", {
189
- value: q.label,
190
- onChange: (e) => J((t) => ({
222
+ value: J.label,
223
+ onChange: (e) => Y((t) => ({
191
224
  ...t,
192
225
  label: e.target.value
193
226
  })),
@@ -195,18 +228,18 @@ var A = () => {
195
228
  className: "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary"
196
229
  }),
197
230
  /* @__PURE__ */ O("input", {
198
- value: q.productSlug,
199
- onChange: (e) => J((t) => ({
231
+ value: J.productSlug,
232
+ onChange: (e) => Y((t) => ({
200
233
  ...t,
201
234
  productSlug: e.target.value
202
235
  })),
203
236
  placeholder: "Product slug (eg. bigconsole)",
204
237
  className: "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary",
205
- disabled: !!Z
238
+ disabled: !!Q
206
239
  }),
207
240
  /* @__PURE__ */ O("input", {
208
- value: q.destinationPath,
209
- onChange: (e) => J((t) => ({
241
+ value: J.destinationPath,
242
+ onChange: (e) => Y((t) => ({
210
243
  ...t,
211
244
  destinationPath: e.target.value
212
245
  })),
@@ -214,8 +247,8 @@ var A = () => {
214
247
  className: "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary"
215
248
  }),
216
249
  /* @__PURE__ */ O("input", {
217
- value: q.destinationUrl,
218
- onChange: (e) => J((t) => ({
250
+ value: J.destinationUrl,
251
+ onChange: (e) => Y((t) => ({
219
252
  ...t,
220
253
  destinationUrl: e.target.value
221
254
  })),
@@ -223,8 +256,8 @@ var A = () => {
223
256
  className: "w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary"
224
257
  }),
225
258
  /* @__PURE__ */ O("textarea", {
226
- value: q.description,
227
- onChange: (e) => J((t) => ({
259
+ value: J.description,
260
+ onChange: (e) => Y((t) => ({
228
261
  ...t,
229
262
  description: e.target.value
230
263
  })),
@@ -232,8 +265,8 @@ var A = () => {
232
265
  className: "min-h-24 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary"
233
266
  }),
234
267
  /* @__PURE__ */ O("textarea", {
235
- value: q.notes,
236
- onChange: (e) => J((t) => ({
268
+ value: J.notes,
269
+ onChange: (e) => Y((t) => ({
237
270
  ...t,
238
271
  notes: e.target.value
239
272
  })),
@@ -246,13 +279,13 @@ var A = () => {
246
279
  className: "mt-4 flex flex-wrap gap-3",
247
280
  children: [/* @__PURE__ */ O("button", {
248
281
  type: "button",
249
- onClick: () => void Q(),
282
+ onClick: () => void $(),
250
283
  className: "rounded-md bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text",
251
- children: Z ? "Save changes" : "Create code"
252
- }), Z ? /* @__PURE__ */ O("button", {
284
+ children: Q ? "Save changes" : "Create code"
285
+ }), Q ? /* @__PURE__ */ O("button", {
253
286
  type: "button",
254
287
  onClick: () => {
255
- K(null), J({
288
+ q(null), Y({
256
289
  label: "",
257
290
  description: "",
258
291
  notes: "",
@@ -273,13 +306,13 @@ var A = () => {
273
306
  children: [/* @__PURE__ */ O("h2", {
274
307
  className: "mb-4 text-lg font-semibold text-text-primary",
275
308
  children: "My codes"
276
- }), F.length === 0 && !V ? /* @__PURE__ */ O(i, {
309
+ }), I.length === 0 && !H ? /* @__PURE__ */ O(i, {
277
310
  icon: /* @__PURE__ */ O(T, { className: "size-8" }),
278
311
  title: "No affiliate codes yet",
279
312
  description: "Create your first code to start tracking attributable journeys."
280
313
  }) : /* @__PURE__ */ O("div", {
281
314
  className: "space-y-4",
282
- children: F.map((e) => {
315
+ children: I.map((e) => {
283
316
  let t = e.destinationUrl || `https://${e.productSlug}.com${e.destinationPath || ""}?ref=${e.code}`;
284
317
  return /* @__PURE__ */ k("div", {
285
318
  className: "rounded-lg border border-border-subtle bg-bg-surface p-4",
@@ -308,19 +341,19 @@ var A = () => {
308
341
  children: [
309
342
  /* @__PURE__ */ O("button", {
310
343
  type: "button",
311
- onClick: () => $(e),
344
+ onClick: () => ee(e),
312
345
  className: "rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-text-primary",
313
346
  children: "Edit"
314
347
  }),
315
348
  /* @__PURE__ */ k("button", {
316
349
  type: "button",
317
- onClick: () => void te(e.id),
350
+ onClick: () => void ne(e.id),
318
351
  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",
319
352
  children: [/* @__PURE__ */ O(w, { className: "size-3.5" }), "Note"]
320
353
  }),
321
354
  e.status === "ACTIVE" ? /* @__PURE__ */ O("button", {
322
355
  type: "button",
323
- onClick: () => void ee(e.id),
356
+ onClick: () => void te(e.id),
324
357
  className: "rounded-md border border-border-subtle px-3 py-1.5 text-xs font-medium text-status-error-text",
325
358
  children: "Deactivate"
326
359
  }) : null
@@ -385,72 +418,14 @@ var A = () => {
385
418
  children: [/* @__PURE__ */ O("h2", {
386
419
  className: "mb-4 text-lg font-semibold text-text-primary",
387
420
  children: "Recent attributed journeys"
388
- }), L.length === 0 ? /* @__PURE__ */ O(i, {
421
+ }), R.length === 0 ? /* @__PURE__ */ O(i, {
389
422
  icon: /* @__PURE__ */ O(D, { className: "size-8" }),
390
423
  title: "No journeys yet",
391
424
  description: "Journeys will appear as visitors land on your affiliate links."
392
- }) : /* @__PURE__ */ O("div", {
393
- className: "overflow-x-auto",
394
- children: /* @__PURE__ */ k("table", {
395
- className: "min-w-full text-sm",
396
- children: [/* @__PURE__ */ O("thead", { children: /* @__PURE__ */ k("tr", {
397
- className: "border-b border-border-subtle text-left text-text-secondary",
398
- children: [
399
- /* @__PURE__ */ O("th", {
400
- className: "px-3 py-2",
401
- children: "Code"
402
- }),
403
- /* @__PURE__ */ O("th", {
404
- className: "px-3 py-2",
405
- children: "Product"
406
- }),
407
- /* @__PURE__ */ O("th", {
408
- className: "px-3 py-2",
409
- children: "Path"
410
- }),
411
- /* @__PURE__ */ O("th", {
412
- className: "px-3 py-2",
413
- children: "Country"
414
- }),
415
- /* @__PURE__ */ O("th", {
416
- className: "px-3 py-2",
417
- children: "Status"
418
- }),
419
- /* @__PURE__ */ O("th", {
420
- className: "px-3 py-2",
421
- children: "Visited"
422
- })
423
- ]
424
- }) }), /* @__PURE__ */ O("tbody", { children: L.map((e) => /* @__PURE__ */ k("tr", {
425
- className: "border-b border-border-subtle/70 text-text-primary",
426
- children: [
427
- /* @__PURE__ */ O("td", {
428
- className: "px-3 py-2 font-medium",
429
- children: e.codeValue
430
- }),
431
- /* @__PURE__ */ O("td", {
432
- className: "px-3 py-2",
433
- children: e.productSlug
434
- }),
435
- /* @__PURE__ */ O("td", {
436
- className: "px-3 py-2",
437
- children: e.currentPath || e.landingPath || "-"
438
- }),
439
- /* @__PURE__ */ O("td", {
440
- className: "px-3 py-2",
441
- children: e.geographyCountry || "-"
442
- }),
443
- /* @__PURE__ */ O("td", {
444
- className: "px-3 py-2",
445
- children: e.status
446
- }),
447
- /* @__PURE__ */ O("td", {
448
- className: "px-3 py-2",
449
- children: c(e.lastVisitedAt)
450
- })
451
- ]
452
- }, e.id)) })]
453
- })
425
+ }) : /* @__PURE__ */ O(A, {
426
+ data: R,
427
+ rowKey: (e) => e.id,
428
+ columns: j
454
429
  })]
455
430
  })]
456
431
  })]
@@ -459,6 +434,6 @@ var A = () => {
459
434
  });
460
435
  };
461
436
  //#endregion
462
- export { A as AffiliateDashboardPage };
437
+ export { M as AffiliateDashboardPage };
463
438
 
464
439
  //# sourceMappingURL=AffiliateDashboardPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"AffiliateDashboardPage.js","names":[],"sources":["../../../../../src/billing/modules/affiliate/pages/AffiliateDashboardPage.tsx"],"sourcesContent":["import { useEffect, useMemo, useState, type FC } from 'react';\nimport { Link2, Plus, RefreshCw, StickyNote, Ticket, TrendingUp, Users } from 'lucide-react';\n\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport {\n AccessDenied,\n EmptyState,\n PageHeader,\n ServerError,\n StatCard,\n} from '../../../shared/components';\nimport { formatCurrency, formatDateTime, isServerError } from '../../../shared/utils';\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 { 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 = 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 };\n\n useEffect(() => {\n void loadData();\n }, [requestContext]);\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 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 <PageHeader\n title=\"Affiliate codes\"\n description=\"Create referral codes, add internal notes, and monitor attributed journeys.\"\n actions={\n <button\n type=\"button\"\n onClick={() => void loadData()}\n className=\"inline-flex items-center gap-2 rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm font-medium text-text-primary\"\n >\n <RefreshCw className=\"size-4\" />\n Refresh\n </button>\n }\n />\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 <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 ) : 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-subtle bg-bg-surface p-4\">\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 <EmptyState\n icon={<Ticket className=\"size-8\" />}\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={() => void handleDeactivate(code.id)}\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 <EmptyState\n icon={<Users className=\"size-8\" />}\n title=\"No journeys yet\"\n description=\"Journeys will appear as visitors land on your affiliate links.\"\n />\n ) : (\n <div className=\"overflow-x-auto\">\n <table className=\"min-w-full text-sm\">\n <thead>\n <tr className=\"border-b border-border-subtle text-left text-text-secondary\">\n <th className=\"px-3 py-2\">Code</th>\n <th className=\"px-3 py-2\">Product</th>\n <th className=\"px-3 py-2\">Path</th>\n <th className=\"px-3 py-2\">Country</th>\n <th className=\"px-3 py-2\">Status</th>\n <th className=\"px-3 py-2\">Visited</th>\n </tr>\n </thead>\n <tbody>\n {journeys.map((journey) => (\n <tr key={journey.id} className=\"border-b border-border-subtle/70 text-text-primary\">\n <td className=\"px-3 py-2 font-medium\">{journey.codeValue}</td>\n <td className=\"px-3 py-2\">{journey.productSlug}</td>\n <td className=\"px-3 py-2\">\n {journey.currentPath || journey.landingPath || '-'}\n </td>\n <td className=\"px-3 py-2\">{journey.geographyCountry || '-'}</td>\n <td className=\"px-3 py-2\">{journey.status}</td>\n <td className=\"px-3 py-2\">{formatDateTime(journey.lastVisitedAt)}</td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </div>\n </section>\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AA2BA,IAAa,UAAmC;CAC9C,IAAM,IAAc,GAAuB,EACrC,EAAE,YAAS,GAAwB,EACnC,EAAE,kBAAe,cAAW,aAAU,GAAY,EAElD,CAAC,GAAO,KAAY,EAA0B,EAAE,CAAC,EACjD,CAAC,GAAU,KAAe,EAA6B,EAAE,CAAC,EAC1D,CAAC,GAAW,KAAgB,EAA2C,KAAK,EAC5E,CAAC,GAAS,KAAc,EAAS,GAAK,EACtC,CAAC,GAAO,KAAY,EAAuB,KAAK,EAChD,CAAC,GAAgB,KAAqB,EAAwB,KAAK,EACnE,CAAC,GAAM,KAAW,EAAS;EAC/B,OAAO;EACP,aAAa;EACb,OAAO;EACP,aAAa;EACb,iBAAiB;EACjB,gBAAgB;EACjB,CAAC,EAEI,IAAiB,SACd;EACL;EACA;EACA;EACD,GACD;EAAC;EAAe;EAAW;EAAM,CAClC,EAEK,IAAW,YAAY;AAE3B,EADA,EAAW,GAAK,EAChB,EAAS,KAAK;AACd,MAAI;GACF,IAAM,CAAC,GAAa,GAAiB,KAAkB,MAAM,QAAQ,IAAI;IACvE,EAAsB,EAAe;IACrC,EAA0B,EAAe;IACzC,EAAyB,EAAe;IACzC,CAAC;AAGF,GAFA,EAAS,EAAY,EACrB,EAAa,EAAgB,EAC7B,EAAY,EAAe;WACpB,GAAW;AAClB,KACE,aAAqB,QAAQ,IAAY,gBAAI,MAAM,qCAAqC,CACzF;YACO;AACR,KAAW,GAAM;;;AAQrB,KAJA,QAAgB;AACT,KAAU;IACd,CAAC,EAAe,CAAC,EAEhB,CAAC,EAAY,sBACf,QAAO,kBAAC,GAAD,EAAc,SAAQ,0DAA2D,CAAA;AAG1F,KAAI,KAAS,EAAc,EAAM,CAC/B,QACE,kBAAC,GAAD;EACE,O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,WAAU,UAAW,CAAA;OAClC,OAAM;OACN,aAAY;OACZ,CAAA,GAEF,kBAAC,OAAD;OAAK,WAAU;iBACb,kBAAC,SAAD;QAAO,WAAU;kBAAjB,CACE,kBAAC,SAAD,EAAA,UACE,kBAAC,MAAD;SAAI,WAAU;mBAAd;UACE,kBAAC,MAAD;WAAI,WAAU;qBAAY;WAAS,CAAA;UACnC,kBAAC,MAAD;WAAI,WAAU;qBAAY;WAAY,CAAA;UACtC,kBAAC,MAAD;WAAI,WAAU;qBAAY;WAAS,CAAA;UACnC,kBAAC,MAAD;WAAI,WAAU;qBAAY;WAAY,CAAA;UACtC,kBAAC,MAAD;WAAI,WAAU;qBAAY;WAAW,CAAA;UACrC,kBAAC,MAAD;WAAI,WAAU;qBAAY;WAAY,CAAA;UACnC;YACC,CAAA,EACR,kBAAC,SAAD,EAAA,UACG,EAAS,KAAK,MACb,kBAAC,MAAD;SAAqB,WAAU;mBAA/B;UACE,kBAAC,MAAD;WAAI,WAAU;qBAAyB,EAAQ;WAAe,CAAA;UAC9D,kBAAC,MAAD;WAAI,WAAU;qBAAa,EAAQ;WAAiB,CAAA;UACpD,kBAAC,MAAD;WAAI,WAAU;qBACX,EAAQ,eAAe,EAAQ,eAAe;WAC5C,CAAA;UACL,kBAAC,MAAD;WAAI,WAAU;qBAAa,EAAQ,oBAAoB;WAAS,CAAA;UAChE,kBAAC,MAAD;WAAI,WAAU;qBAAa,EAAQ;WAAY,CAAA;UAC/C,kBAAC,MAAD;WAAI,WAAU;qBAAa,EAAe,EAAQ,cAAc;WAAM,CAAA;UACnE;WATI,EAAQ,GASZ,CACL,EACI,CAAA,CACF;;OACJ,CAAA,CAEJ;QACE;OACN;;GACF"}
1
+ {"version":3,"file":"AffiliateDashboardPage.js","names":[],"sources":["../../../../../src/billing/modules/affiliate/pages/AffiliateDashboardPage.tsx"],"sourcesContent":["import { 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 {\n AccessDenied,\n EmptyState,\n PageHeader,\n ServerError,\n StatCard,\n} from '../../../shared/components';\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 { 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 = 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 };\n\n useEffect(() => {\n void loadData();\n }, [requestContext]);\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 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 <PageHeader\n title=\"Affiliate codes\"\n description=\"Create referral codes, add internal notes, and monitor attributed journeys.\"\n actions={\n <button\n type=\"button\"\n onClick={() => void loadData()}\n className=\"inline-flex items-center gap-2 rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm font-medium text-text-primary\"\n >\n <RefreshCw className=\"size-4\" />\n Refresh\n </button>\n }\n />\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 <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 ) : 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-subtle bg-bg-surface p-4\">\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 <EmptyState\n icon={<Ticket className=\"size-8\" />}\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={() => void handleDeactivate(code.id)}\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 <EmptyState\n icon={<Users className=\"size-8\" />}\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":";;;;;;;;;;;;;;;;;;AAgBA,IAAM,IAA4D;CAChE;EAAE,KAAK;EAAQ,QAAQ;EAAQ,UAAU;EAAW,OAAO,MAAY,EAAQ;EAAW;CAC1F;EAAE,KAAK;EAAW,QAAQ;EAAW,OAAO,MAAY,EAAQ;EAAa;CAC7E;EACE,KAAK;EACL,QAAQ;EACR,OAAO,MAAY,EAAQ,eAAe,EAAQ,eAAe;EAClE;CACD;EAAE,KAAK;EAAW,QAAQ;EAAW,OAAO,MAAY,EAAQ,oBAAoB;EAAK;CACzF;EAAE,KAAK;EAAU,QAAQ;EAAU,OAAO,MAAY,EAAQ;EAAQ;CACtE;EACE,KAAK;EACL,QAAQ;EACR,OAAO,MAAY,EAAe,EAAQ,cAAc;EACzD;CACF,EAcY,UAAmC;CAC9C,IAAM,IAAc,GAAuB,EACrC,EAAE,YAAS,GAAwB,EACnC,EAAE,kBAAe,cAAW,aAAU,GAAY,EAElD,CAAC,GAAO,KAAY,EAA0B,EAAE,CAAC,EACjD,CAAC,GAAU,KAAe,EAA6B,EAAE,CAAC,EAC1D,CAAC,GAAW,KAAgB,EAA2C,KAAK,EAC5E,CAAC,GAAS,KAAc,EAAS,GAAK,EACtC,CAAC,GAAO,KAAY,EAAuB,KAAK,EAChD,CAAC,GAAgB,KAAqB,EAAwB,KAAK,EACnE,CAAC,GAAM,KAAW,EAAS;EAC/B,OAAO;EACP,aAAa;EACb,OAAO;EACP,aAAa;EACb,iBAAiB;EACjB,gBAAgB;EACjB,CAAC,EAEI,IAAiB,SAC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