@burdenoff/microfe-billing 2026.515.3 → 2026.515.4
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreditWithdrawalPage.d.ts","sourceRoot":"","sources":["../../../../../src/billing/modules/credits/pages/CreditWithdrawalPage.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"CreditWithdrawalPage.d.ts","sourceRoot":"","sources":["../../../../../src/billing/modules/credits/pages/CreditWithdrawalPage.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAuB,KAAK,EAAE,EAAE,MAAM,OAAO,CAAC;AA2JrD,eAAO,MAAM,oBAAoB,EAAE,EA8xBlC,CAAC"}
|
|
@@ -4,32 +4,32 @@ import { useBillingEventEmitter as n } from "../../../hooks/useBillingEventEmitt
|
|
|
4
4
|
import { formatDate as r, formatRelativeTime as ee } from "../../../shared/utils/format.js";
|
|
5
5
|
import { directBillingGraphqlRequest as i } from "../../../shared/utils/directBillingGraphql.js";
|
|
6
6
|
import "../../../shared/utils/index.js";
|
|
7
|
-
import { useBillingPermissions as
|
|
8
|
-
import { CreditWithdrawalHistoryDocument as
|
|
9
|
-
import { useDefaultBillingAccount as
|
|
7
|
+
import { useBillingPermissions as te } from "../../../hooks/useBillingPermissions.js";
|
|
8
|
+
import { CreditWithdrawalHistoryDocument as a, GetCreditBalanceByTypeDocument as o, RequestCreditWithdrawalDocument as s, useGetCostOfCreditsCheckoutQuery as ne } from "../../../../generated/global-operations.js";
|
|
9
|
+
import { useDefaultBillingAccount as re } from "../../subscriptions/hooks/useSubscriptions.js";
|
|
10
10
|
import "../../subscriptions/hooks/index.js";
|
|
11
|
-
import { addPayoutAccount as
|
|
12
|
-
import { useEffect as
|
|
11
|
+
import { addPayoutAccount as ie, fetchPayoutAccounts as c } from "../../earnings/api.js";
|
|
12
|
+
import { useEffect as l, useState as u } from "react";
|
|
13
13
|
import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
|
|
14
14
|
//#region src/billing/modules/credits/pages/CreditWithdrawalPage.tsx
|
|
15
|
-
async function
|
|
15
|
+
async function ae(e, t) {
|
|
16
16
|
return (await i({
|
|
17
17
|
...t,
|
|
18
|
-
query:
|
|
18
|
+
query: o,
|
|
19
19
|
variables: { billingAccountId: e }
|
|
20
20
|
})).getCreditBalanceByType;
|
|
21
21
|
}
|
|
22
|
-
async function
|
|
22
|
+
async function oe(e, t) {
|
|
23
23
|
return (await i({
|
|
24
24
|
...t,
|
|
25
|
-
query:
|
|
25
|
+
query: s,
|
|
26
26
|
variables: { input: e }
|
|
27
27
|
})).requestCreditWithdrawal;
|
|
28
28
|
}
|
|
29
|
-
async function
|
|
29
|
+
async function se(e, t) {
|
|
30
30
|
return (await i({
|
|
31
31
|
...t,
|
|
32
|
-
query:
|
|
32
|
+
query: a,
|
|
33
33
|
variables: { billingAccountId: e }
|
|
34
34
|
})).myPayoutRequests.items;
|
|
35
35
|
}
|
|
@@ -57,7 +57,7 @@ var m = ({ label: e, value: t, description: n, highlight: r }) => /* @__PURE__ *
|
|
|
57
57
|
})
|
|
58
58
|
]
|
|
59
59
|
});
|
|
60
|
-
function
|
|
60
|
+
function ce(e) {
|
|
61
61
|
switch (e.toUpperCase()) {
|
|
62
62
|
case "PAID": return t.success.text;
|
|
63
63
|
case "APPROVED":
|
|
@@ -69,7 +69,7 @@ function se(e) {
|
|
|
69
69
|
default: return "text-muted-foreground";
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
function
|
|
72
|
+
function le(e) {
|
|
73
73
|
switch (e.toUpperCase()) {
|
|
74
74
|
case "PAID": return `${t.success.bg} ${t.success.text}`;
|
|
75
75
|
case "APPROVED":
|
|
@@ -82,74 +82,86 @@ function ce(e) {
|
|
|
82
82
|
}
|
|
83
83
|
}
|
|
84
84
|
var h = () => {
|
|
85
|
-
let i =
|
|
85
|
+
let i = te(), { billingAccount: a, isLoading: o } = re(), { apiGatewayUrl: s, authToken: h, orgId: ue } = e(), { emit: g } = n(), [_, de] = u(null), [fe, v] = u(!1), [y, b] = u(null), [pe, me] = u([]), [he, x] = u(!1), [S, ge] = u([]), [_e, C] = u(!1), [w, T] = u(""), [E, D] = u(""), [O, k] = u(""), [A, j] = u(!1), [M, N] = u(null), [ve, P] = u(!1), [F, I] = u(!1), [L, R] = u({
|
|
86
86
|
label: "",
|
|
87
87
|
type: "BANK_ACCOUNT",
|
|
88
|
+
accountHolderName: "",
|
|
88
89
|
accountNumber: "",
|
|
89
90
|
ifscCode: "",
|
|
90
91
|
routingNumber: "",
|
|
91
92
|
upiId: "",
|
|
92
93
|
country: "",
|
|
93
94
|
currency: "USD"
|
|
94
|
-
}), [
|
|
95
|
-
apiGatewayUrl:
|
|
95
|
+
}), [z, B] = u(!1), [V, H] = u(null), U = a?.id, W = () => ({
|
|
96
|
+
apiGatewayUrl: s,
|
|
96
97
|
authToken: h,
|
|
97
|
-
orgId:
|
|
98
|
-
}),
|
|
99
|
-
if (
|
|
100
|
-
|
|
98
|
+
orgId: ue
|
|
99
|
+
}), G = async () => {
|
|
100
|
+
if (U) {
|
|
101
|
+
v(!0), b(null);
|
|
101
102
|
try {
|
|
102
|
-
|
|
103
|
+
de(await ae(U, W()));
|
|
103
104
|
} catch (e) {
|
|
104
|
-
|
|
105
|
+
b(e instanceof Error ? e.message : "Failed to load balance");
|
|
105
106
|
} finally {
|
|
106
|
-
|
|
107
|
+
v(!1);
|
|
107
108
|
}
|
|
108
109
|
}
|
|
109
|
-
},
|
|
110
|
-
if (
|
|
111
|
-
|
|
110
|
+
}, K = async () => {
|
|
111
|
+
if (U) {
|
|
112
|
+
x(!0);
|
|
112
113
|
try {
|
|
113
|
-
let e = await
|
|
114
|
-
|
|
114
|
+
let e = await c(U, W());
|
|
115
|
+
me(e);
|
|
115
116
|
let t = e.find((e) => e.isDefault) ?? e[0];
|
|
116
|
-
t &&
|
|
117
|
+
t && T(t.id);
|
|
117
118
|
} catch {} finally {
|
|
118
|
-
|
|
119
|
+
x(!1);
|
|
119
120
|
}
|
|
120
121
|
}
|
|
121
|
-
},
|
|
122
|
-
if (
|
|
123
|
-
|
|
122
|
+
}, q = async () => {
|
|
123
|
+
if (U) {
|
|
124
|
+
C(!0);
|
|
124
125
|
try {
|
|
125
|
-
|
|
126
|
+
ge(await se(U, W()));
|
|
126
127
|
} catch {} finally {
|
|
127
|
-
|
|
128
|
+
C(!1);
|
|
128
129
|
}
|
|
129
130
|
}
|
|
130
131
|
};
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
}, [
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
132
|
+
l(() => {
|
|
133
|
+
U && (G(), K(), q());
|
|
134
|
+
}, [U]), l(() => {
|
|
135
|
+
a?.currency && R((e) => ({
|
|
136
|
+
...e,
|
|
137
|
+
currency: a.currency ?? "USD"
|
|
138
|
+
}));
|
|
139
|
+
}, [a?.currency]);
|
|
140
|
+
let ye = async () => {
|
|
141
|
+
if (U) {
|
|
142
|
+
H(null), B(!0);
|
|
137
143
|
try {
|
|
138
|
-
let e =
|
|
139
|
-
|
|
140
|
-
billingAccountId:
|
|
141
|
-
label:
|
|
142
|
-
type:
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
144
|
+
let e = L.country.trim().toUpperCase() === "IN" || L.country.trim().toLowerCase() === "india";
|
|
145
|
+
await ie({
|
|
146
|
+
billingAccountId: U,
|
|
147
|
+
label: L.label,
|
|
148
|
+
type: L.type,
|
|
149
|
+
accountHolderName: L.accountHolderName,
|
|
150
|
+
country: L.country || void 0,
|
|
151
|
+
currency: L.currency,
|
|
152
|
+
...L.type === "BANK_ACCOUNT" && {
|
|
153
|
+
accountNumber: L.accountNumber,
|
|
154
|
+
...e ? { ifsc: L.ifscCode } : { routingNumber: L.routingNumber }
|
|
155
|
+
},
|
|
156
|
+
...L.type === "UPI" && { upiId: L.upiId }
|
|
157
|
+
}, W()), g("billing.payout_account.added", {
|
|
147
158
|
route: "/billing/credits/withdraw",
|
|
148
|
-
entityId:
|
|
159
|
+
entityId: U,
|
|
149
160
|
source: "credit-withdrawal"
|
|
150
|
-
}), await
|
|
161
|
+
}), await K(), I(!1), R({
|
|
151
162
|
label: "",
|
|
152
163
|
type: "BANK_ACCOUNT",
|
|
164
|
+
accountHolderName: "",
|
|
153
165
|
accountNumber: "",
|
|
154
166
|
ifscCode: "",
|
|
155
167
|
routingNumber: "",
|
|
@@ -158,35 +170,41 @@ var h = () => {
|
|
|
158
170
|
currency: "USD"
|
|
159
171
|
});
|
|
160
172
|
} catch (e) {
|
|
161
|
-
|
|
173
|
+
H(e instanceof Error ? e.message : "Failed to add account");
|
|
162
174
|
} finally {
|
|
163
|
-
|
|
175
|
+
B(!1);
|
|
164
176
|
}
|
|
165
177
|
}
|
|
166
|
-
},
|
|
167
|
-
if (!
|
|
168
|
-
let e = parseFloat(
|
|
178
|
+
}, be = async () => {
|
|
179
|
+
if (!U || !w) return;
|
|
180
|
+
let e = parseFloat(E);
|
|
169
181
|
if (!(!e || e <= 0)) {
|
|
170
|
-
|
|
182
|
+
N(null), j(!0);
|
|
171
183
|
try {
|
|
172
|
-
|
|
184
|
+
g("billing.credits.withdrawal_requested", {
|
|
173
185
|
route: "/billing/credits/withdraw",
|
|
174
|
-
entityId: (await
|
|
175
|
-
billingAccountId:
|
|
186
|
+
entityId: (await oe({
|
|
187
|
+
billingAccountId: U,
|
|
176
188
|
creditAmount: e,
|
|
177
|
-
payoutAccountId:
|
|
178
|
-
notes:
|
|
179
|
-
},
|
|
189
|
+
payoutAccountId: w,
|
|
190
|
+
notes: O || void 0
|
|
191
|
+
}, W())).id,
|
|
180
192
|
source: "credit-withdrawal",
|
|
181
193
|
amount: e
|
|
182
|
-
}),
|
|
194
|
+
}), P(!0), D(""), k(""), await G(), await q();
|
|
183
195
|
} catch (e) {
|
|
184
|
-
|
|
196
|
+
N(e instanceof Error ? e.message : "Withdrawal request failed");
|
|
185
197
|
} finally {
|
|
186
|
-
|
|
198
|
+
j(!1);
|
|
187
199
|
}
|
|
188
200
|
}
|
|
189
|
-
}
|
|
201
|
+
}, J = a?.currency ?? "USD", Y = parseFloat(E) || 0, { data: xe, loading: X } = ne({
|
|
202
|
+
variables: {
|
|
203
|
+
creditAmount: Y,
|
|
204
|
+
currency: J
|
|
205
|
+
},
|
|
206
|
+
skip: Y <= 0 || !a
|
|
207
|
+
}), Z = xe?.getCostOfCredits?.amount;
|
|
190
208
|
if (!i.canWithdrawCredits) return /* @__PURE__ */ f("div", {
|
|
191
209
|
className: "flex items-center justify-center h-full min-h-[400px]",
|
|
192
210
|
children: /* @__PURE__ */ p("div", {
|
|
@@ -218,7 +236,20 @@ var h = () => {
|
|
|
218
236
|
]
|
|
219
237
|
})
|
|
220
238
|
});
|
|
221
|
-
if (
|
|
239
|
+
if (!o && !a) return /* @__PURE__ */ f("div", {
|
|
240
|
+
className: "flex items-center justify-center h-full min-h-[400px]",
|
|
241
|
+
children: /* @__PURE__ */ p("div", {
|
|
242
|
+
className: "text-center space-y-2",
|
|
243
|
+
children: [/* @__PURE__ */ f("h2", {
|
|
244
|
+
className: "text-lg font-semibold text-foreground",
|
|
245
|
+
children: "No Billing Account"
|
|
246
|
+
}), /* @__PURE__ */ f("p", {
|
|
247
|
+
className: "text-sm text-muted-foreground",
|
|
248
|
+
children: "You need a billing account to withdraw credits."
|
|
249
|
+
})]
|
|
250
|
+
})
|
|
251
|
+
});
|
|
252
|
+
if (o && !a) return /* @__PURE__ */ p("div", {
|
|
222
253
|
className: "space-y-6 p-6",
|
|
223
254
|
children: [/* @__PURE__ */ f("div", { className: "h-8 w-64 bg-muted animate-pulse rounded" }), /* @__PURE__ */ f("div", {
|
|
224
255
|
className: "grid grid-cols-2 lg:grid-cols-4 gap-4",
|
|
@@ -233,7 +264,7 @@ var h = () => {
|
|
|
233
264
|
}, e))
|
|
234
265
|
})]
|
|
235
266
|
});
|
|
236
|
-
let
|
|
267
|
+
let Q = _?.withdrawable ?? 0, Se = Y > 0 && Y <= Q, $ = pe.filter((e) => e.status !== "ARCHIVED");
|
|
237
268
|
return /* @__PURE__ */ p("div", {
|
|
238
269
|
className: "space-y-6 p-6",
|
|
239
270
|
children: [
|
|
@@ -246,7 +277,7 @@ var h = () => {
|
|
|
246
277
|
})] }),
|
|
247
278
|
/* @__PURE__ */ f("div", {
|
|
248
279
|
className: "grid grid-cols-2 lg:grid-cols-4 gap-4",
|
|
249
|
-
children:
|
|
280
|
+
children: fe ? [
|
|
250
281
|
1,
|
|
251
282
|
2,
|
|
252
283
|
3,
|
|
@@ -254,34 +285,34 @@ var h = () => {
|
|
|
254
285
|
].map((e) => /* @__PURE__ */ p("div", {
|
|
255
286
|
className: "border border-border rounded-lg p-5",
|
|
256
287
|
children: [/* @__PURE__ */ f("div", { className: "h-4 w-20 bg-muted animate-pulse rounded mb-2" }), /* @__PURE__ */ f("div", { className: "h-8 w-28 bg-muted animate-pulse rounded" })]
|
|
257
|
-
}, e)) :
|
|
288
|
+
}, e)) : y ? /* @__PURE__ */ f("div", {
|
|
258
289
|
className: "col-span-4 text-sm text-destructive",
|
|
259
|
-
children:
|
|
290
|
+
children: y
|
|
260
291
|
}) : /* @__PURE__ */ p(d, { children: [
|
|
261
292
|
/* @__PURE__ */ f(m, {
|
|
262
293
|
label: "Purchased",
|
|
263
|
-
value:
|
|
294
|
+
value: _?.purchased ?? 0,
|
|
264
295
|
description: "From credit purchases"
|
|
265
296
|
}),
|
|
266
297
|
/* @__PURE__ */ f(m, {
|
|
267
298
|
label: "Earned",
|
|
268
|
-
value:
|
|
299
|
+
value: _?.earned ?? 0,
|
|
269
300
|
description: "From sales & referrals"
|
|
270
301
|
}),
|
|
271
302
|
/* @__PURE__ */ f(m, {
|
|
272
303
|
label: "Granted",
|
|
273
|
-
value:
|
|
304
|
+
value: _?.granted ?? 0,
|
|
274
305
|
description: "Coupons & admin grants — non-withdrawable"
|
|
275
306
|
}),
|
|
276
307
|
/* @__PURE__ */ f(m, {
|
|
277
308
|
label: "Withdrawable",
|
|
278
|
-
value:
|
|
309
|
+
value: Q,
|
|
279
310
|
description: "Purchased + earned",
|
|
280
311
|
highlight: !0
|
|
281
312
|
})
|
|
282
313
|
] })
|
|
283
314
|
}),
|
|
284
|
-
|
|
315
|
+
ve && /* @__PURE__ */ p("div", {
|
|
285
316
|
className: "flex items-center gap-3 p-4 rounded-lg bg-status-success-bg-subtle border border-status-success-border text-status-success-text",
|
|
286
317
|
children: [
|
|
287
318
|
/* @__PURE__ */ f("svg", {
|
|
@@ -304,7 +335,7 @@ var h = () => {
|
|
|
304
335
|
children: "Our team will review and process your request."
|
|
305
336
|
})] }),
|
|
306
337
|
/* @__PURE__ */ f("button", {
|
|
307
|
-
onClick: () =>
|
|
338
|
+
onClick: () => P(!1),
|
|
308
339
|
className: "ml-auto text-current opacity-60 hover:opacity-100",
|
|
309
340
|
children: /* @__PURE__ */ f("svg", {
|
|
310
341
|
className: "w-4 h-4",
|
|
@@ -332,12 +363,12 @@ var h = () => {
|
|
|
332
363
|
className: "text-base font-semibold text-foreground",
|
|
333
364
|
children: "Payout Account"
|
|
334
365
|
}), /* @__PURE__ */ f("button", {
|
|
335
|
-
onClick: () =>
|
|
366
|
+
onClick: () => I((e) => !e),
|
|
336
367
|
className: "text-sm text-primary hover:underline",
|
|
337
|
-
children:
|
|
368
|
+
children: F ? "Cancel" : "+ Add new"
|
|
338
369
|
})]
|
|
339
370
|
}),
|
|
340
|
-
|
|
371
|
+
F && /* @__PURE__ */ p("div", {
|
|
341
372
|
className: "border border-border rounded-lg p-4 space-y-3 bg-muted/30",
|
|
342
373
|
children: [
|
|
343
374
|
/* @__PURE__ */ f("h3", {
|
|
@@ -349,22 +380,35 @@ var h = () => {
|
|
|
349
380
|
children: "Label"
|
|
350
381
|
}), /* @__PURE__ */ f("input", {
|
|
351
382
|
type: "text",
|
|
352
|
-
value:
|
|
353
|
-
onChange: (e) =>
|
|
383
|
+
value: L.label,
|
|
384
|
+
onChange: (e) => R((t) => ({
|
|
354
385
|
...t,
|
|
355
386
|
label: e.target.value
|
|
356
387
|
})),
|
|
357
388
|
placeholder: "e.g. My Bank Account",
|
|
358
389
|
className: "w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"
|
|
359
390
|
})] }),
|
|
391
|
+
/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("label", {
|
|
392
|
+
className: "block text-xs text-muted-foreground mb-1",
|
|
393
|
+
children: "Account Holder Name"
|
|
394
|
+
}), /* @__PURE__ */ f("input", {
|
|
395
|
+
type: "text",
|
|
396
|
+
value: L.accountHolderName,
|
|
397
|
+
onChange: (e) => R((t) => ({
|
|
398
|
+
...t,
|
|
399
|
+
accountHolderName: e.target.value
|
|
400
|
+
})),
|
|
401
|
+
placeholder: "Full name as on bank account",
|
|
402
|
+
className: "w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"
|
|
403
|
+
})] }),
|
|
360
404
|
/* @__PURE__ */ p("div", {
|
|
361
405
|
className: "grid grid-cols-2 gap-3",
|
|
362
406
|
children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("label", {
|
|
363
407
|
className: "block text-xs text-muted-foreground mb-1",
|
|
364
408
|
children: "Type"
|
|
365
409
|
}), /* @__PURE__ */ p("select", {
|
|
366
|
-
value:
|
|
367
|
-
onChange: (e) =>
|
|
410
|
+
value: L.type,
|
|
411
|
+
onChange: (e) => R((t) => ({
|
|
368
412
|
...t,
|
|
369
413
|
type: e.target.value
|
|
370
414
|
})),
|
|
@@ -381,8 +425,8 @@ var h = () => {
|
|
|
381
425
|
children: "Country"
|
|
382
426
|
}), /* @__PURE__ */ f("input", {
|
|
383
427
|
type: "text",
|
|
384
|
-
value:
|
|
385
|
-
onChange: (e) =>
|
|
428
|
+
value: L.country,
|
|
429
|
+
onChange: (e) => R((t) => ({
|
|
386
430
|
...t,
|
|
387
431
|
country: e.target.value
|
|
388
432
|
})),
|
|
@@ -390,25 +434,25 @@ var h = () => {
|
|
|
390
434
|
className: "w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"
|
|
391
435
|
})] })]
|
|
392
436
|
}),
|
|
393
|
-
|
|
437
|
+
L.type === "BANK_ACCOUNT" && /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("label", {
|
|
394
438
|
className: "block text-xs text-muted-foreground mb-1",
|
|
395
439
|
children: "Account Number"
|
|
396
440
|
}), /* @__PURE__ */ f("input", {
|
|
397
441
|
type: "text",
|
|
398
|
-
value:
|
|
399
|
-
onChange: (e) =>
|
|
442
|
+
value: L.accountNumber,
|
|
443
|
+
onChange: (e) => R((t) => ({
|
|
400
444
|
...t,
|
|
401
445
|
accountNumber: e.target.value
|
|
402
446
|
})),
|
|
403
447
|
placeholder: "Account number",
|
|
404
448
|
className: "w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"
|
|
405
|
-
})] }),
|
|
449
|
+
})] }), L.country.trim().toUpperCase() === "IN" || L.country.trim().toLowerCase() === "india" ? /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("label", {
|
|
406
450
|
className: "block text-xs text-muted-foreground mb-1",
|
|
407
451
|
children: "IFSC Code"
|
|
408
452
|
}), /* @__PURE__ */ f("input", {
|
|
409
453
|
type: "text",
|
|
410
|
-
value:
|
|
411
|
-
onChange: (e) =>
|
|
454
|
+
value: L.ifscCode,
|
|
455
|
+
onChange: (e) => R((t) => ({
|
|
412
456
|
...t,
|
|
413
457
|
ifscCode: e.target.value.toUpperCase()
|
|
414
458
|
})),
|
|
@@ -419,43 +463,43 @@ var h = () => {
|
|
|
419
463
|
children: "Routing Number"
|
|
420
464
|
}), /* @__PURE__ */ f("input", {
|
|
421
465
|
type: "text",
|
|
422
|
-
value:
|
|
423
|
-
onChange: (e) =>
|
|
466
|
+
value: L.routingNumber,
|
|
467
|
+
onChange: (e) => R((t) => ({
|
|
424
468
|
...t,
|
|
425
469
|
routingNumber: e.target.value
|
|
426
470
|
})),
|
|
427
471
|
placeholder: "Routing / sort code",
|
|
428
472
|
className: "w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"
|
|
429
473
|
})] })] }),
|
|
430
|
-
|
|
474
|
+
L.type === "UPI" && /* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("label", {
|
|
431
475
|
className: "block text-xs text-muted-foreground mb-1",
|
|
432
476
|
children: "UPI ID"
|
|
433
477
|
}), /* @__PURE__ */ f("input", {
|
|
434
478
|
type: "text",
|
|
435
|
-
value:
|
|
436
|
-
onChange: (e) =>
|
|
479
|
+
value: L.upiId,
|
|
480
|
+
onChange: (e) => R((t) => ({
|
|
437
481
|
...t,
|
|
438
482
|
upiId: e.target.value
|
|
439
483
|
})),
|
|
440
484
|
placeholder: "yourname@upi",
|
|
441
485
|
className: "w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"
|
|
442
486
|
})] }),
|
|
443
|
-
|
|
487
|
+
V && /* @__PURE__ */ f("p", {
|
|
444
488
|
className: "text-xs text-destructive",
|
|
445
|
-
children:
|
|
489
|
+
children: V
|
|
446
490
|
}),
|
|
447
491
|
/* @__PURE__ */ f("button", {
|
|
448
|
-
onClick: () => void
|
|
449
|
-
disabled:
|
|
492
|
+
onClick: () => void ye(),
|
|
493
|
+
disabled: z || !L.label || !L.accountHolderName,
|
|
450
494
|
className: "w-full py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
451
|
-
children:
|
|
495
|
+
children: z ? "Saving…" : "Save Account"
|
|
452
496
|
})
|
|
453
497
|
]
|
|
454
498
|
}),
|
|
455
|
-
|
|
499
|
+
he ? /* @__PURE__ */ f("div", {
|
|
456
500
|
className: "space-y-2",
|
|
457
501
|
children: [1, 2].map((e) => /* @__PURE__ */ f("div", { className: "h-16 border border-border rounded-lg bg-muted animate-pulse" }, e))
|
|
458
|
-
}) : $.length === 0 && !
|
|
502
|
+
}) : $.length === 0 && !F ? /* @__PURE__ */ p("div", {
|
|
459
503
|
className: "flex flex-col items-center justify-center py-8 border border-dashed border-border rounded-lg",
|
|
460
504
|
children: [
|
|
461
505
|
/* @__PURE__ */ f("svg", {
|
|
@@ -475,7 +519,7 @@ var h = () => {
|
|
|
475
519
|
children: "No payout accounts yet"
|
|
476
520
|
}),
|
|
477
521
|
/* @__PURE__ */ f("button", {
|
|
478
|
-
onClick: () =>
|
|
522
|
+
onClick: () => I(!0),
|
|
479
523
|
className: "mt-2 text-sm text-primary hover:underline",
|
|
480
524
|
children: "Add a bank account or UPI"
|
|
481
525
|
})
|
|
@@ -483,8 +527,8 @@ var h = () => {
|
|
|
483
527
|
}) : /* @__PURE__ */ f("div", {
|
|
484
528
|
className: "space-y-2",
|
|
485
529
|
children: $.map((e) => /* @__PURE__ */ f("button", {
|
|
486
|
-
onClick: () =>
|
|
487
|
-
className: `w-full text-left p-4 border rounded-lg transition-colors ${
|
|
530
|
+
onClick: () => T(e.id),
|
|
531
|
+
className: `w-full text-left p-4 border rounded-lg transition-colors ${w === e.id ? "border-primary bg-primary/5" : "border-border bg-card hover:border-primary/40"}`,
|
|
488
532
|
children: /* @__PURE__ */ p("div", {
|
|
489
533
|
className: "flex items-center justify-between",
|
|
490
534
|
children: [/* @__PURE__ */ p("div", { children: [/* @__PURE__ */ f("p", {
|
|
@@ -509,7 +553,7 @@ var h = () => {
|
|
|
509
553
|
className: `text-xs px-2 py-0.5 rounded font-medium ${e.status === "ACTIVE" ? `${t.success.bg} ${t.success.text}` : e.status === "PENDING_VERIFICATION" ? `${t.warning.bg} ${t.warning.text}` : `${t.error.bg} ${t.error.text}`}`,
|
|
510
554
|
children: e.status.replaceAll("_", " ").toLowerCase()
|
|
511
555
|
}),
|
|
512
|
-
|
|
556
|
+
w === e.id && /* @__PURE__ */ f("svg", {
|
|
513
557
|
className: "w-4 h-4 text-primary shrink-0",
|
|
514
558
|
fill: "none",
|
|
515
559
|
viewBox: "0 0 24 24",
|
|
@@ -543,10 +587,10 @@ var h = () => {
|
|
|
543
587
|
/* @__PURE__ */ f("input", {
|
|
544
588
|
type: "number",
|
|
545
589
|
min: 1,
|
|
546
|
-
max:
|
|
590
|
+
max: Q,
|
|
547
591
|
step: 1,
|
|
548
|
-
value:
|
|
549
|
-
onChange: (e) =>
|
|
592
|
+
value: E,
|
|
593
|
+
onChange: (e) => D(e.target.value),
|
|
550
594
|
placeholder: "Enter credit amount",
|
|
551
595
|
className: "w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30"
|
|
552
596
|
}),
|
|
@@ -557,11 +601,29 @@ var h = () => {
|
|
|
557
601
|
" ",
|
|
558
602
|
/* @__PURE__ */ p("span", {
|
|
559
603
|
className: "font-medium",
|
|
560
|
-
children: [
|
|
604
|
+
children: [Q.toLocaleString(), " credits"]
|
|
561
605
|
})
|
|
562
606
|
]
|
|
563
607
|
}),
|
|
564
|
-
|
|
608
|
+
Y > 0 && Y <= Q && /* @__PURE__ */ f("p", {
|
|
609
|
+
className: "text-xs text-muted-foreground mt-1",
|
|
610
|
+
children: X ? "Calculating…" : Z == null ? null : /* @__PURE__ */ p(d, { children: [
|
|
611
|
+
"Estimated payout:",
|
|
612
|
+
" ",
|
|
613
|
+
/* @__PURE__ */ f("span", {
|
|
614
|
+
className: "font-semibold text-foreground",
|
|
615
|
+
children: Z.toLocaleString(void 0, {
|
|
616
|
+
style: "currency",
|
|
617
|
+
currency: J,
|
|
618
|
+
minimumFractionDigits: 2,
|
|
619
|
+
maximumFractionDigits: 2
|
|
620
|
+
})
|
|
621
|
+
}),
|
|
622
|
+
" ",
|
|
623
|
+
"at the current credit rate"
|
|
624
|
+
] })
|
|
625
|
+
}),
|
|
626
|
+
Y > 0 && Y > Q && /* @__PURE__ */ f("p", {
|
|
565
627
|
className: "text-xs text-destructive mt-1",
|
|
566
628
|
children: "Amount exceeds your withdrawable balance"
|
|
567
629
|
})
|
|
@@ -573,29 +635,33 @@ var h = () => {
|
|
|
573
635
|
children: "(optional)"
|
|
574
636
|
})]
|
|
575
637
|
}), /* @__PURE__ */ f("textarea", {
|
|
576
|
-
value:
|
|
577
|
-
onChange: (e) =>
|
|
638
|
+
value: O,
|
|
639
|
+
onChange: (e) => k(e.target.value),
|
|
578
640
|
placeholder: "Any notes for this withdrawal request",
|
|
579
641
|
rows: 2,
|
|
580
642
|
className: "w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30 resize-none"
|
|
581
643
|
})] }),
|
|
582
|
-
|
|
644
|
+
M && /* @__PURE__ */ f("div", {
|
|
583
645
|
className: "p-3 rounded-md bg-destructive/10 border border-destructive/20",
|
|
584
646
|
children: /* @__PURE__ */ f("p", {
|
|
585
647
|
className: "text-sm text-destructive",
|
|
586
|
-
children:
|
|
648
|
+
children: M
|
|
587
649
|
})
|
|
588
650
|
}),
|
|
589
651
|
/* @__PURE__ */ p("div", {
|
|
590
652
|
className: "pt-1 border-t border-border",
|
|
591
|
-
children: [/* @__PURE__ */
|
|
653
|
+
children: [/* @__PURE__ */ p("p", {
|
|
592
654
|
className: "text-xs text-muted-foreground mb-3",
|
|
593
|
-
children:
|
|
655
|
+
children: [
|
|
656
|
+
"Credits will be converted to ",
|
|
657
|
+
J,
|
|
658
|
+
" at the current credit rate. Withdrawals are reviewed before processing and may take 3–5 business days."
|
|
659
|
+
]
|
|
594
660
|
}), /* @__PURE__ */ f("button", {
|
|
595
|
-
onClick: () => void
|
|
596
|
-
disabled:
|
|
661
|
+
onClick: () => void be(),
|
|
662
|
+
disabled: A || !Se || !w || $.length === 0,
|
|
597
663
|
className: "w-full py-2.5 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed",
|
|
598
|
-
children:
|
|
664
|
+
children: A ? "Submitting…" : "Request Withdrawal"
|
|
599
665
|
})]
|
|
600
666
|
})
|
|
601
667
|
]
|
|
@@ -610,7 +676,7 @@ var h = () => {
|
|
|
610
676
|
className: "text-base font-semibold text-foreground",
|
|
611
677
|
children: "Withdrawal History"
|
|
612
678
|
}), /* @__PURE__ */ f("button", {
|
|
613
|
-
onClick: () => void
|
|
679
|
+
onClick: () => void q(),
|
|
614
680
|
className: "text-sm text-muted-foreground hover:text-foreground transition-colors",
|
|
615
681
|
"aria-label": "Refresh withdrawal history",
|
|
616
682
|
children: /* @__PURE__ */ f("svg", {
|
|
@@ -626,14 +692,14 @@ var h = () => {
|
|
|
626
692
|
})
|
|
627
693
|
})
|
|
628
694
|
})]
|
|
629
|
-
}),
|
|
695
|
+
}), _e ? /* @__PURE__ */ f("div", {
|
|
630
696
|
className: "space-y-2",
|
|
631
697
|
children: [
|
|
632
698
|
1,
|
|
633
699
|
2,
|
|
634
700
|
3
|
|
635
701
|
].map((e) => /* @__PURE__ */ f("div", { className: "h-16 border border-border rounded-lg bg-muted animate-pulse" }, e))
|
|
636
|
-
}) :
|
|
702
|
+
}) : S.length === 0 ? /* @__PURE__ */ p("div", {
|
|
637
703
|
className: "flex flex-col items-center justify-center py-10 border border-dashed border-border rounded-lg",
|
|
638
704
|
children: [/* @__PURE__ */ f("svg", {
|
|
639
705
|
className: "w-8 h-8 text-muted-foreground mb-2",
|
|
@@ -680,7 +746,7 @@ var h = () => {
|
|
|
680
746
|
] })
|
|
681
747
|
}), /* @__PURE__ */ f("tbody", {
|
|
682
748
|
className: "divide-y divide-border",
|
|
683
|
-
children:
|
|
749
|
+
children: S.map((e) => /* @__PURE__ */ p("tr", {
|
|
684
750
|
className: "hover:bg-muted/30 transition-colors",
|
|
685
751
|
children: [
|
|
686
752
|
/* @__PURE__ */ p("td", {
|
|
@@ -694,7 +760,7 @@ var h = () => {
|
|
|
694
760
|
/* @__PURE__ */ p("td", {
|
|
695
761
|
className: "px-4 py-3",
|
|
696
762
|
children: [/* @__PURE__ */ f("span", {
|
|
697
|
-
className: `inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${
|
|
763
|
+
className: `inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${le(e.status)}`,
|
|
698
764
|
children: e.status.charAt(0) + e.status.slice(1).toLowerCase()
|
|
699
765
|
}), e.failureReason && /* @__PURE__ */ f("p", {
|
|
700
766
|
className: "text-xs text-destructive mt-0.5 max-w-[180px] truncate",
|
|
@@ -716,7 +782,7 @@ var h = () => {
|
|
|
716
782
|
/* @__PURE__ */ f("td", {
|
|
717
783
|
className: "px-4 py-3 text-muted-foreground hidden md:table-cell",
|
|
718
784
|
children: e.paidAt ? /* @__PURE__ */ f("span", {
|
|
719
|
-
className:
|
|
785
|
+
className: ce("PAID"),
|
|
720
786
|
children: r(e.paidAt, "short")
|
|
721
787
|
}) : "—"
|
|
722
788
|
})
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CreditWithdrawalPage.js","names":[],"sources":["../../../../../src/billing/modules/credits/pages/CreditWithdrawalPage.tsx"],"sourcesContent":["/**\n * Credits Module - Credit Withdrawal Page\n * Allows users to withdraw withdrawable credits (purchased + earned) to a payout account.\n */\n\nimport { useState, useEffect, type FC } from 'react';\nimport {\n CreditWithdrawalHistoryDocument,\n GetCreditBalanceByTypeDocument,\n RequestCreditWithdrawalDocument,\n} from '../../../../generated/global-operations';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { useDefaultBillingAccount } from '../../subscriptions/hooks';\nimport { directBillingGraphqlRequest } from '../../../shared/utils';\nimport {\n fetchPayoutAccounts,\n addPayoutAccount,\n type PayoutAccount,\n type PayoutRequest,\n} from '../../earnings/api';\nimport { formatDate, formatRelativeTime } from '../../../shared/utils/format';\nimport { statusTokens } from '../../../shared/utils/tokens';\nimport type { CreditBalanceByType } from '../../../shared/types';\n\n// ============================================================================\n// API helpers (credit-specific)\n// ============================================================================\n\ninterface GatewayContext {\n apiGatewayUrl?: string;\n authToken?: string;\n orgId?: string;\n}\n\nasync function fetchCreditBalanceByType(\n billingAccountId: string,\n ctx: GatewayContext\n): Promise<CreditBalanceByType> {\n const data = await directBillingGraphqlRequest<\n { getCreditBalanceByType: CreditBalanceByType },\n { billingAccountId: string }\n >({\n ...ctx,\n query: GetCreditBalanceByTypeDocument,\n variables: { billingAccountId },\n });\n return data.getCreditBalanceByType;\n}\n\nasync function requestCreditWithdrawal(\n input: {\n billingAccountId: string;\n creditAmount: number;\n payoutAccountId: string;\n currency?: string;\n notes?: string;\n },\n ctx: GatewayContext\n): Promise<{ id: string; status: string; requestedAmount: number; currency: string }> {\n const data = await directBillingGraphqlRequest<\n {\n requestCreditWithdrawal: {\n id: string;\n status: string;\n requestedAmount: number;\n currency: string;\n };\n },\n { input: typeof input }\n >({\n ...ctx,\n query: RequestCreditWithdrawalDocument,\n variables: { input },\n });\n return data.requestCreditWithdrawal;\n}\n\nasync function fetchCreditWithdrawalHistory(\n billingAccountId: string,\n ctx: GatewayContext\n): Promise<PayoutRequest[]> {\n const data = await directBillingGraphqlRequest<\n { myPayoutRequests: { items: PayoutRequest[] } },\n { billingAccountId: string }\n >({\n ...ctx,\n query: CreditWithdrawalHistoryDocument,\n variables: { billingAccountId },\n });\n return data.myPayoutRequests.items;\n}\n\n// ============================================================================\n// Sub-components\n// ============================================================================\n\ninterface BalanceCardProps {\n label: string;\n value: number;\n description?: string;\n highlight?: boolean;\n}\n\nconst BalanceCard: FC<BalanceCardProps> = ({ label, value, description, highlight }) => (\n <div\n className={`border border-border rounded-lg p-5 ${\n highlight ? 'bg-gradient-to-br from-primary/5 to-primary/10' : 'bg-card'\n }`}\n >\n <p className=\"text-sm text-muted-foreground\">{label}</p>\n <p className={`text-2xl font-bold mt-1 ${highlight ? 'text-primary' : 'text-foreground'}`}>\n {value.toLocaleString()} <span className=\"text-base font-normal\">credits</span>\n </p>\n {description && <p className=\"text-xs text-muted-foreground mt-1\">{description}</p>}\n </div>\n);\n\nfunction getWithdrawalStatusColor(status: string): string {\n switch (status.toUpperCase()) {\n case 'PAID':\n return statusTokens.success.text;\n case 'APPROVED':\n case 'PROCESSING':\n return statusTokens.info.text;\n case 'REQUESTED':\n return statusTokens.warning.text;\n case 'REJECTED':\n case 'FAILED':\n case 'CANCELED':\n return statusTokens.error.text;\n default:\n return 'text-muted-foreground';\n }\n}\n\nfunction getWithdrawalStatusBg(status: string): string {\n switch (status.toUpperCase()) {\n case 'PAID':\n return `${statusTokens.success.bg} ${statusTokens.success.text}`;\n case 'APPROVED':\n case 'PROCESSING':\n return `${statusTokens.info.bg} ${statusTokens.info.text}`;\n case 'REQUESTED':\n return `${statusTokens.warning.bg} ${statusTokens.warning.text}`;\n case 'REJECTED':\n case 'FAILED':\n case 'CANCELED':\n return `${statusTokens.error.bg} ${statusTokens.error.text}`;\n default:\n return 'bg-muted text-muted-foreground';\n }\n}\n\n// ============================================================================\n// Main Page\n// ============================================================================\n\nexport const CreditWithdrawalPage: FC = () => {\n const permissions = useBillingPermissions();\n const { billingAccount, isLoading: isLoadingAccount } = useDefaultBillingAccount();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n const { emit } = useBillingEventEmitter();\n\n // Balance state\n const [balance, setBalance] = useState<CreditBalanceByType | null>(null);\n const [isLoadingBalance, setIsLoadingBalance] = useState(false);\n const [balanceError, setBalanceError] = useState<string | null>(null);\n\n // Payout accounts state\n const [payoutAccounts, setPayoutAccounts] = useState<PayoutAccount[]>([]);\n const [isLoadingAccounts, setIsLoadingAccounts] = useState(false);\n\n // Withdrawal history state\n const [history, setHistory] = useState<PayoutRequest[]>([]);\n const [isLoadingHistory, setIsLoadingHistory] = useState(false);\n\n // Withdrawal form state\n const [selectedAccountId, setSelectedAccountId] = useState<string>('');\n const [creditAmount, setCreditAmount] = useState<string>('');\n const [notes, setNotes] = useState<string>('');\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [submitError, setSubmitError] = useState<string | null>(null);\n const [submitSuccess, setSubmitSuccess] = useState(false);\n\n // New payout account form state\n const [showAddAccount, setShowAddAccount] = useState(false);\n const [accountForm, setAccountForm] = useState({\n label: '',\n type: 'BANK_ACCOUNT' as 'BANK_ACCOUNT' | 'UPI',\n accountNumber: '',\n ifscCode: '',\n routingNumber: '',\n upiId: '',\n country: '',\n currency: 'USD',\n });\n const [isAddingAccount, setIsAddingAccount] = useState(false);\n const [addAccountError, setAddAccountError] = useState<string | null>(null);\n\n const billingAccountId = billingAccount?.id;\n\n const getCtx = (): GatewayContext => ({\n apiGatewayUrl,\n authToken,\n orgId,\n });\n\n const loadBalance = async () => {\n if (!billingAccountId) return;\n setIsLoadingBalance(true);\n setBalanceError(null);\n try {\n const b = await fetchCreditBalanceByType(billingAccountId, getCtx());\n setBalance(b);\n } catch (e) {\n setBalanceError(e instanceof Error ? e.message : 'Failed to load balance');\n } finally {\n setIsLoadingBalance(false);\n }\n };\n\n const loadAccounts = async () => {\n if (!billingAccountId) return;\n setIsLoadingAccounts(true);\n try {\n const accounts = await fetchPayoutAccounts(billingAccountId, getCtx());\n setPayoutAccounts(accounts);\n const defaultAcc = accounts.find((a) => a.isDefault) ?? accounts[0];\n if (defaultAcc) setSelectedAccountId(defaultAcc.id);\n } catch {\n // silently fail - user will see empty state\n } finally {\n setIsLoadingAccounts(false);\n }\n };\n\n const loadHistory = async () => {\n if (!billingAccountId) return;\n setIsLoadingHistory(true);\n try {\n const items = await fetchCreditWithdrawalHistory(billingAccountId, getCtx());\n setHistory(items);\n } catch {\n // silently fail\n } finally {\n setIsLoadingHistory(false);\n }\n };\n\n useEffect(() => {\n if (billingAccountId) {\n void loadBalance();\n void loadAccounts();\n void loadHistory();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [billingAccountId]);\n\n const handleAddAccount = async () => {\n if (!billingAccountId) return;\n setAddAccountError(null);\n setIsAddingAccount(true);\n try {\n const details: Record<string, string> = {};\n const isIndia =\n accountForm.country.trim().toUpperCase() === 'IN' ||\n accountForm.country.trim().toLowerCase() === 'india';\n if (accountForm.type === 'BANK_ACCOUNT') {\n if (isIndia) {\n details.accountNumber = accountForm.accountNumber;\n details.ifscCode = accountForm.ifscCode;\n } else {\n details.accountNumber = accountForm.accountNumber;\n details.routingNumber = accountForm.routingNumber;\n }\n } else if (accountForm.type === 'UPI') {\n details.upiId = accountForm.upiId;\n }\n\n await addPayoutAccount(\n {\n billingAccountId,\n label: accountForm.label,\n type: accountForm.type,\n country: accountForm.country,\n currency: accountForm.currency,\n accountDetails: details,\n },\n getCtx()\n );\n emit('billing.payout_account.added', {\n route: '/billing/credits/withdraw',\n entityId: billingAccountId,\n source: 'credit-withdrawal',\n });\n await loadAccounts();\n setShowAddAccount(false);\n setAccountForm({\n label: '',\n type: 'BANK_ACCOUNT' as 'BANK_ACCOUNT' | 'UPI',\n accountNumber: '',\n ifscCode: '',\n routingNumber: '',\n upiId: '',\n country: '',\n currency: 'USD',\n });\n } catch (e) {\n setAddAccountError(e instanceof Error ? e.message : 'Failed to add account');\n } finally {\n setIsAddingAccount(false);\n }\n };\n\n const handleWithdraw = async () => {\n if (!billingAccountId || !selectedAccountId) return;\n const amount = parseFloat(creditAmount);\n if (!amount || amount <= 0) return;\n\n setSubmitError(null);\n setIsSubmitting(true);\n try {\n const withdrawal = await requestCreditWithdrawal(\n {\n billingAccountId,\n creditAmount: amount,\n payoutAccountId: selectedAccountId,\n notes: notes || undefined,\n },\n getCtx()\n );\n emit('billing.credits.withdrawal_requested', {\n route: '/billing/credits/withdraw',\n entityId: withdrawal.id,\n source: 'credit-withdrawal',\n amount,\n });\n setSubmitSuccess(true);\n setCreditAmount('');\n setNotes('');\n await loadBalance();\n await loadHistory();\n } catch (e) {\n setSubmitError(e instanceof Error ? e.message : 'Withdrawal request failed');\n } finally {\n setIsSubmitting(false);\n }\n };\n\n // Permission check\n if (!permissions.canWithdrawCredits) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-2\">\n <div className=\"w-12 h-12 mx-auto rounded-full bg-muted flex items-center justify-center\">\n <svg\n className=\"w-6 h-6 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-foreground\">Access Denied</h2>\n <p className=\"text-sm text-muted-foreground\">\n You don't have permission to withdraw credits.\n </p>\n </div>\n </div>\n );\n }\n\n if (isLoadingAccount && !billingAccount) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-64 bg-muted animate-pulse rounded\" />\n <div className=\"grid grid-cols-2 lg:grid-cols-4 gap-4\">\n {[1, 2, 3, 4].map((i) => (\n <div key={i} className=\"border border-border rounded-lg p-5\">\n <div className=\"h-4 w-24 bg-muted animate-pulse rounded mb-2\" />\n <div className=\"h-8 w-32 bg-muted animate-pulse rounded\" />\n </div>\n ))}\n </div>\n </div>\n );\n }\n\n const withdrawable = balance?.withdrawable ?? 0;\n const amount = parseFloat(creditAmount) || 0;\n const amountValid = amount > 0 && amount <= withdrawable;\n const activeAccounts = payoutAccounts.filter((a) => a.status !== 'ARCHIVED');\n\n return (\n <div className=\"space-y-6 p-6\">\n {/* Header */}\n <div>\n <h1 className=\"text-2xl font-bold text-foreground\">Withdraw Credits</h1>\n <p className=\"text-sm text-muted-foreground mt-1\">\n Convert your withdrawable credits (purchased & earned) to a payout\n </p>\n </div>\n\n {/* Balance breakdown */}\n <div className=\"grid grid-cols-2 lg:grid-cols-4 gap-4\">\n {isLoadingBalance ? (\n [1, 2, 3, 4].map((i) => (\n <div key={i} className=\"border border-border rounded-lg p-5\">\n <div className=\"h-4 w-20 bg-muted animate-pulse rounded mb-2\" />\n <div className=\"h-8 w-28 bg-muted animate-pulse rounded\" />\n </div>\n ))\n ) : balanceError ? (\n <div className=\"col-span-4 text-sm text-destructive\">{balanceError}</div>\n ) : (\n <>\n <BalanceCard\n label=\"Purchased\"\n value={balance?.purchased ?? 0}\n description=\"From credit purchases\"\n />\n <BalanceCard\n label=\"Earned\"\n value={balance?.earned ?? 0}\n description=\"From sales & referrals\"\n />\n <BalanceCard\n label=\"Granted\"\n value={balance?.granted ?? 0}\n description=\"Coupons & admin grants — non-withdrawable\"\n />\n <BalanceCard\n label=\"Withdrawable\"\n value={withdrawable}\n description=\"Purchased + earned\"\n highlight\n />\n </>\n )}\n </div>\n\n {/* Success banner */}\n {submitSuccess && (\n <div className=\"flex items-center gap-3 p-4 rounded-lg bg-status-success-bg-subtle border border-status-success-border text-status-success-text\">\n <svg className=\"w-5 h-5 shrink-0\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M5 13l4 4L19 7\" />\n </svg>\n <div>\n <p className=\"font-medium\">Withdrawal request submitted</p>\n <p className=\"text-sm opacity-80\">Our team will review and process your request.</p>\n </div>\n <button\n onClick={() => setSubmitSuccess(false)}\n className=\"ml-auto text-current opacity-60 hover:opacity-100\"\n >\n <svg className=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M6 18L18 6M6 6l12 12\"\n />\n </svg>\n </button>\n </div>\n )}\n\n {/* Main two-column layout */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n {/* Left: Payout account management */}\n <div className=\"space-y-4\">\n <div className=\"flex items-center justify-between\">\n <h2 className=\"text-base font-semibold text-foreground\">Payout Account</h2>\n <button\n onClick={() => setShowAddAccount((v) => !v)}\n className=\"text-sm text-primary hover:underline\"\n >\n {showAddAccount ? 'Cancel' : '+ Add new'}\n </button>\n </div>\n\n {/* Add account form */}\n {showAddAccount && (\n <div className=\"border border-border rounded-lg p-4 space-y-3 bg-muted/30\">\n <h3 className=\"text-sm font-medium text-foreground\">New Payout Account</h3>\n\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">Label</label>\n <input\n type=\"text\"\n value={accountForm.label}\n onChange={(e) => setAccountForm((f) => ({ ...f, label: e.target.value }))}\n placeholder=\"e.g. My Bank Account\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">Type</label>\n <select\n value={accountForm.type}\n onChange={(e) =>\n setAccountForm((f) => ({\n ...f,\n type: e.target.value as typeof accountForm.type,\n }))\n }\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n >\n <option value=\"BANK_ACCOUNT\">Bank Account</option>\n <option value=\"UPI\">UPI</option>\n </select>\n </div>\n\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">Country</label>\n <input\n type=\"text\"\n value={accountForm.country}\n onChange={(e) => setAccountForm((f) => ({ ...f, country: e.target.value }))}\n placeholder=\"e.g. India, US, UK\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n </div>\n\n {accountForm.type === 'BANK_ACCOUNT' && (\n <>\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">\n Account Number\n </label>\n <input\n type=\"text\"\n value={accountForm.accountNumber}\n onChange={(e) =>\n setAccountForm((f) => ({ ...f, accountNumber: e.target.value }))\n }\n placeholder=\"Account number\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n {accountForm.country.trim().toUpperCase() === 'IN' ||\n accountForm.country.trim().toLowerCase() === 'india' ? (\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">IFSC Code</label>\n <input\n type=\"text\"\n value={accountForm.ifscCode}\n onChange={(e) =>\n setAccountForm((f) => ({ ...f, ifscCode: e.target.value.toUpperCase() }))\n }\n placeholder=\"e.g. SBIN0001234\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n ) : (\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">\n Routing Number\n </label>\n <input\n type=\"text\"\n value={accountForm.routingNumber}\n onChange={(e) =>\n setAccountForm((f) => ({ ...f, routingNumber: e.target.value }))\n }\n placeholder=\"Routing / sort code\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n )}\n </>\n )}\n\n {accountForm.type === 'UPI' && (\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">UPI ID</label>\n <input\n type=\"text\"\n value={accountForm.upiId}\n onChange={(e) => setAccountForm((f) => ({ ...f, upiId: e.target.value }))}\n placeholder=\"yourname@upi\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n )}\n\n {addAccountError && <p className=\"text-xs text-destructive\">{addAccountError}</p>}\n\n <button\n onClick={() => void handleAddAccount()}\n disabled={isAddingAccount || !accountForm.label}\n className=\"w-full py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n {isAddingAccount ? 'Saving…' : 'Save Account'}\n </button>\n </div>\n )}\n\n {/* Existing accounts */}\n {isLoadingAccounts ? (\n <div className=\"space-y-2\">\n {[1, 2].map((i) => (\n <div\n key={i}\n className=\"h-16 border border-border rounded-lg bg-muted animate-pulse\"\n />\n ))}\n </div>\n ) : activeAccounts.length === 0 && !showAddAccount ? (\n <div className=\"flex flex-col items-center justify-center py-8 border border-dashed border-border rounded-lg\">\n <svg\n className=\"w-8 h-8 text-muted-foreground mb-2\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={1.5}\n d=\"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z\"\n />\n </svg>\n <p className=\"text-sm text-muted-foreground\">No payout accounts yet</p>\n <button\n onClick={() => setShowAddAccount(true)}\n className=\"mt-2 text-sm text-primary hover:underline\"\n >\n Add a bank account or UPI\n </button>\n </div>\n ) : (\n <div className=\"space-y-2\">\n {activeAccounts.map((account) => (\n <button\n key={account.id}\n onClick={() => setSelectedAccountId(account.id)}\n className={`w-full text-left p-4 border rounded-lg transition-colors ${\n selectedAccountId === account.id\n ? 'border-primary bg-primary/5'\n : 'border-border bg-card hover:border-primary/40'\n }`}\n >\n <div className=\"flex items-center justify-between\">\n <div>\n <p className=\"text-sm font-medium text-foreground\">{account.label}</p>\n <p className=\"text-xs text-muted-foreground mt-0.5\">\n {account.type.replaceAll('_', ' ')}\n {account.displayName ? ` · ${account.displayName}` : ''}\n {account.accountLast4 ? ` ···${account.accountLast4}` : ''}\n {account.country ? ` · ${account.country}` : ''}\n </p>\n </div>\n <div className=\"flex items-center gap-2\">\n {account.isDefault && (\n <span className=\"text-xs px-2 py-0.5 rounded bg-primary/10 text-primary font-medium\">\n Default\n </span>\n )}\n <span\n className={`text-xs px-2 py-0.5 rounded font-medium ${\n account.status === 'ACTIVE'\n ? `${statusTokens.success.bg} ${statusTokens.success.text}`\n : account.status === 'PENDING_VERIFICATION'\n ? `${statusTokens.warning.bg} ${statusTokens.warning.text}`\n : `${statusTokens.error.bg} ${statusTokens.error.text}`\n }`}\n >\n {account.status.replaceAll('_', ' ').toLowerCase()}\n </span>\n {selectedAccountId === account.id && (\n <svg\n className=\"w-4 h-4 text-primary shrink-0\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M5 13l4 4L19 7\"\n />\n </svg>\n )}\n </div>\n </div>\n </button>\n ))}\n </div>\n )}\n </div>\n\n {/* Right: Withdrawal request form */}\n <div className=\"space-y-4\">\n <h2 className=\"text-base font-semibold text-foreground\">Request Withdrawal</h2>\n\n <div className=\"border border-border rounded-lg p-5 bg-card space-y-4\">\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-1\">\n Credits to Withdraw\n </label>\n <input\n type=\"number\"\n min={1}\n max={withdrawable}\n step={1}\n value={creditAmount}\n onChange={(e) => setCreditAmount(e.target.value)}\n placeholder=\"Enter credit amount\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n <p className=\"text-xs text-muted-foreground mt-1\">\n Max withdrawable:{' '}\n <span className=\"font-medium\">{withdrawable.toLocaleString()} credits</span>\n </p>\n {amount > 0 && amount > withdrawable && (\n <p className=\"text-xs text-destructive mt-1\">\n Amount exceeds your withdrawable balance\n </p>\n )}\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-1\">\n Notes <span className=\"text-muted-foreground font-normal\">(optional)</span>\n </label>\n <textarea\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n placeholder=\"Any notes for this withdrawal request\"\n rows={2}\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30 resize-none\"\n />\n </div>\n\n {submitError && (\n <div className=\"p-3 rounded-md bg-destructive/10 border border-destructive/20\">\n <p className=\"text-sm text-destructive\">{submitError}</p>\n </div>\n )}\n\n <div className=\"pt-1 border-t border-border\">\n <p className=\"text-xs text-muted-foreground mb-3\">\n Credits will be converted to USD at the current credit rate. Withdrawals are\n reviewed before processing and may take 3–5 business days.\n </p>\n <button\n onClick={() => void handleWithdraw()}\n disabled={\n isSubmitting || !amountValid || !selectedAccountId || activeAccounts.length === 0\n }\n className=\"w-full py-2.5 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n {isSubmitting ? 'Submitting…' : 'Request Withdrawal'}\n </button>\n </div>\n </div>\n </div>\n </div>\n\n {/* Withdrawal history */}\n <div className=\"space-y-3\">\n <div className=\"flex items-center justify-between\">\n <h2 className=\"text-base font-semibold text-foreground\">Withdrawal History</h2>\n <button\n onClick={() => void loadHistory()}\n className=\"text-sm text-muted-foreground hover:text-foreground transition-colors\"\n aria-label=\"Refresh withdrawal history\"\n >\n <svg className=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15\"\n />\n </svg>\n </button>\n </div>\n\n {isLoadingHistory ? (\n <div className=\"space-y-2\">\n {[1, 2, 3].map((i) => (\n <div\n key={i}\n className=\"h-16 border border-border rounded-lg bg-muted animate-pulse\"\n />\n ))}\n </div>\n ) : history.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-10 border border-dashed border-border rounded-lg\">\n <svg\n className=\"w-8 h-8 text-muted-foreground mb-2\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={1.5}\n d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"\n />\n </svg>\n <p className=\"text-sm text-muted-foreground\">No withdrawal requests yet</p>\n </div>\n ) : (\n <div className=\"border border-border rounded-lg overflow-hidden\">\n <table className=\"w-full text-sm\">\n <thead className=\"bg-muted/50 border-b border-border\">\n <tr>\n <th className=\"text-left px-4 py-3 text-xs font-medium text-muted-foreground uppercase tracking-wide\">\n Amount\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium text-muted-foreground uppercase tracking-wide\">\n Status\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium text-muted-foreground uppercase tracking-wide hidden sm:table-cell\">\n Payout Account\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium text-muted-foreground uppercase tracking-wide hidden md:table-cell\">\n Requested\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium text-muted-foreground uppercase tracking-wide hidden md:table-cell\">\n Completed\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border\">\n {history.map((req) => (\n <tr key={req.id} className=\"hover:bg-muted/30 transition-colors\">\n <td className=\"px-4 py-3 font-medium text-foreground\">\n {req.requestedAmount.toLocaleString()} {req.currency}\n </td>\n <td className=\"px-4 py-3\">\n <span\n className={`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${getWithdrawalStatusBg(req.status)}`}\n >\n {req.status.charAt(0) + req.status.slice(1).toLowerCase()}\n </span>\n {req.failureReason && (\n <p\n className=\"text-xs text-destructive mt-0.5 max-w-[180px] truncate\"\n title={req.failureReason}\n >\n {req.failureReason}\n </p>\n )}\n </td>\n <td className=\"px-4 py-3 text-muted-foreground hidden sm:table-cell\">\n {req.payoutAccount ? (\n <span>\n {req.payoutAccount.label}\n {req.payoutAccount.accountLast4\n ? ` ···${req.payoutAccount.accountLast4}`\n : ''}\n </span>\n ) : (\n '—'\n )}\n </td>\n <td className=\"px-4 py-3 text-muted-foreground hidden md:table-cell\">\n <span title={formatDate(req.createdAt, 'long')}>\n {formatRelativeTime(req.createdAt)}\n </span>\n </td>\n <td className=\"px-4 py-3 text-muted-foreground hidden md:table-cell\">\n {req.paidAt ? (\n <span className={getWithdrawalStatusColor('PAID')}>\n {formatDate(req.paidAt, 'short')}\n </span>\n ) : (\n '—'\n )}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAoCA,eAAe,GACb,GACA,GAC8B;AAS9B,SARa,MAAM,EAGjB;EACA,GAAG;EACH,OAAO;EACP,WAAW,EAAE,qBAAkB;EAChC,CAAC,EACU;;AAGd,eAAe,GACb,GAOA,GACoF;AAgBpF,SAfa,MAAM,EAUjB;EACA,GAAG;EACH,OAAO;EACP,WAAW,EAAE,UAAO;EACrB,CAAC,EACU;;AAGd,eAAe,GACb,GACA,GAC0B;AAS1B,SARa,MAAM,EAGjB;EACA,GAAG;EACH,OAAO;EACP,WAAW,EAAE,qBAAkB;EAChC,CAAC,EACU,iBAAiB;;AAc/B,IAAM,KAAqC,EAAE,UAAO,UAAO,gBAAa,mBACtE,kBAAC,OAAD;CACE,WAAW,uCACT,IAAY,mDAAmD;WAFnE;EAKE,kBAAC,KAAD;GAAG,WAAU;aAAiC;GAAU,CAAA;EACxD,kBAAC,KAAD;GAAG,WAAW,2BAA2B,IAAY,iBAAiB;aAAtE;IACG,EAAM,gBAAgB;IAAC;IAAC,kBAAC,QAAD;KAAM,WAAU;eAAwB;KAAc,CAAA;IAC7E;;EACH,KAAe,kBAAC,KAAD;GAAG,WAAU;aAAsC;GAAgB,CAAA;EAC/E;;AAGR,SAA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Q;WAC3B,CAAA,GAEP;UAEC,CAAA;SACF;UA7CI,EAAI,GA6CR,CACL;OACI,CAAA,CACF;;KACJ,CAAA,CAEJ;;GACF"}
|
|
1
|
+
{"version":3,"file":"CreditWithdrawalPage.js","names":[],"sources":["../../../../../src/billing/modules/credits/pages/CreditWithdrawalPage.tsx"],"sourcesContent":["/**\n * Credits Module - Credit Withdrawal Page\n * Allows users to withdraw withdrawable credits (purchased + earned) to a payout account.\n */\n\nimport { useState, useEffect, type FC } from 'react';\nimport {\n CreditWithdrawalHistoryDocument,\n GetCreditBalanceByTypeDocument,\n RequestCreditWithdrawalDocument,\n useGetCostOfCreditsCheckoutQuery,\n} from '../../../../generated/global-operations';\nimport { useBillingPermissions } from '../../../hooks/useBillingPermissions';\nimport { useBillingEventEmitter } from '../../../hooks/useBillingEventEmitter';\nimport { useBilling } from '../../../providers/BillingProvider';\nimport { useDefaultBillingAccount } from '../../subscriptions/hooks';\nimport { directBillingGraphqlRequest } from '../../../shared/utils';\nimport {\n fetchPayoutAccounts,\n addPayoutAccount,\n type PayoutAccount,\n type PayoutRequest,\n} from '../../earnings/api';\nimport { formatDate, formatRelativeTime } from '../../../shared/utils/format';\nimport { statusTokens } from '../../../shared/utils/tokens';\nimport type { CreditBalanceByType } from '../../../shared/types';\n\n// ============================================================================\n// API helpers (credit-specific)\n// ============================================================================\n\ninterface GatewayContext {\n apiGatewayUrl?: string;\n authToken?: string;\n orgId?: string;\n}\n\nasync function fetchCreditBalanceByType(\n billingAccountId: string,\n ctx: GatewayContext\n): Promise<CreditBalanceByType> {\n const data = await directBillingGraphqlRequest<\n { getCreditBalanceByType: CreditBalanceByType },\n { billingAccountId: string }\n >({\n ...ctx,\n query: GetCreditBalanceByTypeDocument,\n variables: { billingAccountId },\n });\n return data.getCreditBalanceByType;\n}\n\nasync function requestCreditWithdrawal(\n input: {\n billingAccountId: string;\n creditAmount: number;\n payoutAccountId: string;\n currency?: string;\n notes?: string;\n },\n ctx: GatewayContext\n): Promise<{ id: string; status: string; requestedAmount: number; currency: string }> {\n const data = await directBillingGraphqlRequest<\n {\n requestCreditWithdrawal: {\n id: string;\n status: string;\n requestedAmount: number;\n currency: string;\n };\n },\n { input: typeof input }\n >({\n ...ctx,\n query: RequestCreditWithdrawalDocument,\n variables: { input },\n });\n return data.requestCreditWithdrawal;\n}\n\nasync function fetchCreditWithdrawalHistory(\n billingAccountId: string,\n ctx: GatewayContext\n): Promise<PayoutRequest[]> {\n const data = await directBillingGraphqlRequest<\n { myPayoutRequests: { items: PayoutRequest[] } },\n { billingAccountId: string }\n >({\n ...ctx,\n query: CreditWithdrawalHistoryDocument,\n variables: { billingAccountId },\n });\n return data.myPayoutRequests.items;\n}\n\n// ============================================================================\n// Sub-components\n// ============================================================================\n\ninterface BalanceCardProps {\n label: string;\n value: number;\n description?: string;\n highlight?: boolean;\n}\n\nconst BalanceCard: FC<BalanceCardProps> = ({ label, value, description, highlight }) => (\n <div\n className={`border border-border rounded-lg p-5 ${\n highlight ? 'bg-gradient-to-br from-primary/5 to-primary/10' : 'bg-card'\n }`}\n >\n <p className=\"text-sm text-muted-foreground\">{label}</p>\n <p className={`text-2xl font-bold mt-1 ${highlight ? 'text-primary' : 'text-foreground'}`}>\n {value.toLocaleString()} <span className=\"text-base font-normal\">credits</span>\n </p>\n {description && <p className=\"text-xs text-muted-foreground mt-1\">{description}</p>}\n </div>\n);\n\nfunction getWithdrawalStatusColor(status: string): string {\n switch (status.toUpperCase()) {\n case 'PAID':\n return statusTokens.success.text;\n case 'APPROVED':\n case 'PROCESSING':\n return statusTokens.info.text;\n case 'REQUESTED':\n return statusTokens.warning.text;\n case 'REJECTED':\n case 'FAILED':\n case 'CANCELED':\n return statusTokens.error.text;\n default:\n return 'text-muted-foreground';\n }\n}\n\nfunction getWithdrawalStatusBg(status: string): string {\n switch (status.toUpperCase()) {\n case 'PAID':\n return `${statusTokens.success.bg} ${statusTokens.success.text}`;\n case 'APPROVED':\n case 'PROCESSING':\n return `${statusTokens.info.bg} ${statusTokens.info.text}`;\n case 'REQUESTED':\n return `${statusTokens.warning.bg} ${statusTokens.warning.text}`;\n case 'REJECTED':\n case 'FAILED':\n case 'CANCELED':\n return `${statusTokens.error.bg} ${statusTokens.error.text}`;\n default:\n return 'bg-muted text-muted-foreground';\n }\n}\n\n// ============================================================================\n// Main Page\n// ============================================================================\n\nexport const CreditWithdrawalPage: FC = () => {\n const permissions = useBillingPermissions();\n const { billingAccount, isLoading: isLoadingAccount } = useDefaultBillingAccount();\n const { apiGatewayUrl, authToken, orgId } = useBilling();\n const { emit } = useBillingEventEmitter();\n\n // Balance state\n const [balance, setBalance] = useState<CreditBalanceByType | null>(null);\n const [isLoadingBalance, setIsLoadingBalance] = useState(false);\n const [balanceError, setBalanceError] = useState<string | null>(null);\n\n // Payout accounts state\n const [payoutAccounts, setPayoutAccounts] = useState<PayoutAccount[]>([]);\n const [isLoadingAccounts, setIsLoadingAccounts] = useState(false);\n\n // Withdrawal history state\n const [history, setHistory] = useState<PayoutRequest[]>([]);\n const [isLoadingHistory, setIsLoadingHistory] = useState(false);\n\n // Withdrawal form state\n const [selectedAccountId, setSelectedAccountId] = useState<string>('');\n const [creditAmount, setCreditAmount] = useState<string>('');\n const [notes, setNotes] = useState<string>('');\n const [isSubmitting, setIsSubmitting] = useState(false);\n const [submitError, setSubmitError] = useState<string | null>(null);\n const [submitSuccess, setSubmitSuccess] = useState(false);\n\n // New payout account form state\n const [showAddAccount, setShowAddAccount] = useState(false);\n const [accountForm, setAccountForm] = useState({\n label: '',\n type: 'BANK_ACCOUNT' as 'BANK_ACCOUNT' | 'UPI',\n accountHolderName: '',\n accountNumber: '',\n ifscCode: '',\n routingNumber: '',\n upiId: '',\n country: '',\n currency: 'USD',\n });\n const [isAddingAccount, setIsAddingAccount] = useState(false);\n const [addAccountError, setAddAccountError] = useState<string | null>(null);\n\n const billingAccountId = billingAccount?.id;\n\n const getCtx = (): GatewayContext => ({\n apiGatewayUrl,\n authToken,\n orgId,\n });\n\n const loadBalance = async () => {\n if (!billingAccountId) return;\n setIsLoadingBalance(true);\n setBalanceError(null);\n try {\n const b = await fetchCreditBalanceByType(billingAccountId, getCtx());\n setBalance(b);\n } catch (e) {\n setBalanceError(e instanceof Error ? e.message : 'Failed to load balance');\n } finally {\n setIsLoadingBalance(false);\n }\n };\n\n const loadAccounts = async () => {\n if (!billingAccountId) return;\n setIsLoadingAccounts(true);\n try {\n const accounts = await fetchPayoutAccounts(billingAccountId, getCtx());\n setPayoutAccounts(accounts);\n const defaultAcc = accounts.find((a) => a.isDefault) ?? accounts[0];\n if (defaultAcc) setSelectedAccountId(defaultAcc.id);\n } catch {\n // silently fail - user will see empty state\n } finally {\n setIsLoadingAccounts(false);\n }\n };\n\n const loadHistory = async () => {\n if (!billingAccountId) return;\n setIsLoadingHistory(true);\n try {\n const items = await fetchCreditWithdrawalHistory(billingAccountId, getCtx());\n setHistory(items);\n } catch {\n // silently fail\n } finally {\n setIsLoadingHistory(false);\n }\n };\n\n useEffect(() => {\n if (billingAccountId) {\n void loadBalance();\n void loadAccounts();\n void loadHistory();\n }\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [billingAccountId]);\n\n // Sync payout account currency to billing account currency when it loads\n useEffect(() => {\n if (billingAccount?.currency) {\n setAccountForm((f) => ({ ...f, currency: billingAccount.currency ?? 'USD' }));\n }\n }, [billingAccount?.currency]);\n\n const handleAddAccount = async () => {\n if (!billingAccountId) return;\n setAddAccountError(null);\n setIsAddingAccount(true);\n try {\n const isIndia =\n accountForm.country.trim().toUpperCase() === 'IN' ||\n accountForm.country.trim().toLowerCase() === 'india';\n\n await addPayoutAccount(\n {\n billingAccountId,\n label: accountForm.label,\n type: accountForm.type,\n accountHolderName: accountForm.accountHolderName,\n country: accountForm.country || undefined,\n currency: accountForm.currency,\n ...(accountForm.type === 'BANK_ACCOUNT' && {\n accountNumber: accountForm.accountNumber,\n ...(isIndia\n ? { ifsc: accountForm.ifscCode }\n : { routingNumber: accountForm.routingNumber }),\n }),\n ...(accountForm.type === 'UPI' && { upiId: accountForm.upiId }),\n },\n getCtx()\n );\n emit('billing.payout_account.added', {\n route: '/billing/credits/withdraw',\n entityId: billingAccountId,\n source: 'credit-withdrawal',\n });\n await loadAccounts();\n setShowAddAccount(false);\n setAccountForm({\n label: '',\n type: 'BANK_ACCOUNT' as 'BANK_ACCOUNT' | 'UPI',\n accountHolderName: '',\n accountNumber: '',\n ifscCode: '',\n routingNumber: '',\n upiId: '',\n country: '',\n currency: 'USD',\n });\n } catch (e) {\n setAddAccountError(e instanceof Error ? e.message : 'Failed to add account');\n } finally {\n setIsAddingAccount(false);\n }\n };\n\n const handleWithdraw = async () => {\n if (!billingAccountId || !selectedAccountId) return;\n const amount = parseFloat(creditAmount);\n if (!amount || amount <= 0) return;\n\n setSubmitError(null);\n setIsSubmitting(true);\n try {\n const withdrawal = await requestCreditWithdrawal(\n {\n billingAccountId,\n creditAmount: amount,\n payoutAccountId: selectedAccountId,\n notes: notes || undefined,\n },\n getCtx()\n );\n emit('billing.credits.withdrawal_requested', {\n route: '/billing/credits/withdraw',\n entityId: withdrawal.id,\n source: 'credit-withdrawal',\n amount,\n });\n setSubmitSuccess(true);\n setCreditAmount('');\n setNotes('');\n await loadBalance();\n await loadHistory();\n } catch (e) {\n setSubmitError(e instanceof Error ? e.message : 'Withdrawal request failed');\n } finally {\n setIsSubmitting(false);\n }\n };\n\n const accountCurrency = billingAccount?.currency ?? 'USD';\n const withdrawAmount = parseFloat(creditAmount) || 0;\n\n const { data: costData, loading: isFetchingCost } = useGetCostOfCreditsCheckoutQuery({\n variables: { creditAmount: withdrawAmount, currency: accountCurrency },\n skip: withdrawAmount <= 0 || !billingAccount,\n });\n\n const estimatedPayout = costData?.getCostOfCredits?.amount;\n\n // Permission check\n if (!permissions.canWithdrawCredits) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-2\">\n <div className=\"w-12 h-12 mx-auto rounded-full bg-muted flex items-center justify-center\">\n <svg\n className=\"w-6 h-6 text-muted-foreground\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M12 15v2m-6 4h12a2 2 0 002-2v-6a2 2 0 00-2-2H6a2 2 0 00-2 2v6a2 2 0 002 2zm10-10V7a4 4 0 00-8 0v4h8z\"\n />\n </svg>\n </div>\n <h2 className=\"text-lg font-semibold text-foreground\">Access Denied</h2>\n <p className=\"text-sm text-muted-foreground\">\n You don't have permission to withdraw credits.\n </p>\n </div>\n </div>\n );\n }\n\n if (!isLoadingAccount && !billingAccount) {\n return (\n <div className=\"flex items-center justify-center h-full min-h-[400px]\">\n <div className=\"text-center space-y-2\">\n <h2 className=\"text-lg font-semibold text-foreground\">No Billing Account</h2>\n <p className=\"text-sm text-muted-foreground\">\n You need a billing account to withdraw credits.\n </p>\n </div>\n </div>\n );\n }\n\n if (isLoadingAccount && !billingAccount) {\n return (\n <div className=\"space-y-6 p-6\">\n <div className=\"h-8 w-64 bg-muted animate-pulse rounded\" />\n <div className=\"grid grid-cols-2 lg:grid-cols-4 gap-4\">\n {[1, 2, 3, 4].map((i) => (\n <div key={i} className=\"border border-border rounded-lg p-5\">\n <div className=\"h-4 w-24 bg-muted animate-pulse rounded mb-2\" />\n <div className=\"h-8 w-32 bg-muted animate-pulse rounded\" />\n </div>\n ))}\n </div>\n </div>\n );\n }\n\n const withdrawable = balance?.withdrawable ?? 0;\n const amountValid = withdrawAmount > 0 && withdrawAmount <= withdrawable;\n const activeAccounts = payoutAccounts.filter((a) => a.status !== 'ARCHIVED');\n\n return (\n <div className=\"space-y-6 p-6\">\n {/* Header */}\n <div>\n <h1 className=\"text-2xl font-bold text-foreground\">Withdraw Credits</h1>\n <p className=\"text-sm text-muted-foreground mt-1\">\n Convert your withdrawable credits (purchased & earned) to a payout\n </p>\n </div>\n\n {/* Balance breakdown */}\n <div className=\"grid grid-cols-2 lg:grid-cols-4 gap-4\">\n {isLoadingBalance ? (\n [1, 2, 3, 4].map((i) => (\n <div key={i} className=\"border border-border rounded-lg p-5\">\n <div className=\"h-4 w-20 bg-muted animate-pulse rounded mb-2\" />\n <div className=\"h-8 w-28 bg-muted animate-pulse rounded\" />\n </div>\n ))\n ) : balanceError ? (\n <div className=\"col-span-4 text-sm text-destructive\">{balanceError}</div>\n ) : (\n <>\n <BalanceCard\n label=\"Purchased\"\n value={balance?.purchased ?? 0}\n description=\"From credit purchases\"\n />\n <BalanceCard\n label=\"Earned\"\n value={balance?.earned ?? 0}\n description=\"From sales & referrals\"\n />\n <BalanceCard\n label=\"Granted\"\n value={balance?.granted ?? 0}\n description=\"Coupons & admin grants — non-withdrawable\"\n />\n <BalanceCard\n label=\"Withdrawable\"\n value={withdrawable}\n description=\"Purchased + earned\"\n highlight\n />\n </>\n )}\n </div>\n\n {/* Success banner */}\n {submitSuccess && (\n <div className=\"flex items-center gap-3 p-4 rounded-lg bg-status-success-bg-subtle border border-status-success-border text-status-success-text\">\n <svg className=\"w-5 h-5 shrink-0\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path strokeLinecap=\"round\" strokeLinejoin=\"round\" strokeWidth={2} d=\"M5 13l4 4L19 7\" />\n </svg>\n <div>\n <p className=\"font-medium\">Withdrawal request submitted</p>\n <p className=\"text-sm opacity-80\">Our team will review and process your request.</p>\n </div>\n <button\n onClick={() => setSubmitSuccess(false)}\n className=\"ml-auto text-current opacity-60 hover:opacity-100\"\n >\n <svg className=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M6 18L18 6M6 6l12 12\"\n />\n </svg>\n </button>\n </div>\n )}\n\n {/* Main two-column layout */}\n <div className=\"grid grid-cols-1 lg:grid-cols-2 gap-6\">\n {/* Left: Payout account management */}\n <div className=\"space-y-4\">\n <div className=\"flex items-center justify-between\">\n <h2 className=\"text-base font-semibold text-foreground\">Payout Account</h2>\n <button\n onClick={() => setShowAddAccount((v) => !v)}\n className=\"text-sm text-primary hover:underline\"\n >\n {showAddAccount ? 'Cancel' : '+ Add new'}\n </button>\n </div>\n\n {/* Add account form */}\n {showAddAccount && (\n <div className=\"border border-border rounded-lg p-4 space-y-3 bg-muted/30\">\n <h3 className=\"text-sm font-medium text-foreground\">New Payout Account</h3>\n\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">Label</label>\n <input\n type=\"text\"\n value={accountForm.label}\n onChange={(e) => setAccountForm((f) => ({ ...f, label: e.target.value }))}\n placeholder=\"e.g. My Bank Account\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">\n Account Holder Name\n </label>\n <input\n type=\"text\"\n value={accountForm.accountHolderName}\n onChange={(e) =>\n setAccountForm((f) => ({ ...f, accountHolderName: e.target.value }))\n }\n placeholder=\"Full name as on bank account\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n\n <div className=\"grid grid-cols-2 gap-3\">\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">Type</label>\n <select\n value={accountForm.type}\n onChange={(e) =>\n setAccountForm((f) => ({\n ...f,\n type: e.target.value as typeof accountForm.type,\n }))\n }\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n >\n <option value=\"BANK_ACCOUNT\">Bank Account</option>\n <option value=\"UPI\">UPI</option>\n </select>\n </div>\n\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">Country</label>\n <input\n type=\"text\"\n value={accountForm.country}\n onChange={(e) => setAccountForm((f) => ({ ...f, country: e.target.value }))}\n placeholder=\"e.g. India, US, UK\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n </div>\n\n {accountForm.type === 'BANK_ACCOUNT' && (\n <>\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">\n Account Number\n </label>\n <input\n type=\"text\"\n value={accountForm.accountNumber}\n onChange={(e) =>\n setAccountForm((f) => ({ ...f, accountNumber: e.target.value }))\n }\n placeholder=\"Account number\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n {accountForm.country.trim().toUpperCase() === 'IN' ||\n accountForm.country.trim().toLowerCase() === 'india' ? (\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">IFSC Code</label>\n <input\n type=\"text\"\n value={accountForm.ifscCode}\n onChange={(e) =>\n setAccountForm((f) => ({ ...f, ifscCode: e.target.value.toUpperCase() }))\n }\n placeholder=\"e.g. SBIN0001234\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n ) : (\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">\n Routing Number\n </label>\n <input\n type=\"text\"\n value={accountForm.routingNumber}\n onChange={(e) =>\n setAccountForm((f) => ({ ...f, routingNumber: e.target.value }))\n }\n placeholder=\"Routing / sort code\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n )}\n </>\n )}\n\n {accountForm.type === 'UPI' && (\n <div>\n <label className=\"block text-xs text-muted-foreground mb-1\">UPI ID</label>\n <input\n type=\"text\"\n value={accountForm.upiId}\n onChange={(e) => setAccountForm((f) => ({ ...f, upiId: e.target.value }))}\n placeholder=\"yourname@upi\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n </div>\n )}\n\n {addAccountError && <p className=\"text-xs text-destructive\">{addAccountError}</p>}\n\n <button\n onClick={() => void handleAddAccount()}\n disabled={isAddingAccount || !accountForm.label || !accountForm.accountHolderName}\n className=\"w-full py-2 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n {isAddingAccount ? 'Saving…' : 'Save Account'}\n </button>\n </div>\n )}\n\n {/* Existing accounts */}\n {isLoadingAccounts ? (\n <div className=\"space-y-2\">\n {[1, 2].map((i) => (\n <div\n key={i}\n className=\"h-16 border border-border rounded-lg bg-muted animate-pulse\"\n />\n ))}\n </div>\n ) : activeAccounts.length === 0 && !showAddAccount ? (\n <div className=\"flex flex-col items-center justify-center py-8 border border-dashed border-border rounded-lg\">\n <svg\n className=\"w-8 h-8 text-muted-foreground mb-2\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={1.5}\n d=\"M3 10h18M7 15h1m4 0h1m-7 4h12a3 3 0 003-3V8a3 3 0 00-3-3H6a3 3 0 00-3 3v8a3 3 0 003 3z\"\n />\n </svg>\n <p className=\"text-sm text-muted-foreground\">No payout accounts yet</p>\n <button\n onClick={() => setShowAddAccount(true)}\n className=\"mt-2 text-sm text-primary hover:underline\"\n >\n Add a bank account or UPI\n </button>\n </div>\n ) : (\n <div className=\"space-y-2\">\n {activeAccounts.map((account) => (\n <button\n key={account.id}\n onClick={() => setSelectedAccountId(account.id)}\n className={`w-full text-left p-4 border rounded-lg transition-colors ${\n selectedAccountId === account.id\n ? 'border-primary bg-primary/5'\n : 'border-border bg-card hover:border-primary/40'\n }`}\n >\n <div className=\"flex items-center justify-between\">\n <div>\n <p className=\"text-sm font-medium text-foreground\">{account.label}</p>\n <p className=\"text-xs text-muted-foreground mt-0.5\">\n {account.type.replaceAll('_', ' ')}\n {account.displayName ? ` · ${account.displayName}` : ''}\n {account.accountLast4 ? ` ···${account.accountLast4}` : ''}\n {account.country ? ` · ${account.country}` : ''}\n </p>\n </div>\n <div className=\"flex items-center gap-2\">\n {account.isDefault && (\n <span className=\"text-xs px-2 py-0.5 rounded bg-primary/10 text-primary font-medium\">\n Default\n </span>\n )}\n <span\n className={`text-xs px-2 py-0.5 rounded font-medium ${\n account.status === 'ACTIVE'\n ? `${statusTokens.success.bg} ${statusTokens.success.text}`\n : account.status === 'PENDING_VERIFICATION'\n ? `${statusTokens.warning.bg} ${statusTokens.warning.text}`\n : `${statusTokens.error.bg} ${statusTokens.error.text}`\n }`}\n >\n {account.status.replaceAll('_', ' ').toLowerCase()}\n </span>\n {selectedAccountId === account.id && (\n <svg\n className=\"w-4 h-4 text-primary shrink-0\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M5 13l4 4L19 7\"\n />\n </svg>\n )}\n </div>\n </div>\n </button>\n ))}\n </div>\n )}\n </div>\n\n {/* Right: Withdrawal request form */}\n <div className=\"space-y-4\">\n <h2 className=\"text-base font-semibold text-foreground\">Request Withdrawal</h2>\n\n <div className=\"border border-border rounded-lg p-5 bg-card space-y-4\">\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-1\">\n Credits to Withdraw\n </label>\n <input\n type=\"number\"\n min={1}\n max={withdrawable}\n step={1}\n value={creditAmount}\n onChange={(e) => setCreditAmount(e.target.value)}\n placeholder=\"Enter credit amount\"\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30\"\n />\n <p className=\"text-xs text-muted-foreground mt-1\">\n Max withdrawable:{' '}\n <span className=\"font-medium\">{withdrawable.toLocaleString()} credits</span>\n </p>\n {withdrawAmount > 0 && withdrawAmount <= withdrawable && (\n <p className=\"text-xs text-muted-foreground mt-1\">\n {isFetchingCost ? (\n 'Calculating…'\n ) : estimatedPayout != null ? (\n <>\n Estimated payout:{' '}\n <span className=\"font-semibold text-foreground\">\n {estimatedPayout.toLocaleString(undefined, {\n style: 'currency',\n currency: accountCurrency,\n minimumFractionDigits: 2,\n maximumFractionDigits: 2,\n })}\n </span>{' '}\n at the current credit rate\n </>\n ) : null}\n </p>\n )}\n {withdrawAmount > 0 && withdrawAmount > withdrawable && (\n <p className=\"text-xs text-destructive mt-1\">\n Amount exceeds your withdrawable balance\n </p>\n )}\n </div>\n\n <div>\n <label className=\"block text-sm font-medium text-foreground mb-1\">\n Notes <span className=\"text-muted-foreground font-normal\">(optional)</span>\n </label>\n <textarea\n value={notes}\n onChange={(e) => setNotes(e.target.value)}\n placeholder=\"Any notes for this withdrawal request\"\n rows={2}\n className=\"w-full px-3 py-2 text-sm border border-border rounded-md bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-primary/30 resize-none\"\n />\n </div>\n\n {submitError && (\n <div className=\"p-3 rounded-md bg-destructive/10 border border-destructive/20\">\n <p className=\"text-sm text-destructive\">{submitError}</p>\n </div>\n )}\n\n <div className=\"pt-1 border-t border-border\">\n <p className=\"text-xs text-muted-foreground mb-3\">\n Credits will be converted to {accountCurrency} at the current credit rate.\n Withdrawals are reviewed before processing and may take 3–5 business days.\n </p>\n <button\n onClick={() => void handleWithdraw()}\n disabled={\n isSubmitting || !amountValid || !selectedAccountId || activeAccounts.length === 0\n }\n className=\"w-full py-2.5 text-sm font-medium bg-primary text-primary-foreground rounded-md hover:bg-primary/90 transition-colors disabled:opacity-50 disabled:cursor-not-allowed\"\n >\n {isSubmitting ? 'Submitting…' : 'Request Withdrawal'}\n </button>\n </div>\n </div>\n </div>\n </div>\n\n {/* Withdrawal history */}\n <div className=\"space-y-3\">\n <div className=\"flex items-center justify-between\">\n <h2 className=\"text-base font-semibold text-foreground\">Withdrawal History</h2>\n <button\n onClick={() => void loadHistory()}\n className=\"text-sm text-muted-foreground hover:text-foreground transition-colors\"\n aria-label=\"Refresh withdrawal history\"\n >\n <svg className=\"w-4 h-4\" fill=\"none\" viewBox=\"0 0 24 24\" stroke=\"currentColor\">\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={2}\n d=\"M4 4v5h.582m15.356 2A8.001 8.001 0 004.582 9m0 0H9m11 11v-5h-.581m0 0a8.003 8.003 0 01-15.357-2m15.357 2H15\"\n />\n </svg>\n </button>\n </div>\n\n {isLoadingHistory ? (\n <div className=\"space-y-2\">\n {[1, 2, 3].map((i) => (\n <div\n key={i}\n className=\"h-16 border border-border rounded-lg bg-muted animate-pulse\"\n />\n ))}\n </div>\n ) : history.length === 0 ? (\n <div className=\"flex flex-col items-center justify-center py-10 border border-dashed border-border rounded-lg\">\n <svg\n className=\"w-8 h-8 text-muted-foreground mb-2\"\n fill=\"none\"\n viewBox=\"0 0 24 24\"\n stroke=\"currentColor\"\n >\n <path\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n strokeWidth={1.5}\n d=\"M9 5H7a2 2 0 00-2 2v12a2 2 0 002 2h10a2 2 0 002-2V7a2 2 0 00-2-2h-2M9 5a2 2 0 002 2h2a2 2 0 002-2M9 5a2 2 0 012-2h2a2 2 0 012 2\"\n />\n </svg>\n <p className=\"text-sm text-muted-foreground\">No withdrawal requests yet</p>\n </div>\n ) : (\n <div className=\"border border-border rounded-lg overflow-hidden\">\n <table className=\"w-full text-sm\">\n <thead className=\"bg-muted/50 border-b border-border\">\n <tr>\n <th className=\"text-left px-4 py-3 text-xs font-medium text-muted-foreground uppercase tracking-wide\">\n Amount\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium text-muted-foreground uppercase tracking-wide\">\n Status\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium text-muted-foreground uppercase tracking-wide hidden sm:table-cell\">\n Payout Account\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium text-muted-foreground uppercase tracking-wide hidden md:table-cell\">\n Requested\n </th>\n <th className=\"text-left px-4 py-3 text-xs font-medium text-muted-foreground uppercase tracking-wide hidden md:table-cell\">\n Completed\n </th>\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border\">\n {history.map((req) => (\n <tr key={req.id} className=\"hover:bg-muted/30 transition-colors\">\n <td className=\"px-4 py-3 font-medium text-foreground\">\n {req.requestedAmount.toLocaleString()} {req.currency}\n </td>\n <td className=\"px-4 py-3\">\n <span\n className={`inline-flex items-center px-2 py-0.5 rounded text-xs font-medium ${getWithdrawalStatusBg(req.status)}`}\n >\n {req.status.charAt(0) + req.status.slice(1).toLowerCase()}\n </span>\n {req.failureReason && (\n <p\n className=\"text-xs text-destructive mt-0.5 max-w-[180px] truncate\"\n title={req.failureReason}\n >\n {req.failureReason}\n </p>\n )}\n </td>\n <td className=\"px-4 py-3 text-muted-foreground hidden sm:table-cell\">\n {req.payoutAccount ? (\n <span>\n {req.payoutAccount.label}\n {req.payoutAccount.accountLast4\n ? ` ···${req.payoutAccount.accountLast4}`\n : ''}\n </span>\n ) : (\n '—'\n )}\n </td>\n <td className=\"px-4 py-3 text-muted-foreground hidden md:table-cell\">\n <span title={formatDate(req.createdAt, 'long')}>\n {formatRelativeTime(req.createdAt)}\n </span>\n </td>\n <td className=\"px-4 py-3 text-muted-foreground hidden md:table-cell\">\n {req.paidAt ? (\n <span className={getWithdrawalStatusColor('PAID')}>\n {formatDate(req.paidAt, 'short')}\n </span>\n ) : (\n '—'\n )}\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </div>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;AAqCA,eAAe,GACb,GACA,GAC8B;AAS9B,SARa,MAAM,EAGjB;EACA,GAAG;EACH,OAAO;EACP,WAAW,EAAE,qBAAkB;EAChC,CAAC,EACU;;AAGd,eAAe,GACb,GAOA,GACoF;AAgBpF,SAfa,MAAM,EAUjB;EACA,GAAG;EACH,OAAO;EACP,WAAW,EAAE,UAAO;EACrB,CAAC,EACU;;AAGd,e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