@doujins/payments-ui 0.1.8 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +594 -531
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -5
- package/dist/index.d.ts +0 -5
- package/dist/index.js +436 -373
- package/dist/index.js.map +1 -1
- package/package.json +3 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
3
|
+
var React15 = require('react');
|
|
4
4
|
var reactQuery = require('@tanstack/react-query');
|
|
5
5
|
var walletAdapterReact = require('@solana/wallet-adapter-react');
|
|
6
6
|
var walletAdapterReactUi = require('@solana/wallet-adapter-react-ui');
|
|
@@ -48,7 +48,7 @@ function _interopNamespace(e) {
|
|
|
48
48
|
return Object.freeze(n);
|
|
49
49
|
}
|
|
50
50
|
|
|
51
|
-
var
|
|
51
|
+
var React15__namespace = /*#__PURE__*/_interopNamespace(React15);
|
|
52
52
|
var DialogPrimitive__namespace = /*#__PURE__*/_interopNamespace(DialogPrimitive);
|
|
53
53
|
var clsx2__default = /*#__PURE__*/_interopDefault(clsx2);
|
|
54
54
|
var countryList__default = /*#__PURE__*/_interopDefault(countryList);
|
|
@@ -64,30 +64,119 @@ var CheckboxPrimitive__namespace = /*#__PURE__*/_interopNamespace(CheckboxPrimit
|
|
|
64
64
|
|
|
65
65
|
// src/utils/collect.ts
|
|
66
66
|
var SCRIPT_SRC = "https://secure.networkmerchants.com/token/Collect.js";
|
|
67
|
+
var baseFieldReset = {
|
|
68
|
+
border: "none",
|
|
69
|
+
"border-bottom": "0",
|
|
70
|
+
"border-top": "0",
|
|
71
|
+
"border-left": "0",
|
|
72
|
+
"border-right": "0",
|
|
73
|
+
"border-width": "0",
|
|
74
|
+
"border-color": "transparent",
|
|
75
|
+
"border-style": "none",
|
|
76
|
+
outline: "none",
|
|
77
|
+
"box-shadow": "none",
|
|
78
|
+
"background-clip": "padding-box",
|
|
79
|
+
"text-decoration": "none"
|
|
80
|
+
};
|
|
81
|
+
var customCss = {
|
|
82
|
+
...baseFieldReset,
|
|
83
|
+
background: "#0d1325",
|
|
84
|
+
"background-color": "#0d1325",
|
|
85
|
+
color: "#e2e8f0",
|
|
86
|
+
padding: "0",
|
|
87
|
+
margin: "0",
|
|
88
|
+
width: "100%",
|
|
89
|
+
height: "100%",
|
|
90
|
+
"font-size": "15px",
|
|
91
|
+
"letter-spacing": "0.05em",
|
|
92
|
+
"line-height": "1.5"
|
|
93
|
+
};
|
|
94
|
+
var focusCss = {
|
|
95
|
+
...baseFieldReset,
|
|
96
|
+
color: "#f8fafc",
|
|
97
|
+
"box-shadow": "0 0 0 1px rgba(94,234,212,0.3)"
|
|
98
|
+
};
|
|
99
|
+
var invalidCss = {
|
|
100
|
+
...baseFieldReset,
|
|
101
|
+
color: "#fecaca",
|
|
102
|
+
"box-shadow": "0 0 0 1px rgba(248,113,113,0.5)"
|
|
103
|
+
};
|
|
104
|
+
var placeholderCss = {
|
|
105
|
+
color: "rgba(226,232,240,0.45)",
|
|
106
|
+
"font-size": "14px",
|
|
107
|
+
"letter-spacing": "0.03em"
|
|
108
|
+
};
|
|
109
|
+
var baseCssString = JSON.stringify(customCss);
|
|
110
|
+
var focusCssString = JSON.stringify(focusCss);
|
|
111
|
+
var invalidCssString = JSON.stringify(invalidCss);
|
|
112
|
+
var placeholderCssString = JSON.stringify(placeholderCss);
|
|
113
|
+
var collectCssConfig = {
|
|
114
|
+
customCss,
|
|
115
|
+
focusCss,
|
|
116
|
+
invalidCss,
|
|
117
|
+
placeholderCss
|
|
118
|
+
};
|
|
119
|
+
var loadPromise = null;
|
|
67
120
|
var loadCollectJs = (tokenizationKey) => {
|
|
68
121
|
if (typeof document === "undefined") return;
|
|
122
|
+
if (typeof window !== "undefined" && window.CollectJS) {
|
|
123
|
+
return Promise.resolve();
|
|
124
|
+
}
|
|
69
125
|
const trimmed = tokenizationKey?.trim();
|
|
70
126
|
if (!trimmed || trimmed.length < 10) {
|
|
71
127
|
console.warn("payments-ui: invalid Collect.js key, skipping load");
|
|
72
128
|
return;
|
|
73
129
|
}
|
|
130
|
+
if (loadPromise) {
|
|
131
|
+
return loadPromise;
|
|
132
|
+
}
|
|
74
133
|
const existing = document.querySelector(`script[src="${SCRIPT_SRC}"]`);
|
|
75
|
-
if (existing)
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
134
|
+
if (existing) {
|
|
135
|
+
loadPromise = new Promise((resolve) => {
|
|
136
|
+
existing.addEventListener("load", () => resolve(), { once: true });
|
|
137
|
+
existing.addEventListener("error", () => resolve(), { once: true });
|
|
138
|
+
});
|
|
139
|
+
return loadPromise;
|
|
140
|
+
}
|
|
141
|
+
loadPromise = new Promise((resolve, reject) => {
|
|
142
|
+
const script = document.createElement("script");
|
|
143
|
+
script.src = SCRIPT_SRC;
|
|
144
|
+
script.setAttribute("data-tokenization-key", trimmed);
|
|
145
|
+
script.setAttribute("data-field-ccnumber-placeholder", "0000 0000 0000 0000");
|
|
146
|
+
script.setAttribute("data-field-ccexp-placeholder", "10 / 25");
|
|
147
|
+
script.setAttribute("data-field-cvv-placeholder", "123");
|
|
148
|
+
script.setAttribute("data-variant", "inline");
|
|
149
|
+
script.setAttribute("data-style-sniffer", "false");
|
|
150
|
+
script.setAttribute("data-custom-css", baseCssString);
|
|
151
|
+
script.setAttribute("data-placeholder-css", placeholderCssString);
|
|
152
|
+
script.setAttribute("data-focus-css", focusCssString);
|
|
153
|
+
script.setAttribute("data-invalid-css", invalidCssString);
|
|
154
|
+
script.async = true;
|
|
155
|
+
script.addEventListener("load", () => {
|
|
156
|
+
console.log("payments-ui: Collect.js loaded");
|
|
157
|
+
resolve();
|
|
158
|
+
});
|
|
159
|
+
script.addEventListener("error", (event) => {
|
|
160
|
+
console.error("payments-ui: failed to load Collect.js", event);
|
|
161
|
+
reject(event);
|
|
162
|
+
});
|
|
163
|
+
document.head.appendChild(script);
|
|
89
164
|
});
|
|
90
|
-
|
|
165
|
+
window.__doujinsCollectPromise = loadPromise;
|
|
166
|
+
return loadPromise;
|
|
167
|
+
};
|
|
168
|
+
var waitForCollectJs = async () => {
|
|
169
|
+
if (typeof window === "undefined") return null;
|
|
170
|
+
if (window.CollectJS) return window.CollectJS;
|
|
171
|
+
const promise = loadPromise ?? window.__doujinsCollectPromise;
|
|
172
|
+
if (!promise) return null;
|
|
173
|
+
try {
|
|
174
|
+
await promise;
|
|
175
|
+
return window.CollectJS ?? null;
|
|
176
|
+
} catch (error) {
|
|
177
|
+
console.error("payments-ui: Collect.js failed to initialise", error);
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
91
180
|
};
|
|
92
181
|
|
|
93
182
|
// src/lib/client.ts
|
|
@@ -295,77 +384,103 @@ var createClient = (config) => {
|
|
|
295
384
|
function cn(...inputs) {
|
|
296
385
|
return tailwindMerge.twMerge(clsx2.clsx(inputs));
|
|
297
386
|
}
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
DialogPrimitive__namespace.
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
315
|
-
DialogPrimitive__namespace.Content,
|
|
387
|
+
function Dialog({
|
|
388
|
+
...props
|
|
389
|
+
}) {
|
|
390
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Root, { "data-slot": "dialog", ...props });
|
|
391
|
+
}
|
|
392
|
+
function DialogPortal({
|
|
393
|
+
...props
|
|
394
|
+
}) {
|
|
395
|
+
return /* @__PURE__ */ jsxRuntime.jsx(DialogPrimitive__namespace.Portal, { "data-slot": "dialog-portal", ...props });
|
|
396
|
+
}
|
|
397
|
+
function DialogOverlay({
|
|
398
|
+
className,
|
|
399
|
+
...props
|
|
400
|
+
}) {
|
|
401
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
402
|
+
DialogPrimitive__namespace.Overlay,
|
|
316
403
|
{
|
|
317
|
-
|
|
404
|
+
"data-slot": "dialog-overlay",
|
|
318
405
|
className: cn(
|
|
319
|
-
"
|
|
406
|
+
"data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50",
|
|
320
407
|
className
|
|
321
408
|
),
|
|
322
|
-
...props
|
|
323
|
-
children: [
|
|
324
|
-
children,
|
|
325
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogPrimitive__namespace.Close, { className: "absolute right-4 top-4 rounded-sm opacity-70 ring-offset-background transition-opacity hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", children: [
|
|
326
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.X, { className: "h-4 w-4" }),
|
|
327
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
|
|
328
|
-
] })
|
|
329
|
-
]
|
|
409
|
+
...props
|
|
330
410
|
}
|
|
331
|
-
)
|
|
332
|
-
|
|
333
|
-
DialogContent
|
|
334
|
-
var DialogHeader = ({
|
|
411
|
+
);
|
|
412
|
+
}
|
|
413
|
+
function DialogContent({
|
|
335
414
|
className,
|
|
415
|
+
children,
|
|
416
|
+
showCloseButton = true,
|
|
336
417
|
...props
|
|
337
|
-
})
|
|
338
|
-
"
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
)
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
)
|
|
368
|
-
|
|
418
|
+
}) {
|
|
419
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(DialogPortal, { "data-slot": "dialog-portal", children: [
|
|
420
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogOverlay, {}),
|
|
421
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
422
|
+
DialogPrimitive__namespace.Content,
|
|
423
|
+
{
|
|
424
|
+
"data-slot": "dialog-content",
|
|
425
|
+
className: cn(
|
|
426
|
+
"bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-lg border p-6 shadow-lg duration-200 outline-none sm:max-w-lg",
|
|
427
|
+
className
|
|
428
|
+
),
|
|
429
|
+
...props,
|
|
430
|
+
children: [
|
|
431
|
+
children,
|
|
432
|
+
showCloseButton && /* @__PURE__ */ jsxRuntime.jsxs(
|
|
433
|
+
DialogPrimitive__namespace.Close,
|
|
434
|
+
{
|
|
435
|
+
"data-slot": "dialog-close",
|
|
436
|
+
className: "ring-offset-background focus:ring-ring data-[state=open]:bg-accent data-[state=open]:text-muted-foreground absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
437
|
+
children: [
|
|
438
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.XIcon, {}),
|
|
439
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "sr-only", children: "Close" })
|
|
440
|
+
]
|
|
441
|
+
}
|
|
442
|
+
)
|
|
443
|
+
]
|
|
444
|
+
}
|
|
445
|
+
)
|
|
446
|
+
] });
|
|
447
|
+
}
|
|
448
|
+
function DialogHeader({ className, ...props }) {
|
|
449
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
450
|
+
"div",
|
|
451
|
+
{
|
|
452
|
+
"data-slot": "dialog-header",
|
|
453
|
+
className: cn("flex flex-col gap-2 text-center sm:text-left", className),
|
|
454
|
+
...props
|
|
455
|
+
}
|
|
456
|
+
);
|
|
457
|
+
}
|
|
458
|
+
function DialogTitle({
|
|
459
|
+
className,
|
|
460
|
+
...props
|
|
461
|
+
}) {
|
|
462
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
463
|
+
DialogPrimitive__namespace.Title,
|
|
464
|
+
{
|
|
465
|
+
"data-slot": "dialog-title",
|
|
466
|
+
className: cn("text-lg leading-none font-semibold", className),
|
|
467
|
+
...props
|
|
468
|
+
}
|
|
469
|
+
);
|
|
470
|
+
}
|
|
471
|
+
function DialogDescription({
|
|
472
|
+
className,
|
|
473
|
+
...props
|
|
474
|
+
}) {
|
|
475
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
476
|
+
DialogPrimitive__namespace.Description,
|
|
477
|
+
{
|
|
478
|
+
"data-slot": "dialog-description",
|
|
479
|
+
className: cn("text-muted-foreground text-sm", className),
|
|
480
|
+
...props
|
|
481
|
+
}
|
|
482
|
+
);
|
|
483
|
+
}
|
|
369
484
|
var customCountries = [
|
|
370
485
|
{ code: "TW", name: "Taiwan, Province of China" },
|
|
371
486
|
{ code: "KR", name: "Korea" },
|
|
@@ -406,7 +521,7 @@ var buttonVariants = classVarianceAuthority.cva(
|
|
|
406
521
|
}
|
|
407
522
|
}
|
|
408
523
|
);
|
|
409
|
-
var Button =
|
|
524
|
+
var Button = React15__namespace.forwardRef(
|
|
410
525
|
({ className, variant, size, asChild = false, ...props }, ref) => {
|
|
411
526
|
const Comp = asChild ? reactSlot.Slot : "button";
|
|
412
527
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -420,7 +535,7 @@ var Button = React17__namespace.forwardRef(
|
|
|
420
535
|
}
|
|
421
536
|
);
|
|
422
537
|
Button.displayName = "Button";
|
|
423
|
-
var Input =
|
|
538
|
+
var Input = React15__namespace.forwardRef(
|
|
424
539
|
({ className, type, ...props }, ref) => {
|
|
425
540
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
426
541
|
"input",
|
|
@@ -440,7 +555,7 @@ Input.displayName = "Input";
|
|
|
440
555
|
var labelVariants = classVarianceAuthority.cva(
|
|
441
556
|
"text-sm font-medium leading-none peer-disabled:cursor-not-allowed peer-disabled:opacity-70"
|
|
442
557
|
);
|
|
443
|
-
var Label =
|
|
558
|
+
var Label = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
444
559
|
LabelPrimitive__namespace.Root,
|
|
445
560
|
{
|
|
446
561
|
ref,
|
|
@@ -451,7 +566,7 @@ var Label = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
451
566
|
Label.displayName = LabelPrimitive__namespace.Root.displayName;
|
|
452
567
|
var Select = SelectPrimitive__namespace.Root;
|
|
453
568
|
var SelectValue = SelectPrimitive__namespace.Value;
|
|
454
|
-
var SelectTrigger =
|
|
569
|
+
var SelectTrigger = React15__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
455
570
|
SelectPrimitive__namespace.Trigger,
|
|
456
571
|
{
|
|
457
572
|
ref,
|
|
@@ -467,7 +582,7 @@ var SelectTrigger = React17__namespace.forwardRef(({ className, children, ...pro
|
|
|
467
582
|
}
|
|
468
583
|
));
|
|
469
584
|
SelectTrigger.displayName = SelectPrimitive__namespace.Trigger.displayName;
|
|
470
|
-
var SelectScrollUpButton =
|
|
585
|
+
var SelectScrollUpButton = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
471
586
|
SelectPrimitive__namespace.ScrollUpButton,
|
|
472
587
|
{
|
|
473
588
|
ref,
|
|
@@ -480,7 +595,7 @@ var SelectScrollUpButton = React17__namespace.forwardRef(({ className, ...props
|
|
|
480
595
|
}
|
|
481
596
|
));
|
|
482
597
|
SelectScrollUpButton.displayName = SelectPrimitive__namespace.ScrollUpButton.displayName;
|
|
483
|
-
var SelectScrollDownButton =
|
|
598
|
+
var SelectScrollDownButton = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
484
599
|
SelectPrimitive__namespace.ScrollDownButton,
|
|
485
600
|
{
|
|
486
601
|
ref,
|
|
@@ -493,7 +608,7 @@ var SelectScrollDownButton = React17__namespace.forwardRef(({ className, ...prop
|
|
|
493
608
|
}
|
|
494
609
|
));
|
|
495
610
|
SelectScrollDownButton.displayName = SelectPrimitive__namespace.ScrollDownButton.displayName;
|
|
496
|
-
var SelectContent =
|
|
611
|
+
var SelectContent = React15__namespace.forwardRef(({ className, children, position = "popper", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(SelectPrimitive__namespace.Portal, { children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
497
612
|
SelectPrimitive__namespace.Content,
|
|
498
613
|
{
|
|
499
614
|
ref,
|
|
@@ -521,7 +636,7 @@ var SelectContent = React17__namespace.forwardRef(({ className, children, positi
|
|
|
521
636
|
}
|
|
522
637
|
) }));
|
|
523
638
|
SelectContent.displayName = SelectPrimitive__namespace.Content.displayName;
|
|
524
|
-
var SelectLabel =
|
|
639
|
+
var SelectLabel = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
525
640
|
SelectPrimitive__namespace.Label,
|
|
526
641
|
{
|
|
527
642
|
ref,
|
|
@@ -530,7 +645,7 @@ var SelectLabel = React17__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
530
645
|
}
|
|
531
646
|
));
|
|
532
647
|
SelectLabel.displayName = SelectPrimitive__namespace.Label.displayName;
|
|
533
|
-
var SelectItem =
|
|
648
|
+
var SelectItem = React15__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
534
649
|
SelectPrimitive__namespace.Item,
|
|
535
650
|
{
|
|
536
651
|
ref,
|
|
@@ -546,7 +661,7 @@ var SelectItem = React17__namespace.forwardRef(({ className, children, ...props
|
|
|
546
661
|
}
|
|
547
662
|
));
|
|
548
663
|
SelectItem.displayName = SelectPrimitive__namespace.Item.displayName;
|
|
549
|
-
var SelectSeparator =
|
|
664
|
+
var SelectSeparator = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
550
665
|
SelectPrimitive__namespace.Separator,
|
|
551
666
|
{
|
|
552
667
|
ref,
|
|
@@ -582,8 +697,8 @@ var CardDetailsForm = ({
|
|
|
582
697
|
submitDisabled = false
|
|
583
698
|
}) => {
|
|
584
699
|
const { config } = usePaymentContext();
|
|
585
|
-
const defaultValuesKey =
|
|
586
|
-
const mergedDefaults =
|
|
700
|
+
const defaultValuesKey = React15.useMemo(() => JSON.stringify(defaultValues ?? {}), [defaultValues]);
|
|
701
|
+
const mergedDefaults = React15.useMemo(
|
|
587
702
|
() => ({
|
|
588
703
|
...defaultBillingDetails,
|
|
589
704
|
...defaultValues,
|
|
@@ -591,23 +706,38 @@ var CardDetailsForm = ({
|
|
|
591
706
|
}),
|
|
592
707
|
[defaultValuesKey, config.defaultUser?.email]
|
|
593
708
|
);
|
|
594
|
-
const [firstName, setFirstName] =
|
|
595
|
-
const [lastName, setLastName] =
|
|
596
|
-
const [address1, setAddress1] =
|
|
597
|
-
const [city, setCity] =
|
|
598
|
-
const [stateRegion, setStateRegion] =
|
|
599
|
-
const [postalCode, setPostalCode] =
|
|
600
|
-
const [country, setCountry] =
|
|
601
|
-
const [email, setEmail] =
|
|
602
|
-
const [localError, setLocalError] =
|
|
603
|
-
const [isTokenizing, setIsTokenizing] =
|
|
604
|
-
|
|
709
|
+
const [firstName, setFirstName] = React15.useState(mergedDefaults.firstName);
|
|
710
|
+
const [lastName, setLastName] = React15.useState(mergedDefaults.lastName);
|
|
711
|
+
const [address1, setAddress1] = React15.useState(mergedDefaults.address1);
|
|
712
|
+
const [city, setCity] = React15.useState(mergedDefaults.city);
|
|
713
|
+
const [stateRegion, setStateRegion] = React15.useState(mergedDefaults.stateRegion ?? "");
|
|
714
|
+
const [postalCode, setPostalCode] = React15.useState(mergedDefaults.postalCode);
|
|
715
|
+
const [country, setCountry] = React15.useState(mergedDefaults.country);
|
|
716
|
+
const [email, setEmail] = React15.useState(mergedDefaults.email ?? "");
|
|
717
|
+
const [localError, setLocalError] = React15.useState(null);
|
|
718
|
+
const [isTokenizing, setIsTokenizing] = React15.useState(false);
|
|
719
|
+
const [collectReady, setCollectReady] = React15.useState(
|
|
720
|
+
typeof window !== "undefined" && Boolean(window.CollectJS)
|
|
721
|
+
);
|
|
722
|
+
React15.useEffect(() => {
|
|
723
|
+
if (collectReady) return;
|
|
724
|
+
let active = true;
|
|
725
|
+
waitForCollectJs().then((instance) => {
|
|
726
|
+
if (active && instance) {
|
|
727
|
+
setCollectReady(true);
|
|
728
|
+
}
|
|
729
|
+
});
|
|
730
|
+
return () => {
|
|
731
|
+
active = false;
|
|
732
|
+
};
|
|
733
|
+
}, [collectReady]);
|
|
734
|
+
React15.useEffect(() => {
|
|
605
735
|
if (!visible) {
|
|
606
736
|
setLocalError(null);
|
|
607
737
|
setIsTokenizing(false);
|
|
608
738
|
}
|
|
609
739
|
}, [visible]);
|
|
610
|
-
|
|
740
|
+
React15.useEffect(() => {
|
|
611
741
|
if (!visible) return;
|
|
612
742
|
setFirstName(mergedDefaults.firstName);
|
|
613
743
|
setLastName(mergedDefaults.lastName);
|
|
@@ -618,7 +748,7 @@ var CardDetailsForm = ({
|
|
|
618
748
|
setCountry(mergedDefaults.country);
|
|
619
749
|
setEmail(mergedDefaults.email ?? "");
|
|
620
750
|
}, [defaultValuesKey, mergedDefaults, visible]);
|
|
621
|
-
|
|
751
|
+
React15.useEffect(() => {
|
|
622
752
|
if (!onBillingChange) return;
|
|
623
753
|
onBillingChange({
|
|
624
754
|
firstName,
|
|
@@ -643,8 +773,22 @@ var CardDetailsForm = ({
|
|
|
643
773
|
mergedDefaults.provider,
|
|
644
774
|
onBillingChange
|
|
645
775
|
]);
|
|
646
|
-
|
|
647
|
-
|
|
776
|
+
const sanitizeCollectField = (field) => {
|
|
777
|
+
const sanitized = { ...field };
|
|
778
|
+
if ("style_input" in sanitized || "style_placeholder" in sanitized) {
|
|
779
|
+
delete sanitized.style_input;
|
|
780
|
+
delete sanitized.style_placeholder;
|
|
781
|
+
if (typeof window !== "undefined") {
|
|
782
|
+
console.warn(
|
|
783
|
+
"[payments-ui] stripping unsupported Collect.js style fields",
|
|
784
|
+
Object.keys(field).filter((key) => key.startsWith("style_"))
|
|
785
|
+
);
|
|
786
|
+
}
|
|
787
|
+
}
|
|
788
|
+
return sanitized;
|
|
789
|
+
};
|
|
790
|
+
React15.useEffect(() => {
|
|
791
|
+
if (!collectReady || typeof window === "undefined" || !window.CollectJS || !visible) {
|
|
648
792
|
return;
|
|
649
793
|
}
|
|
650
794
|
const handlers = window.__doujinsCollectHandlers || (window.__doujinsCollectHandlers = {});
|
|
@@ -671,10 +815,14 @@ var CardDetailsForm = ({
|
|
|
671
815
|
if (!configured[collectPrefix]) {
|
|
672
816
|
window.CollectJS.configure({
|
|
673
817
|
variant: "inline",
|
|
818
|
+
customCss: collectCssConfig.customCss,
|
|
819
|
+
focusCss: collectCssConfig.focusCss,
|
|
820
|
+
invalidCss: collectCssConfig.invalidCss,
|
|
821
|
+
placeholderCss: collectCssConfig.placeholderCss,
|
|
674
822
|
fields: {
|
|
675
|
-
ccnumber: { selector: buildSelector(collectPrefix, "ccnumber") },
|
|
676
|
-
ccexp: { selector: buildSelector(collectPrefix, "ccexp") },
|
|
677
|
-
cvv: { selector: buildSelector(collectPrefix, "cvv") }
|
|
823
|
+
ccnumber: sanitizeCollectField({ selector: buildSelector(collectPrefix, "ccnumber") }),
|
|
824
|
+
ccexp: sanitizeCollectField({ selector: buildSelector(collectPrefix, "ccexp") }),
|
|
825
|
+
cvv: sanitizeCollectField({ selector: buildSelector(collectPrefix, "cvv") })
|
|
678
826
|
},
|
|
679
827
|
callback: (response) => {
|
|
680
828
|
const fn = window.__doujinsCollectHandlers?.[collectPrefix];
|
|
@@ -685,6 +833,7 @@ var CardDetailsForm = ({
|
|
|
685
833
|
}
|
|
686
834
|
}, [
|
|
687
835
|
collectPrefix,
|
|
836
|
+
collectReady,
|
|
688
837
|
firstName,
|
|
689
838
|
lastName,
|
|
690
839
|
address1,
|
|
@@ -716,22 +865,22 @@ var CardDetailsForm = ({
|
|
|
716
865
|
window.CollectJS.startPaymentRequest();
|
|
717
866
|
};
|
|
718
867
|
const errorMessage = localError ?? externalError;
|
|
719
|
-
const collectFieldClass = "flex h-11 w-full items-center rounded-md border bg-
|
|
868
|
+
const collectFieldClass = "relative flex h-11 w-full items-center overflow-hidden rounded-md border border-border/60 bg-background/40 px-3 text-sm text-foreground";
|
|
720
869
|
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
721
870
|
"form",
|
|
722
871
|
{
|
|
723
|
-
className: cn("space-y-
|
|
872
|
+
className: cn("space-y-2", className),
|
|
724
873
|
onSubmit: handleSubmit,
|
|
725
874
|
noValidate: true,
|
|
726
875
|
children: [
|
|
727
876
|
errorMessage && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-red-500/40 bg-red-500/10 px-4 py-2 text-sm text-red-400", children: errorMessage }),
|
|
728
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-
|
|
877
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2 md:flex-row", children: [
|
|
729
878
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 space-y-2", children: [
|
|
730
|
-
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "
|
|
879
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "firstName", children: "First name" }),
|
|
731
880
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
732
881
|
Input,
|
|
733
882
|
{
|
|
734
|
-
id: "
|
|
883
|
+
id: "firstName",
|
|
735
884
|
value: firstName,
|
|
736
885
|
onChange: (e) => setFirstName(e.target.value),
|
|
737
886
|
required: true
|
|
@@ -739,11 +888,11 @@ var CardDetailsForm = ({
|
|
|
739
888
|
)
|
|
740
889
|
] }),
|
|
741
890
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex-1 space-y-2", children: [
|
|
742
|
-
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "
|
|
891
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "lastName", children: "Last name" }),
|
|
743
892
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
744
893
|
Input,
|
|
745
894
|
{
|
|
746
|
-
id: "
|
|
895
|
+
id: "lastName",
|
|
747
896
|
value: lastName,
|
|
748
897
|
onChange: (e) => setLastName(e.target.value),
|
|
749
898
|
required: true
|
|
@@ -752,11 +901,11 @@ var CardDetailsForm = ({
|
|
|
752
901
|
] })
|
|
753
902
|
] }),
|
|
754
903
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
755
|
-
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "
|
|
904
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "email", children: "Email" }),
|
|
756
905
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
757
906
|
Input,
|
|
758
907
|
{
|
|
759
|
-
id: "
|
|
908
|
+
id: "email",
|
|
760
909
|
type: "email",
|
|
761
910
|
value: email,
|
|
762
911
|
onChange: (e) => setEmail(e.target.value),
|
|
@@ -765,24 +914,24 @@ var CardDetailsForm = ({
|
|
|
765
914
|
)
|
|
766
915
|
] }),
|
|
767
916
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
768
|
-
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "
|
|
917
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "address1", children: "Address" }),
|
|
769
918
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
770
919
|
Input,
|
|
771
920
|
{
|
|
772
|
-
id: "
|
|
921
|
+
id: "address1",
|
|
773
922
|
value: address1,
|
|
774
923
|
onChange: (e) => setAddress1(e.target.value),
|
|
775
924
|
required: true
|
|
776
925
|
}
|
|
777
926
|
)
|
|
778
927
|
] }),
|
|
779
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-
|
|
928
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-2 md:grid-cols-2", children: [
|
|
780
929
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
781
|
-
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "
|
|
930
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "city", children: "City" }),
|
|
782
931
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
783
932
|
Input,
|
|
784
933
|
{
|
|
785
|
-
id: "
|
|
934
|
+
id: "city",
|
|
786
935
|
value: city,
|
|
787
936
|
onChange: (e) => setCity(e.target.value),
|
|
788
937
|
required: true
|
|
@@ -790,24 +939,24 @@ var CardDetailsForm = ({
|
|
|
790
939
|
)
|
|
791
940
|
] }),
|
|
792
941
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
793
|
-
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "
|
|
942
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "state", children: "State / Region" }),
|
|
794
943
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
795
944
|
Input,
|
|
796
945
|
{
|
|
797
|
-
id: "
|
|
946
|
+
id: "state",
|
|
798
947
|
value: stateRegion,
|
|
799
948
|
onChange: (e) => setStateRegion(e.target.value)
|
|
800
949
|
}
|
|
801
950
|
)
|
|
802
951
|
] })
|
|
803
952
|
] }),
|
|
804
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-
|
|
953
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-2 md:grid-cols-2", children: [
|
|
805
954
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
806
|
-
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "
|
|
955
|
+
/* @__PURE__ */ jsxRuntime.jsx(Label, { htmlFor: "postal", children: "Postal code" }),
|
|
807
956
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
808
957
|
Input,
|
|
809
958
|
{
|
|
810
|
-
id: "
|
|
959
|
+
id: "postal",
|
|
811
960
|
value: postalCode,
|
|
812
961
|
onChange: (e) => setPostalCode(e.target.value),
|
|
813
962
|
required: true
|
|
@@ -826,7 +975,7 @@ var CardDetailsForm = ({
|
|
|
826
975
|
/* @__PURE__ */ jsxRuntime.jsx(Label, { children: "Card number" }),
|
|
827
976
|
/* @__PURE__ */ jsxRuntime.jsx("div", { id: buildSelector(collectPrefix, "ccnumber").slice(1), className: collectFieldClass })
|
|
828
977
|
] }),
|
|
829
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-
|
|
978
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-2 md:grid-cols-2", children: [
|
|
830
979
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-2", children: [
|
|
831
980
|
/* @__PURE__ */ jsxRuntime.jsx(Label, { children: "Expiry" }),
|
|
832
981
|
/* @__PURE__ */ jsxRuntime.jsx("div", { id: buildSelector(collectPrefix, "ccexp").slice(1), className: collectFieldClass })
|
|
@@ -924,7 +1073,7 @@ var badgeVariants = classVarianceAuthority.cva(
|
|
|
924
1073
|
function Badge({ className, variant, ...props }) {
|
|
925
1074
|
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: cn(badgeVariants({ variant }), className), ...props });
|
|
926
1075
|
}
|
|
927
|
-
var ScrollArea =
|
|
1076
|
+
var ScrollArea = React15__namespace.forwardRef(({ className, children, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
928
1077
|
ScrollAreaPrimitive__namespace.Root,
|
|
929
1078
|
{
|
|
930
1079
|
ref,
|
|
@@ -938,7 +1087,7 @@ var ScrollArea = React17__namespace.forwardRef(({ className, children, ...props
|
|
|
938
1087
|
}
|
|
939
1088
|
));
|
|
940
1089
|
ScrollArea.displayName = ScrollAreaPrimitive__namespace.Root.displayName;
|
|
941
|
-
var ScrollBar =
|
|
1090
|
+
var ScrollBar = React15__namespace.forwardRef(({ className, orientation = "vertical", ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
942
1091
|
ScrollAreaPrimitive__namespace.ScrollAreaScrollbar,
|
|
943
1092
|
{
|
|
944
1093
|
ref,
|
|
@@ -961,123 +1110,119 @@ var formatCardLabel = (method) => {
|
|
|
961
1110
|
};
|
|
962
1111
|
var StoredPaymentMethods = ({
|
|
963
1112
|
selectedMethodId,
|
|
964
|
-
onMethodSelect
|
|
965
|
-
showAddButton = true
|
|
1113
|
+
onMethodSelect
|
|
966
1114
|
}) => {
|
|
967
|
-
const
|
|
968
|
-
const
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
className:
|
|
985
|
-
|
|
986
|
-
{
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
] })
|
|
1005
|
-
]
|
|
1006
|
-
},
|
|
1007
|
-
method.id
|
|
1008
|
-
);
|
|
1009
|
-
}) }) }),
|
|
1010
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isModalOpen, onOpenChange: setIsModalOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "max-h-[85vh] overflow-y-auto", children: [
|
|
1011
|
-
/* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { children: [
|
|
1012
|
-
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Add a new card" }),
|
|
1013
|
-
/* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { children: "Your card details are tokenized securely via our payment provider." })
|
|
1014
|
-
] }),
|
|
1015
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1016
|
-
CardDetailsForm,
|
|
1017
|
-
{
|
|
1018
|
-
visible: isModalOpen,
|
|
1019
|
-
collectPrefix: "payments-ui-card",
|
|
1020
|
-
submitting: createMutation.isPending,
|
|
1021
|
-
submitLabel: "Save card",
|
|
1022
|
-
externalError: createMutation.error?.message ?? null,
|
|
1023
|
-
onTokenize: handleCardTokenize
|
|
1024
|
-
}
|
|
1025
|
-
)
|
|
1026
|
-
] }) })
|
|
1027
|
-
] });
|
|
1115
|
+
const { listQuery } = usePaymentMethods();
|
|
1116
|
+
const payments = React15.useMemo(() => listQuery.data?.data ?? [], [listQuery.data]);
|
|
1117
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: listQuery.isLoading ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-center py-4 text-sm text-muted-foreground", children: [
|
|
1118
|
+
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }),
|
|
1119
|
+
" Loading cards..."
|
|
1120
|
+
] }) : payments.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4 text-center text-sm text-muted-foreground", children: "No saved payment methods yet." }) : /* @__PURE__ */ jsxRuntime.jsx(ScrollArea, { className: "max-h-[320px] pr-2", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-3", children: payments.map((method) => {
|
|
1121
|
+
const isSelected = selectedMethodId === method.id;
|
|
1122
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1123
|
+
"div",
|
|
1124
|
+
{
|
|
1125
|
+
className: cn(
|
|
1126
|
+
"flex border border-border rounded-md px-4 py-3 flex-row items-center justify-between",
|
|
1127
|
+
{
|
|
1128
|
+
"bg-muted/20": isSelected
|
|
1129
|
+
}
|
|
1130
|
+
),
|
|
1131
|
+
children: [
|
|
1132
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-semibold text-foreground", children: formatCardLabel(method) }),
|
|
1133
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-2", children: [
|
|
1134
|
+
method.failure_reason && /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "destructive", children: method.failure_reason }),
|
|
1135
|
+
onMethodSelect && /* @__PURE__ */ jsxRuntime.jsx(
|
|
1136
|
+
Button,
|
|
1137
|
+
{
|
|
1138
|
+
size: "sm",
|
|
1139
|
+
variant: "ghost",
|
|
1140
|
+
disabled: isSelected,
|
|
1141
|
+
onClick: () => onMethodSelect(method),
|
|
1142
|
+
className: clsx2__default.default("px-3", { "bg-muted/90": !isSelected, "bg-inherit": isSelected }),
|
|
1143
|
+
children: isSelected ? "Selected" : "Use card"
|
|
1144
|
+
}
|
|
1145
|
+
)
|
|
1146
|
+
] })
|
|
1147
|
+
]
|
|
1148
|
+
},
|
|
1149
|
+
method.id
|
|
1150
|
+
);
|
|
1151
|
+
}) }) }) });
|
|
1028
1152
|
};
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
)
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1153
|
+
function Tabs({
|
|
1154
|
+
className,
|
|
1155
|
+
...props
|
|
1156
|
+
}) {
|
|
1157
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1158
|
+
TabsPrimitive__namespace.Root,
|
|
1159
|
+
{
|
|
1160
|
+
"data-slot": "tabs",
|
|
1161
|
+
className: cn("flex flex-col gap-2", className),
|
|
1162
|
+
...props
|
|
1163
|
+
}
|
|
1164
|
+
);
|
|
1165
|
+
}
|
|
1166
|
+
function TabsList({
|
|
1167
|
+
className,
|
|
1168
|
+
...props
|
|
1169
|
+
}) {
|
|
1170
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1171
|
+
TabsPrimitive__namespace.List,
|
|
1172
|
+
{
|
|
1173
|
+
"data-slot": "tabs-list",
|
|
1174
|
+
className: cn(
|
|
1175
|
+
"bg-muted text-muted-foreground inline-flex h-9 w-fit items-center justify-center rounded-lg p-[3px]",
|
|
1176
|
+
className
|
|
1177
|
+
),
|
|
1178
|
+
...props
|
|
1179
|
+
}
|
|
1180
|
+
);
|
|
1181
|
+
}
|
|
1182
|
+
function TabsTrigger({
|
|
1183
|
+
className,
|
|
1184
|
+
...props
|
|
1185
|
+
}) {
|
|
1186
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1187
|
+
TabsPrimitive__namespace.Trigger,
|
|
1188
|
+
{
|
|
1189
|
+
"data-slot": "tabs-trigger",
|
|
1190
|
+
className: cn(
|
|
1191
|
+
"data-[state=active]:bg-background dark:data-[state=active]:text-foreground focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:outline-ring dark:data-[state=active]:border-input dark:data-[state=active]:bg-input/30 text-foreground dark:text-muted-foreground inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-2 py-1 text-sm font-medium whitespace-nowrap transition-[color,box-shadow] focus-visible:ring-[3px] focus-visible:outline-1 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:shadow-sm [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
1192
|
+
className
|
|
1193
|
+
),
|
|
1194
|
+
...props
|
|
1195
|
+
}
|
|
1196
|
+
);
|
|
1197
|
+
}
|
|
1198
|
+
function TabsContent({
|
|
1199
|
+
className,
|
|
1200
|
+
...props
|
|
1201
|
+
}) {
|
|
1202
|
+
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
1203
|
+
TabsPrimitive__namespace.Content,
|
|
1204
|
+
{
|
|
1205
|
+
"data-slot": "tabs-content",
|
|
1206
|
+
className: cn("flex-1 outline-none", className),
|
|
1207
|
+
...props
|
|
1208
|
+
}
|
|
1209
|
+
);
|
|
1210
|
+
}
|
|
1066
1211
|
var usePaymentNotifications = () => {
|
|
1067
1212
|
const { config } = usePaymentContext();
|
|
1068
|
-
const notifyStatus =
|
|
1213
|
+
const notifyStatus = React15.useCallback(
|
|
1069
1214
|
(status, context) => {
|
|
1070
1215
|
config.callbacks?.onStatusChange?.({ status, context });
|
|
1071
1216
|
},
|
|
1072
1217
|
[config.callbacks]
|
|
1073
1218
|
);
|
|
1074
|
-
const notifySuccess =
|
|
1219
|
+
const notifySuccess = React15.useCallback(
|
|
1075
1220
|
(payload) => {
|
|
1076
1221
|
config.callbacks?.onSuccess?.(payload ?? {});
|
|
1077
1222
|
},
|
|
1078
1223
|
[config.callbacks]
|
|
1079
1224
|
);
|
|
1080
|
-
const notifyError =
|
|
1225
|
+
const notifyError = React15.useCallback(
|
|
1081
1226
|
(error) => {
|
|
1082
1227
|
config.callbacks?.onError?.(
|
|
1083
1228
|
typeof error === "string" ? new Error(error) : error
|
|
@@ -1095,17 +1240,17 @@ var useSolanaQrPayment = (options) => {
|
|
|
1095
1240
|
const { priceId, selectedToken, onSuccess, onError } = options;
|
|
1096
1241
|
const { client } = usePaymentContext();
|
|
1097
1242
|
const tokenSymbol = selectedToken?.symbol ?? null;
|
|
1098
|
-
const onSuccessRef =
|
|
1099
|
-
const onErrorRef =
|
|
1100
|
-
const [intent, setIntent] =
|
|
1101
|
-
const [qrDataUri, setQrDataUri] =
|
|
1102
|
-
const [isLoading, setIsLoading] =
|
|
1103
|
-
const [error, setError] =
|
|
1104
|
-
const [timeRemaining, setTimeRemaining] =
|
|
1105
|
-
const [refreshNonce, setRefreshNonce] =
|
|
1106
|
-
const pollRef =
|
|
1107
|
-
const countdownRef =
|
|
1108
|
-
const clearTimers =
|
|
1243
|
+
const onSuccessRef = React15.useRef(onSuccess);
|
|
1244
|
+
const onErrorRef = React15.useRef(onError);
|
|
1245
|
+
const [intent, setIntent] = React15.useState(null);
|
|
1246
|
+
const [qrDataUri, setQrDataUri] = React15.useState(null);
|
|
1247
|
+
const [isLoading, setIsLoading] = React15.useState(false);
|
|
1248
|
+
const [error, setError] = React15.useState(null);
|
|
1249
|
+
const [timeRemaining, setTimeRemaining] = React15.useState(0);
|
|
1250
|
+
const [refreshNonce, setRefreshNonce] = React15.useState(0);
|
|
1251
|
+
const pollRef = React15.useRef(null);
|
|
1252
|
+
const countdownRef = React15.useRef(null);
|
|
1253
|
+
const clearTimers = React15.useCallback(() => {
|
|
1109
1254
|
if (pollRef.current) {
|
|
1110
1255
|
clearInterval(pollRef.current);
|
|
1111
1256
|
pollRef.current = null;
|
|
@@ -1115,12 +1260,12 @@ var useSolanaQrPayment = (options) => {
|
|
|
1115
1260
|
countdownRef.current = null;
|
|
1116
1261
|
}
|
|
1117
1262
|
}, []);
|
|
1118
|
-
|
|
1263
|
+
React15.useEffect(() => {
|
|
1119
1264
|
return () => {
|
|
1120
1265
|
clearTimers();
|
|
1121
1266
|
};
|
|
1122
1267
|
}, [clearTimers]);
|
|
1123
|
-
const resetState =
|
|
1268
|
+
const resetState = React15.useCallback(
|
|
1124
1269
|
(message) => {
|
|
1125
1270
|
clearTimers();
|
|
1126
1271
|
setIntent(null);
|
|
@@ -1130,13 +1275,13 @@ var useSolanaQrPayment = (options) => {
|
|
|
1130
1275
|
},
|
|
1131
1276
|
[clearTimers]
|
|
1132
1277
|
);
|
|
1133
|
-
|
|
1278
|
+
React15.useEffect(() => {
|
|
1134
1279
|
onSuccessRef.current = onSuccess;
|
|
1135
1280
|
}, [onSuccess]);
|
|
1136
|
-
|
|
1281
|
+
React15.useEffect(() => {
|
|
1137
1282
|
onErrorRef.current = onError;
|
|
1138
1283
|
}, [onError]);
|
|
1139
|
-
const handleError =
|
|
1284
|
+
const handleError = React15.useCallback(
|
|
1140
1285
|
(message, notifyParent = false) => {
|
|
1141
1286
|
console.error("[payments-ui] Solana Pay QR error:", message);
|
|
1142
1287
|
clearTimers();
|
|
@@ -1147,7 +1292,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1147
1292
|
},
|
|
1148
1293
|
[clearTimers, resetState]
|
|
1149
1294
|
);
|
|
1150
|
-
const handleSuccess =
|
|
1295
|
+
const handleSuccess = React15.useCallback(
|
|
1151
1296
|
(status) => {
|
|
1152
1297
|
clearTimers();
|
|
1153
1298
|
resetState(null);
|
|
@@ -1161,7 +1306,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1161
1306
|
},
|
|
1162
1307
|
[clearTimers, resetState]
|
|
1163
1308
|
);
|
|
1164
|
-
const pollStatus =
|
|
1309
|
+
const pollStatus = React15.useCallback(
|
|
1165
1310
|
async (reference) => {
|
|
1166
1311
|
try {
|
|
1167
1312
|
const status = await client.getSolanaPayStatus(reference);
|
|
@@ -1180,7 +1325,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1180
1325
|
},
|
|
1181
1326
|
[handleError, handleSuccess, client]
|
|
1182
1327
|
);
|
|
1183
|
-
const startCountdown =
|
|
1328
|
+
const startCountdown = React15.useCallback(
|
|
1184
1329
|
(expiresAt, reference) => {
|
|
1185
1330
|
const updateTime = () => {
|
|
1186
1331
|
const remaining = Math.max(0, Math.floor(expiresAt - Date.now() / 1e3));
|
|
@@ -1195,7 +1340,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1195
1340
|
},
|
|
1196
1341
|
[handleError, pollStatus]
|
|
1197
1342
|
);
|
|
1198
|
-
const renderQr =
|
|
1343
|
+
const renderQr = React15.useCallback(async (qrIntent) => {
|
|
1199
1344
|
try {
|
|
1200
1345
|
const dataUri = await QRCode__default.default.toDataURL(qrIntent.url, {
|
|
1201
1346
|
width: 320,
|
|
@@ -1211,7 +1356,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1211
1356
|
handleError("Unable to render QR code");
|
|
1212
1357
|
}
|
|
1213
1358
|
}, [handleError]);
|
|
1214
|
-
|
|
1359
|
+
React15.useEffect(() => {
|
|
1215
1360
|
let cancelled = false;
|
|
1216
1361
|
const generateIntent = async () => {
|
|
1217
1362
|
clearTimers();
|
|
@@ -1275,7 +1420,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1275
1420
|
tokenSymbol,
|
|
1276
1421
|
refreshNonce
|
|
1277
1422
|
]);
|
|
1278
|
-
const refresh =
|
|
1423
|
+
const refresh = React15.useCallback(() => {
|
|
1279
1424
|
setRefreshNonce((value) => value + 1);
|
|
1280
1425
|
}, []);
|
|
1281
1426
|
return {
|
|
@@ -1287,7 +1432,7 @@ var useSolanaQrPayment = (options) => {
|
|
|
1287
1432
|
refresh
|
|
1288
1433
|
};
|
|
1289
1434
|
};
|
|
1290
|
-
var Card =
|
|
1435
|
+
var Card = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1291
1436
|
"div",
|
|
1292
1437
|
{
|
|
1293
1438
|
ref,
|
|
@@ -1299,7 +1444,7 @@ var Card = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @_
|
|
|
1299
1444
|
}
|
|
1300
1445
|
));
|
|
1301
1446
|
Card.displayName = "Card";
|
|
1302
|
-
var CardHeader =
|
|
1447
|
+
var CardHeader = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1303
1448
|
"div",
|
|
1304
1449
|
{
|
|
1305
1450
|
ref,
|
|
@@ -1308,7 +1453,7 @@ var CardHeader = React17__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1308
1453
|
}
|
|
1309
1454
|
));
|
|
1310
1455
|
CardHeader.displayName = "CardHeader";
|
|
1311
|
-
var CardTitle =
|
|
1456
|
+
var CardTitle = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1312
1457
|
"div",
|
|
1313
1458
|
{
|
|
1314
1459
|
ref,
|
|
@@ -1320,7 +1465,7 @@ var CardTitle = React17__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
1320
1465
|
}
|
|
1321
1466
|
));
|
|
1322
1467
|
CardTitle.displayName = "CardTitle";
|
|
1323
|
-
var CardDescription =
|
|
1468
|
+
var CardDescription = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1324
1469
|
"div",
|
|
1325
1470
|
{
|
|
1326
1471
|
ref,
|
|
@@ -1329,9 +1474,9 @@ var CardDescription = React17__namespace.forwardRef(({ className, ...props }, re
|
|
|
1329
1474
|
}
|
|
1330
1475
|
));
|
|
1331
1476
|
CardDescription.displayName = "CardDescription";
|
|
1332
|
-
var CardContent =
|
|
1477
|
+
var CardContent = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { ref, className: cn("p-6 pt-0", className), ...props }));
|
|
1333
1478
|
CardContent.displayName = "CardContent";
|
|
1334
|
-
var CardFooter =
|
|
1479
|
+
var CardFooter = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
1335
1480
|
"div",
|
|
1336
1481
|
{
|
|
1337
1482
|
ref,
|
|
@@ -1346,7 +1491,7 @@ var QRCodePayment = ({
|
|
|
1346
1491
|
onPaymentError,
|
|
1347
1492
|
onPaymentSuccess
|
|
1348
1493
|
}) => {
|
|
1349
|
-
const handleQrSuccess =
|
|
1494
|
+
const handleQrSuccess = React15__namespace.default.useCallback(
|
|
1350
1495
|
(paymentId, txId) => {
|
|
1351
1496
|
if (!paymentId && !txId) {
|
|
1352
1497
|
onPaymentError("Missing payment confirmation details");
|
|
@@ -1455,16 +1600,16 @@ var PaymentStatus = ({
|
|
|
1455
1600
|
};
|
|
1456
1601
|
var useSupportedTokens = () => {
|
|
1457
1602
|
const { client } = usePaymentContext();
|
|
1458
|
-
const [tokens, setTokens] =
|
|
1459
|
-
const [isLoading, setIsLoading] =
|
|
1460
|
-
const [error, setError] =
|
|
1461
|
-
const [lastFetched, setLastFetched] =
|
|
1603
|
+
const [tokens, setTokens] = React15.useState([]);
|
|
1604
|
+
const [isLoading, setIsLoading] = React15.useState(false);
|
|
1605
|
+
const [error, setError] = React15.useState(null);
|
|
1606
|
+
const [lastFetched, setLastFetched] = React15.useState(null);
|
|
1462
1607
|
const CACHE_DURATION = 5 * 60 * 1e3;
|
|
1463
|
-
const tokensRef =
|
|
1464
|
-
const lastFetchedRef =
|
|
1608
|
+
const tokensRef = React15.useRef(tokens);
|
|
1609
|
+
const lastFetchedRef = React15.useRef(lastFetched);
|
|
1465
1610
|
tokensRef.current = tokens;
|
|
1466
1611
|
lastFetchedRef.current = lastFetched;
|
|
1467
|
-
const fetchSupportedTokens =
|
|
1612
|
+
const fetchSupportedTokens = React15.useCallback(async () => {
|
|
1468
1613
|
if (tokensRef.current.length > 0 && lastFetchedRef.current && Date.now() - lastFetchedRef.current < CACHE_DURATION) {
|
|
1469
1614
|
return tokensRef.current;
|
|
1470
1615
|
}
|
|
@@ -1491,50 +1636,50 @@ var useSupportedTokens = () => {
|
|
|
1491
1636
|
setIsLoading(false);
|
|
1492
1637
|
}
|
|
1493
1638
|
}, [client]);
|
|
1494
|
-
|
|
1639
|
+
React15.useEffect(() => {
|
|
1495
1640
|
if (tokens.length === 0) {
|
|
1496
1641
|
fetchSupportedTokens();
|
|
1497
1642
|
}
|
|
1498
1643
|
}, [tokens.length, fetchSupportedTokens]);
|
|
1499
|
-
const getTokenBySymbol =
|
|
1644
|
+
const getTokenBySymbol = React15.useCallback(
|
|
1500
1645
|
(symbol) => {
|
|
1501
1646
|
return tokens.find((token) => token.symbol === symbol);
|
|
1502
1647
|
},
|
|
1503
1648
|
[tokens]
|
|
1504
1649
|
);
|
|
1505
|
-
const getTokenByMint =
|
|
1650
|
+
const getTokenByMint = React15.useCallback(
|
|
1506
1651
|
(mintAddress) => {
|
|
1507
1652
|
return tokens.find((token) => token.mint === mintAddress);
|
|
1508
1653
|
},
|
|
1509
1654
|
[tokens]
|
|
1510
1655
|
);
|
|
1511
|
-
const isTokenSupported =
|
|
1656
|
+
const isTokenSupported = React15.useCallback(
|
|
1512
1657
|
(symbol) => {
|
|
1513
1658
|
return tokens.some((token) => token.symbol === symbol);
|
|
1514
1659
|
},
|
|
1515
1660
|
[tokens]
|
|
1516
1661
|
);
|
|
1517
|
-
const getUSDCToken =
|
|
1662
|
+
const getUSDCToken = React15.useCallback(() => {
|
|
1518
1663
|
return getTokenBySymbol("USDC");
|
|
1519
1664
|
}, [getTokenBySymbol]);
|
|
1520
|
-
const getPYUSDToken =
|
|
1665
|
+
const getPYUSDToken = React15.useCallback(() => {
|
|
1521
1666
|
return getTokenBySymbol("PYUSD");
|
|
1522
1667
|
}, [getTokenBySymbol]);
|
|
1523
|
-
const getSOLToken =
|
|
1668
|
+
const getSOLToken = React15.useCallback(() => {
|
|
1524
1669
|
return getTokenBySymbol("SOL");
|
|
1525
1670
|
}, [getTokenBySymbol]);
|
|
1526
|
-
const getStablecoins =
|
|
1671
|
+
const getStablecoins = React15.useCallback(() => {
|
|
1527
1672
|
return tokens.filter((token) => ["USDC", "PYUSD"].includes(token.symbol));
|
|
1528
1673
|
}, [tokens]);
|
|
1529
|
-
const refreshTokens =
|
|
1674
|
+
const refreshTokens = React15.useCallback(async () => {
|
|
1530
1675
|
setLastFetched(null);
|
|
1531
1676
|
return await fetchSupportedTokens();
|
|
1532
1677
|
}, [fetchSupportedTokens]);
|
|
1533
|
-
const isCacheStale =
|
|
1678
|
+
const isCacheStale = React15.useCallback(() => {
|
|
1534
1679
|
if (!lastFetched) return true;
|
|
1535
1680
|
return Date.now() - lastFetched > CACHE_DURATION;
|
|
1536
1681
|
}, [lastFetched]);
|
|
1537
|
-
const getTokenDisplayInfo =
|
|
1682
|
+
const getTokenDisplayInfo = React15.useCallback((token) => {
|
|
1538
1683
|
return {
|
|
1539
1684
|
...token,
|
|
1540
1685
|
displayName: `${token.name} (${token.symbol})`,
|
|
@@ -1542,7 +1687,7 @@ var useSupportedTokens = () => {
|
|
|
1542
1687
|
decimalPlaces: token.decimals
|
|
1543
1688
|
};
|
|
1544
1689
|
}, []);
|
|
1545
|
-
const getTokenPrice =
|
|
1690
|
+
const getTokenPrice = React15.useCallback(
|
|
1546
1691
|
(symbol) => {
|
|
1547
1692
|
const token = getTokenBySymbol(symbol);
|
|
1548
1693
|
if (!token) return 0;
|
|
@@ -1551,7 +1696,7 @@ var useSupportedTokens = () => {
|
|
|
1551
1696
|
},
|
|
1552
1697
|
[getTokenBySymbol]
|
|
1553
1698
|
);
|
|
1554
|
-
const calculateTokenAmount =
|
|
1699
|
+
const calculateTokenAmount = React15.useCallback(
|
|
1555
1700
|
(usdAmount, tokenSymbol) => {
|
|
1556
1701
|
const token = getTokenBySymbol(tokenSymbol);
|
|
1557
1702
|
const price = getTokenPrice(tokenSymbol);
|
|
@@ -1562,7 +1707,7 @@ var useSupportedTokens = () => {
|
|
|
1562
1707
|
},
|
|
1563
1708
|
[getTokenBySymbol, getTokenPrice]
|
|
1564
1709
|
);
|
|
1565
|
-
const formatTokenAmount =
|
|
1710
|
+
const formatTokenAmount = React15.useCallback(
|
|
1566
1711
|
(amount, tokenSymbol) => {
|
|
1567
1712
|
const token = getTokenBySymbol(tokenSymbol);
|
|
1568
1713
|
if (!token) return "0";
|
|
@@ -1603,28 +1748,28 @@ var SolanaPaymentView = ({
|
|
|
1603
1748
|
onClose
|
|
1604
1749
|
}) => {
|
|
1605
1750
|
const { notifyStatus, notifyError, notifySuccess } = usePaymentNotifications();
|
|
1606
|
-
const [paymentState, setPaymentState] =
|
|
1607
|
-
const [errorMessage, setErrorMessage] =
|
|
1608
|
-
const [transactionId, setTransactionId] =
|
|
1609
|
-
const [tokenAmount, setTokenAmount] =
|
|
1610
|
-
const [selectedTokenSymbol, setSelectedTokenSymbol] =
|
|
1751
|
+
const [paymentState, setPaymentState] = React15.useState("selecting");
|
|
1752
|
+
const [errorMessage, setErrorMessage] = React15.useState(null);
|
|
1753
|
+
const [transactionId, setTransactionId] = React15.useState(null);
|
|
1754
|
+
const [tokenAmount, setTokenAmount] = React15.useState(0);
|
|
1755
|
+
const [selectedTokenSymbol, setSelectedTokenSymbol] = React15.useState(null);
|
|
1611
1756
|
const {
|
|
1612
1757
|
tokens,
|
|
1613
1758
|
isLoading: tokensLoading,
|
|
1614
1759
|
error: tokensError
|
|
1615
1760
|
} = useSupportedTokens();
|
|
1616
|
-
const selectedToken =
|
|
1761
|
+
const selectedToken = React15.useMemo(() => {
|
|
1617
1762
|
if (!tokens.length) return null;
|
|
1618
1763
|
const explicit = tokens.find((token) => token.symbol === selectedTokenSymbol);
|
|
1619
1764
|
return explicit || tokens[0];
|
|
1620
1765
|
}, [tokens, selectedTokenSymbol]);
|
|
1621
|
-
|
|
1766
|
+
React15.useEffect(() => {
|
|
1622
1767
|
if (!selectedTokenSymbol && tokens.length) {
|
|
1623
1768
|
const defaultToken = tokens.find((token) => token.symbol === "SOL") || tokens[0];
|
|
1624
1769
|
setSelectedTokenSymbol(defaultToken.symbol);
|
|
1625
1770
|
}
|
|
1626
1771
|
}, [tokens, selectedTokenSymbol]);
|
|
1627
|
-
const handlePaymentSuccess =
|
|
1772
|
+
const handlePaymentSuccess = React15.useCallback(
|
|
1628
1773
|
(result, txId) => {
|
|
1629
1774
|
const resolvedTx = txId || (typeof result === "string" ? result : result.transaction_id);
|
|
1630
1775
|
setTransactionId(resolvedTx);
|
|
@@ -1652,7 +1797,7 @@ var SolanaPaymentView = ({
|
|
|
1652
1797
|
},
|
|
1653
1798
|
[notifyStatus, notifySuccess, onSuccess]
|
|
1654
1799
|
);
|
|
1655
|
-
const handlePaymentError =
|
|
1800
|
+
const handlePaymentError = React15.useCallback(
|
|
1656
1801
|
(error) => {
|
|
1657
1802
|
setPaymentState("error");
|
|
1658
1803
|
setErrorMessage(error);
|
|
@@ -1662,22 +1807,22 @@ var SolanaPaymentView = ({
|
|
|
1662
1807
|
},
|
|
1663
1808
|
[notifyError, notifyStatus, onError]
|
|
1664
1809
|
);
|
|
1665
|
-
const resetState =
|
|
1810
|
+
const resetState = React15.useCallback(() => {
|
|
1666
1811
|
setPaymentState("selecting");
|
|
1667
1812
|
setErrorMessage(null);
|
|
1668
1813
|
setTransactionId(null);
|
|
1669
1814
|
}, []);
|
|
1670
|
-
const handleRetry =
|
|
1815
|
+
const handleRetry = React15.useCallback(() => {
|
|
1671
1816
|
resetState();
|
|
1672
1817
|
}, [resetState]);
|
|
1673
|
-
const handleClose =
|
|
1818
|
+
const handleClose = React15.useCallback(() => {
|
|
1674
1819
|
if (paymentState === "processing" || paymentState === "confirming") {
|
|
1675
1820
|
return;
|
|
1676
1821
|
}
|
|
1677
1822
|
resetState();
|
|
1678
1823
|
onClose?.();
|
|
1679
1824
|
}, [paymentState, onClose, resetState]);
|
|
1680
|
-
|
|
1825
|
+
React15.useEffect(() => {
|
|
1681
1826
|
if (!selectedToken || usdAmount === 0) {
|
|
1682
1827
|
setTokenAmount(0);
|
|
1683
1828
|
return;
|
|
@@ -1689,7 +1834,7 @@ var SolanaPaymentView = ({
|
|
|
1689
1834
|
}
|
|
1690
1835
|
setTokenAmount(usdAmount / price);
|
|
1691
1836
|
}, [usdAmount, selectedToken]);
|
|
1692
|
-
const handleTokenChange =
|
|
1837
|
+
const handleTokenChange = React15.useCallback((value) => {
|
|
1693
1838
|
setSelectedTokenSymbol(value);
|
|
1694
1839
|
}, []);
|
|
1695
1840
|
const renderBody = () => {
|
|
@@ -1795,20 +1940,20 @@ var PaymentExperience = ({
|
|
|
1795
1940
|
const showNewCard = enableNewCard && Boolean(onNewCardPayment);
|
|
1796
1941
|
const showStored = enableStoredMethods && Boolean(onSavedMethodPayment);
|
|
1797
1942
|
const defaultTab = showStored ? "saved" : "new";
|
|
1798
|
-
const [activeTab, setActiveTab] =
|
|
1799
|
-
const [mode, setMode] =
|
|
1943
|
+
const [activeTab, setActiveTab] = React15.useState(defaultTab);
|
|
1944
|
+
const [mode, setMode] = React15.useState(
|
|
1800
1945
|
() => initialMode === "solana" && enableSolanaPay ? "solana" : "cards"
|
|
1801
1946
|
);
|
|
1802
|
-
const [selectedMethodId, setSelectedMethodId] =
|
|
1803
|
-
const [savedStatus, setSavedStatus] =
|
|
1804
|
-
const [savedError, setSavedError] =
|
|
1805
|
-
const [newCardStatus, setNewCardStatus] =
|
|
1806
|
-
const [newCardError, setNewCardError] =
|
|
1947
|
+
const [selectedMethodId, setSelectedMethodId] = React15.useState(null);
|
|
1948
|
+
const [savedStatus, setSavedStatus] = React15.useState("idle");
|
|
1949
|
+
const [savedError, setSavedError] = React15.useState(null);
|
|
1950
|
+
const [newCardStatus, setNewCardStatus] = React15.useState("idle");
|
|
1951
|
+
const [newCardError, setNewCardError] = React15.useState(null);
|
|
1807
1952
|
const { notifyStatus, notifyError } = usePaymentNotifications();
|
|
1808
|
-
|
|
1953
|
+
React15.useEffect(() => {
|
|
1809
1954
|
setActiveTab(showStored ? "saved" : "new");
|
|
1810
1955
|
}, [showStored]);
|
|
1811
|
-
|
|
1956
|
+
React15.useEffect(() => {
|
|
1812
1957
|
if (!enableSolanaPay) {
|
|
1813
1958
|
setMode("cards");
|
|
1814
1959
|
return;
|
|
@@ -1819,12 +1964,12 @@ var PaymentExperience = ({
|
|
|
1819
1964
|
setMode("cards");
|
|
1820
1965
|
}
|
|
1821
1966
|
}, [enableSolanaPay, initialMode]);
|
|
1822
|
-
const handleMethodSelect =
|
|
1967
|
+
const handleMethodSelect = React15.useCallback((method) => {
|
|
1823
1968
|
setSelectedMethodId(method.id);
|
|
1824
1969
|
setSavedStatus("idle");
|
|
1825
1970
|
setSavedError(null);
|
|
1826
1971
|
}, []);
|
|
1827
|
-
const handleSavedPayment =
|
|
1972
|
+
const handleSavedPayment = React15.useCallback(async () => {
|
|
1828
1973
|
if (!onSavedMethodPayment || !selectedMethodId) return;
|
|
1829
1974
|
try {
|
|
1830
1975
|
setSavedStatus("processing");
|
|
@@ -1844,7 +1989,7 @@ var PaymentExperience = ({
|
|
|
1844
1989
|
notifyError(message);
|
|
1845
1990
|
}
|
|
1846
1991
|
}, [notifyError, notifyStatus, onSavedMethodPayment, selectedMethodId, usdAmount]);
|
|
1847
|
-
const handleNewCardTokenize =
|
|
1992
|
+
const handleNewCardTokenize = React15.useCallback(
|
|
1848
1993
|
async (token, billing) => {
|
|
1849
1994
|
if (!onNewCardPayment) return;
|
|
1850
1995
|
try {
|
|
@@ -1864,21 +2009,21 @@ var PaymentExperience = ({
|
|
|
1864
2009
|
},
|
|
1865
2010
|
[notifyError, notifyStatus, onNewCardPayment]
|
|
1866
2011
|
);
|
|
1867
|
-
|
|
2012
|
+
React15.useCallback(() => {
|
|
1868
2013
|
if (!enableSolanaPay) return;
|
|
1869
2014
|
setMode("solana");
|
|
1870
2015
|
}, [enableSolanaPay]);
|
|
1871
|
-
const exitSolanaView =
|
|
2016
|
+
const exitSolanaView = React15.useCallback(() => {
|
|
1872
2017
|
setMode("cards");
|
|
1873
2018
|
}, []);
|
|
1874
|
-
const handleSolanaSuccess =
|
|
2019
|
+
const handleSolanaSuccess = React15.useCallback(
|
|
1875
2020
|
(result) => {
|
|
1876
2021
|
onSolanaSuccess?.(result);
|
|
1877
2022
|
exitSolanaView();
|
|
1878
2023
|
},
|
|
1879
2024
|
[exitSolanaView, onSolanaSuccess]
|
|
1880
2025
|
);
|
|
1881
|
-
const handleSolanaError =
|
|
2026
|
+
const handleSolanaError = React15.useCallback(
|
|
1882
2027
|
(error) => {
|
|
1883
2028
|
onSolanaError?.(error);
|
|
1884
2029
|
},
|
|
@@ -1892,7 +2037,6 @@ var PaymentExperience = ({
|
|
|
1892
2037
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1893
2038
|
StoredPaymentMethods,
|
|
1894
2039
|
{
|
|
1895
|
-
showAddButton: false,
|
|
1896
2040
|
selectedMethodId,
|
|
1897
2041
|
onMethodSelect: handleMethodSelect
|
|
1898
2042
|
}
|
|
@@ -1924,21 +2068,14 @@ var PaymentExperience = ({
|
|
|
1924
2068
|
}
|
|
1925
2069
|
);
|
|
1926
2070
|
};
|
|
1927
|
-
const renderCardExperience = () => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1928
|
-
|
|
1929
|
-
|
|
1930
|
-
|
|
1931
|
-
|
|
1932
|
-
|
|
1933
|
-
|
|
1934
|
-
|
|
1935
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { value: "new", disabled: !showNewCard, children: "Add new card" })
|
|
1936
|
-
] }),
|
|
1937
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "saved", children: renderSavedTab() }),
|
|
1938
|
-
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "new", children: renderNewTab() })
|
|
1939
|
-
]
|
|
1940
|
-
}
|
|
1941
|
-
);
|
|
2071
|
+
const renderCardExperience = () => /* @__PURE__ */ jsxRuntime.jsxs(Tabs, { value: activeTab, onValueChange: setActiveTab, children: [
|
|
2072
|
+
/* @__PURE__ */ jsxRuntime.jsxs(TabsList, { className: "w-full rounded-md mb-4", children: [
|
|
2073
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { className: clsx2.clsx("cursor-pointer", { "bg-background": activeTab == "saved" }), value: "saved", children: "Use saved card" }),
|
|
2074
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsTrigger, { className: clsx2.clsx("cursor-pointer", { "bg-background": activeTab == "new" }), value: "new", children: "Add new card" })
|
|
2075
|
+
] }),
|
|
2076
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "saved", children: renderSavedTab() }),
|
|
2077
|
+
/* @__PURE__ */ jsxRuntime.jsx(TabsContent, { value: "new", children: renderNewTab() })
|
|
2078
|
+
] });
|
|
1942
2079
|
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-6 pt-4", children: [
|
|
1943
2080
|
mode === "cards" && renderCardExperience(),
|
|
1944
2081
|
mode === "solana" && enableSolanaPay && /* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -1989,7 +2126,7 @@ var useSubscriptionActions = () => {
|
|
|
1989
2126
|
}
|
|
1990
2127
|
return priceId;
|
|
1991
2128
|
};
|
|
1992
|
-
const subscribeWithCard =
|
|
2129
|
+
const subscribeWithCard = React15.useCallback(
|
|
1993
2130
|
async ({
|
|
1994
2131
|
priceId,
|
|
1995
2132
|
processor = "nmi",
|
|
@@ -2016,7 +2153,7 @@ var useSubscriptionActions = () => {
|
|
|
2016
2153
|
},
|
|
2017
2154
|
[client]
|
|
2018
2155
|
);
|
|
2019
|
-
const subscribeWithSavedMethod =
|
|
2156
|
+
const subscribeWithSavedMethod = React15.useCallback(
|
|
2020
2157
|
async ({
|
|
2021
2158
|
priceId,
|
|
2022
2159
|
processor = "nmi",
|
|
@@ -2036,7 +2173,7 @@ var useSubscriptionActions = () => {
|
|
|
2036
2173
|
},
|
|
2037
2174
|
[client]
|
|
2038
2175
|
);
|
|
2039
|
-
const subscribeWithCCBill =
|
|
2176
|
+
const subscribeWithCCBill = React15.useCallback(
|
|
2040
2177
|
async ({
|
|
2041
2178
|
priceId,
|
|
2042
2179
|
email,
|
|
@@ -2082,15 +2219,15 @@ var SubscriptionCheckoutModal = ({
|
|
|
2082
2219
|
onSolanaError,
|
|
2083
2220
|
initialMode = "cards"
|
|
2084
2221
|
}) => {
|
|
2085
|
-
const [showSuccess, setShowSuccess] =
|
|
2086
|
-
const [idempotencyKey, setIdempotencyKey] =
|
|
2222
|
+
const [showSuccess, setShowSuccess] = React15.useState(false);
|
|
2223
|
+
const [idempotencyKey, setIdempotencyKey] = React15.useState(() => crypto.randomUUID());
|
|
2087
2224
|
const { subscribeWithCard, subscribeWithSavedMethod } = useSubscriptionActions();
|
|
2088
|
-
|
|
2225
|
+
React15.useEffect(() => {
|
|
2089
2226
|
if (open) {
|
|
2090
2227
|
setIdempotencyKey(crypto.randomUUID());
|
|
2091
2228
|
}
|
|
2092
2229
|
}, [open, priceId]);
|
|
2093
|
-
const handleClose =
|
|
2230
|
+
const handleClose = React15.useCallback(
|
|
2094
2231
|
(nextOpen) => {
|
|
2095
2232
|
onOpenChange(nextOpen);
|
|
2096
2233
|
if (!nextOpen) setShowSuccess(false);
|
|
@@ -2147,16 +2284,17 @@ var SubscriptionCheckoutModal = ({
|
|
|
2147
2284
|
onSolanaError?.(error);
|
|
2148
2285
|
};
|
|
2149
2286
|
return /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
2150
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.
|
|
2287
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange: handleClose, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
2151
2288
|
DialogContent,
|
|
2152
2289
|
{
|
|
2153
|
-
className: "max-w-3xl max-h-[90vh] overflow-y-auto [&::-webkit-scrollbar]:hidden",
|
|
2154
|
-
children:
|
|
2155
|
-
|
|
2290
|
+
className: "max-w-3xl max-h-[90vh] overflow-y-auto border-border rounded-md [&::-webkit-scrollbar]:hidden",
|
|
2291
|
+
children: [
|
|
2292
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: "Checkout" }) }),
|
|
2293
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "space-y-4", children: !priceId ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-2 text-center px-3 py-2 text-sm text-destructive", children: [
|
|
2156
2294
|
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.AlertCircle, { className: "h-4 w-4" }),
|
|
2157
|
-
"
|
|
2158
|
-
|
|
2159
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2295
|
+
" ",
|
|
2296
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { children: "Select a subscription plan to continue." })
|
|
2297
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsx(
|
|
2160
2298
|
PaymentExperience,
|
|
2161
2299
|
{
|
|
2162
2300
|
usdAmount,
|
|
@@ -2170,8 +2308,8 @@ var SubscriptionCheckoutModal = ({
|
|
|
2170
2308
|
onNewCardPayment: priceId ? handleNewCardPayment : void 0,
|
|
2171
2309
|
onSavedMethodPayment: priceId ? handleSavedMethodPayment : void 0
|
|
2172
2310
|
}
|
|
2173
|
-
)
|
|
2174
|
-
]
|
|
2311
|
+
) })
|
|
2312
|
+
]
|
|
2175
2313
|
}
|
|
2176
2314
|
) }),
|
|
2177
2315
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
@@ -2199,7 +2337,7 @@ var wallets = [
|
|
|
2199
2337
|
}
|
|
2200
2338
|
];
|
|
2201
2339
|
var WalletModal = ({ open, onOpenChange }) => {
|
|
2202
|
-
const [expandedWallet, setExpandedWallet] =
|
|
2340
|
+
const [expandedWallet, setExpandedWallet] = React15.useState(null);
|
|
2203
2341
|
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open, onOpenChange, children: /* @__PURE__ */ jsxRuntime.jsxs(DialogContent, { className: "w-full max-w-lg max-h-[90vh] overflow-y-auto rounded-md border bg-background/95 p-0 shadow-2xl [&::-webkit-scrollbar]:hidden", children: [
|
|
2204
2342
|
/* @__PURE__ */ jsxRuntime.jsxs(DialogHeader, { className: "border-b bg-gradient-to-r from-primary/10 via-background to-background px-6 py-5 text-left", children: [
|
|
2205
2343
|
/* @__PURE__ */ jsxRuntime.jsxs(DialogTitle, { className: "flex items-center gap-2 text-foreground", children: [
|
|
@@ -2255,17 +2393,17 @@ var createDialogState = () => ({
|
|
|
2255
2393
|
isOpen: false,
|
|
2256
2394
|
props: null
|
|
2257
2395
|
});
|
|
2258
|
-
var PaymentsDialogContext =
|
|
2396
|
+
var PaymentsDialogContext = React15.createContext(void 0);
|
|
2259
2397
|
var PaymentsDialogProvider = ({
|
|
2260
2398
|
children
|
|
2261
2399
|
}) => {
|
|
2262
|
-
const [checkoutState, setCheckoutState] =
|
|
2400
|
+
const [checkoutState, setCheckoutState] = React15.useState(
|
|
2263
2401
|
() => createDialogState()
|
|
2264
2402
|
);
|
|
2265
|
-
const [walletState, setWalletState] =
|
|
2403
|
+
const [walletState, setWalletState] = React15.useState(
|
|
2266
2404
|
() => createDialogState()
|
|
2267
2405
|
);
|
|
2268
|
-
const contextValue =
|
|
2406
|
+
const contextValue = React15.useMemo(() => {
|
|
2269
2407
|
const openCheckout = (options) => setCheckoutState({
|
|
2270
2408
|
isOpen: true,
|
|
2271
2409
|
props: options
|
|
@@ -2319,18 +2457,18 @@ var PaymentsDialogProvider = ({
|
|
|
2319
2457
|
] });
|
|
2320
2458
|
};
|
|
2321
2459
|
var usePaymentDialogs = () => {
|
|
2322
|
-
const context =
|
|
2460
|
+
const context = React15.useContext(PaymentsDialogContext);
|
|
2323
2461
|
if (!context) {
|
|
2324
2462
|
throw new Error("usePaymentDialogs must be used within PaymentProvider");
|
|
2325
2463
|
}
|
|
2326
2464
|
return context;
|
|
2327
2465
|
};
|
|
2328
|
-
var PaymentContext =
|
|
2466
|
+
var PaymentContext = React15.createContext(void 0);
|
|
2329
2467
|
var PaymentProvider = ({
|
|
2330
2468
|
config,
|
|
2331
2469
|
children
|
|
2332
2470
|
}) => {
|
|
2333
|
-
const queryClient =
|
|
2471
|
+
const queryClient = React15.useMemo(() => {
|
|
2334
2472
|
return new reactQuery.QueryClient({
|
|
2335
2473
|
defaultOptions: {
|
|
2336
2474
|
queries: {
|
|
@@ -2345,7 +2483,7 @@ var PaymentProvider = ({
|
|
|
2345
2483
|
}
|
|
2346
2484
|
});
|
|
2347
2485
|
}, []);
|
|
2348
|
-
const client =
|
|
2486
|
+
const client = React15.useMemo(() => {
|
|
2349
2487
|
const authProvider = config.getAuthToken ? async () => {
|
|
2350
2488
|
try {
|
|
2351
2489
|
const result = config.getAuthToken?.();
|
|
@@ -2369,12 +2507,12 @@ var PaymentProvider = ({
|
|
|
2369
2507
|
defaultHeaders: config.defaultHeaders
|
|
2370
2508
|
});
|
|
2371
2509
|
}, [config]);
|
|
2372
|
-
const solanaEndpoint =
|
|
2510
|
+
const solanaEndpoint = React15.useMemo(() => {
|
|
2373
2511
|
if (config.solana?.endpoint) return config.solana.endpoint;
|
|
2374
2512
|
const network = config.solana?.network ?? walletAdapterBase.WalletAdapterNetwork.Mainnet;
|
|
2375
2513
|
return web3_js.clusterApiUrl(network);
|
|
2376
2514
|
}, [config.solana?.endpoint, config.solana?.network]);
|
|
2377
|
-
const walletAdapters =
|
|
2515
|
+
const walletAdapters = React15.useMemo(() => {
|
|
2378
2516
|
if (config.solana?.wallets?.length) {
|
|
2379
2517
|
return config.solana.wallets;
|
|
2380
2518
|
}
|
|
@@ -2386,21 +2524,21 @@ var PaymentProvider = ({
|
|
|
2386
2524
|
];
|
|
2387
2525
|
}, [config.solana?.wallets]);
|
|
2388
2526
|
const autoConnect = config.solana?.autoConnect ?? true;
|
|
2389
|
-
const value =
|
|
2527
|
+
const value = React15.useMemo(() => {
|
|
2390
2528
|
return {
|
|
2391
2529
|
config,
|
|
2392
2530
|
client,
|
|
2393
2531
|
queryClient
|
|
2394
2532
|
};
|
|
2395
2533
|
}, [client, config, queryClient]);
|
|
2396
|
-
|
|
2534
|
+
React15.useEffect(() => {
|
|
2397
2535
|
if (!config.collectJsKey) return;
|
|
2398
2536
|
loadCollectJs(config.collectJsKey);
|
|
2399
2537
|
}, [config.collectJsKey]);
|
|
2400
2538
|
return /* @__PURE__ */ jsxRuntime.jsx(PaymentContext.Provider, { value, children: /* @__PURE__ */ jsxRuntime.jsx(reactQuery.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ jsxRuntime.jsx(walletAdapterReact.ConnectionProvider, { endpoint: solanaEndpoint, config: { commitment: "confirmed" }, children: /* @__PURE__ */ jsxRuntime.jsx(walletAdapterReact.WalletProvider, { wallets: walletAdapters, autoConnect, children: /* @__PURE__ */ jsxRuntime.jsx(walletAdapterReactUi.WalletModalProvider, { children: /* @__PURE__ */ jsxRuntime.jsx(PaymentsDialogProvider, { children }) }) }) }) }) });
|
|
2401
2539
|
};
|
|
2402
2540
|
var usePaymentContext = () => {
|
|
2403
|
-
const context =
|
|
2541
|
+
const context = React15.useContext(PaymentContext);
|
|
2404
2542
|
if (!context) {
|
|
2405
2543
|
throw new Error("usePaymentContext must be used within a PaymentProvider");
|
|
2406
2544
|
}
|
|
@@ -2413,7 +2551,7 @@ var SolanaPaymentSelector = ({
|
|
|
2413
2551
|
}) => {
|
|
2414
2552
|
return /* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isOpen, onOpenChange: (value) => value ? void 0 : onClose(), children: /* @__PURE__ */ jsxRuntime.jsx(DialogContent, { className: "w-full max-w-2xl max-h-[90vh] overflow-y-auto rounded-md border bg-background/95 p-0 shadow-2xl [&::-webkit-scrollbar]:hidden", children: /* @__PURE__ */ jsxRuntime.jsx(SolanaPaymentView, { ...props, onClose }) }) });
|
|
2415
2553
|
};
|
|
2416
|
-
var Table =
|
|
2554
|
+
var Table = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("div", { className: "relative w-full overflow-auto", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
2417
2555
|
"table",
|
|
2418
2556
|
{
|
|
2419
2557
|
ref,
|
|
@@ -2422,9 +2560,9 @@ var Table = React17__namespace.forwardRef(({ className, ...props }, ref) => /* @
|
|
|
2422
2560
|
}
|
|
2423
2561
|
) }));
|
|
2424
2562
|
Table.displayName = "Table";
|
|
2425
|
-
var TableHeader =
|
|
2563
|
+
var TableHeader = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx("thead", { ref, className: cn("[&_tr]:border-b", className), ...props }));
|
|
2426
2564
|
TableHeader.displayName = "TableHeader";
|
|
2427
|
-
var TableBody =
|
|
2565
|
+
var TableBody = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2428
2566
|
"tbody",
|
|
2429
2567
|
{
|
|
2430
2568
|
ref,
|
|
@@ -2433,7 +2571,7 @@ var TableBody = React17__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
2433
2571
|
}
|
|
2434
2572
|
));
|
|
2435
2573
|
TableBody.displayName = "TableBody";
|
|
2436
|
-
var TableFooter =
|
|
2574
|
+
var TableFooter = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2437
2575
|
"tfoot",
|
|
2438
2576
|
{
|
|
2439
2577
|
ref,
|
|
@@ -2445,7 +2583,7 @@ var TableFooter = React17__namespace.forwardRef(({ className, ...props }, ref) =
|
|
|
2445
2583
|
}
|
|
2446
2584
|
));
|
|
2447
2585
|
TableFooter.displayName = "TableFooter";
|
|
2448
|
-
var TableRow =
|
|
2586
|
+
var TableRow = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2449
2587
|
"tr",
|
|
2450
2588
|
{
|
|
2451
2589
|
ref,
|
|
@@ -2457,7 +2595,7 @@ var TableRow = React17__namespace.forwardRef(({ className, ...props }, ref) => /
|
|
|
2457
2595
|
}
|
|
2458
2596
|
));
|
|
2459
2597
|
TableRow.displayName = "TableRow";
|
|
2460
|
-
var TableHead =
|
|
2598
|
+
var TableHead = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2461
2599
|
"th",
|
|
2462
2600
|
{
|
|
2463
2601
|
ref,
|
|
@@ -2469,7 +2607,7 @@ var TableHead = React17__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
2469
2607
|
}
|
|
2470
2608
|
));
|
|
2471
2609
|
TableHead.displayName = "TableHead";
|
|
2472
|
-
var TableCell =
|
|
2610
|
+
var TableCell = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2473
2611
|
"td",
|
|
2474
2612
|
{
|
|
2475
2613
|
ref,
|
|
@@ -2478,7 +2616,7 @@ var TableCell = React17__namespace.forwardRef(({ className, ...props }, ref) =>
|
|
|
2478
2616
|
}
|
|
2479
2617
|
));
|
|
2480
2618
|
TableCell.displayName = "TableCell";
|
|
2481
|
-
var TableCaption =
|
|
2619
|
+
var TableCaption = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2482
2620
|
"caption",
|
|
2483
2621
|
{
|
|
2484
2622
|
ref,
|
|
@@ -2490,7 +2628,7 @@ TableCaption.displayName = "TableCaption";
|
|
|
2490
2628
|
var AlertDialog = AlertDialogPrimitive__namespace.Root;
|
|
2491
2629
|
var AlertDialogTrigger = AlertDialogPrimitive__namespace.Trigger;
|
|
2492
2630
|
var AlertDialogPortal = AlertDialogPrimitive__namespace.Portal;
|
|
2493
|
-
var AlertDialogOverlay =
|
|
2631
|
+
var AlertDialogOverlay = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2494
2632
|
AlertDialogPrimitive__namespace.Overlay,
|
|
2495
2633
|
{
|
|
2496
2634
|
className: cn(
|
|
@@ -2502,7 +2640,7 @@ var AlertDialogOverlay = React17__namespace.forwardRef(({ className, ...props },
|
|
|
2502
2640
|
}
|
|
2503
2641
|
));
|
|
2504
2642
|
AlertDialogOverlay.displayName = AlertDialogPrimitive__namespace.Overlay.displayName;
|
|
2505
|
-
var AlertDialogContent =
|
|
2643
|
+
var AlertDialogContent = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsxs(AlertDialogPortal, { children: [
|
|
2506
2644
|
/* @__PURE__ */ jsxRuntime.jsx(AlertDialogOverlay, {}),
|
|
2507
2645
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
2508
2646
|
AlertDialogPrimitive__namespace.Content,
|
|
@@ -2545,7 +2683,7 @@ var AlertDialogFooter = ({
|
|
|
2545
2683
|
}
|
|
2546
2684
|
);
|
|
2547
2685
|
AlertDialogFooter.displayName = "AlertDialogFooter";
|
|
2548
|
-
var AlertDialogTitle =
|
|
2686
|
+
var AlertDialogTitle = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2549
2687
|
AlertDialogPrimitive__namespace.Title,
|
|
2550
2688
|
{
|
|
2551
2689
|
ref,
|
|
@@ -2554,7 +2692,7 @@ var AlertDialogTitle = React17__namespace.forwardRef(({ className, ...props }, r
|
|
|
2554
2692
|
}
|
|
2555
2693
|
));
|
|
2556
2694
|
AlertDialogTitle.displayName = AlertDialogPrimitive__namespace.Title.displayName;
|
|
2557
|
-
var AlertDialogDescription =
|
|
2695
|
+
var AlertDialogDescription = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2558
2696
|
AlertDialogPrimitive__namespace.Description,
|
|
2559
2697
|
{
|
|
2560
2698
|
ref,
|
|
@@ -2563,7 +2701,7 @@ var AlertDialogDescription = React17__namespace.forwardRef(({ className, ...prop
|
|
|
2563
2701
|
}
|
|
2564
2702
|
));
|
|
2565
2703
|
AlertDialogDescription.displayName = AlertDialogPrimitive__namespace.Description.displayName;
|
|
2566
|
-
var AlertDialogAction =
|
|
2704
|
+
var AlertDialogAction = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2567
2705
|
AlertDialogPrimitive__namespace.Action,
|
|
2568
2706
|
{
|
|
2569
2707
|
ref,
|
|
@@ -2572,7 +2710,7 @@ var AlertDialogAction = React17__namespace.forwardRef(({ className, ...props },
|
|
|
2572
2710
|
}
|
|
2573
2711
|
));
|
|
2574
2712
|
AlertDialogAction.displayName = AlertDialogPrimitive__namespace.Action.displayName;
|
|
2575
|
-
var AlertDialogCancel =
|
|
2713
|
+
var AlertDialogCancel = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
2576
2714
|
AlertDialogPrimitive__namespace.Cancel,
|
|
2577
2715
|
{
|
|
2578
2716
|
ref,
|
|
@@ -2585,7 +2723,7 @@ var AlertDialogCancel = React17__namespace.forwardRef(({ className, ...props },
|
|
|
2585
2723
|
}
|
|
2586
2724
|
));
|
|
2587
2725
|
AlertDialogCancel.displayName = AlertDialogPrimitive__namespace.Cancel.displayName;
|
|
2588
|
-
var Textarea =
|
|
2726
|
+
var Textarea = React15__namespace.forwardRef(({ className, ...props }, ref) => {
|
|
2589
2727
|
return /* @__PURE__ */ jsxRuntime.jsx(
|
|
2590
2728
|
"textarea",
|
|
2591
2729
|
{
|
|
@@ -2630,12 +2768,12 @@ var CancelMembershipDialog = ({
|
|
|
2630
2768
|
const { client } = usePaymentContext();
|
|
2631
2769
|
const notify = onNotify ?? notifyDefault;
|
|
2632
2770
|
const t = { ...defaultTranslations, ...customTranslations };
|
|
2633
|
-
const [cancelReason, setCancelReason] =
|
|
2634
|
-
const [isOpen, setIsOpen] =
|
|
2635
|
-
const [isReasonValid, setIsReasonValid] =
|
|
2636
|
-
const [hasInteracted, setHasInteracted] =
|
|
2637
|
-
const [isSubmitting, setIsSubmitting] =
|
|
2638
|
-
|
|
2771
|
+
const [cancelReason, setCancelReason] = React15.useState("");
|
|
2772
|
+
const [isOpen, setIsOpen] = React15.useState(false);
|
|
2773
|
+
const [isReasonValid, setIsReasonValid] = React15.useState(false);
|
|
2774
|
+
const [hasInteracted, setHasInteracted] = React15.useState(false);
|
|
2775
|
+
const [isSubmitting, setIsSubmitting] = React15.useState(false);
|
|
2776
|
+
React15.useEffect(() => {
|
|
2639
2777
|
const trimmed = cancelReason.trim();
|
|
2640
2778
|
setIsReasonValid(trimmed.length >= minReasonLength);
|
|
2641
2779
|
}, [cancelReason, minReasonLength]);
|
|
@@ -2768,9 +2906,9 @@ var BillingHistory = ({
|
|
|
2768
2906
|
const { client } = usePaymentContext();
|
|
2769
2907
|
const notify = onNotify ?? notifyDefault2;
|
|
2770
2908
|
const t = { ...defaultTranslations2, ...customTranslations };
|
|
2771
|
-
const [isExpanded, setIsExpanded] =
|
|
2772
|
-
const observerRef =
|
|
2773
|
-
const loadMoreRef =
|
|
2909
|
+
const [isExpanded, setIsExpanded] = React15.useState(false);
|
|
2910
|
+
const observerRef = React15.useRef(null);
|
|
2911
|
+
const loadMoreRef = React15.useRef(null);
|
|
2774
2912
|
const historyQuery = reactQuery.useInfiniteQuery({
|
|
2775
2913
|
queryKey: ["payments-ui", "billing-history", pageSize],
|
|
2776
2914
|
queryFn: async ({ pageParam = initialPage }) => {
|
|
@@ -2797,7 +2935,7 @@ var BillingHistory = ({
|
|
|
2797
2935
|
},
|
|
2798
2936
|
staleTime: 5 * 60 * 1e3
|
|
2799
2937
|
});
|
|
2800
|
-
|
|
2938
|
+
React15.useEffect(() => {
|
|
2801
2939
|
if (!loadMoreRef.current || !isExpanded) return;
|
|
2802
2940
|
observerRef.current = new IntersectionObserver((entries) => {
|
|
2803
2941
|
const [entry] = entries;
|
|
@@ -2812,7 +2950,7 @@ var BillingHistory = ({
|
|
|
2812
2950
|
observerRef.current?.disconnect();
|
|
2813
2951
|
};
|
|
2814
2952
|
}, [historyQuery, isExpanded, notify]);
|
|
2815
|
-
const payments =
|
|
2953
|
+
const payments = React15.useMemo(() => {
|
|
2816
2954
|
const data = historyQuery.data;
|
|
2817
2955
|
return data?.pages ?? [];
|
|
2818
2956
|
}, [historyQuery.data]);
|
|
@@ -2893,21 +3031,17 @@ var defaultTranslations3 = {
|
|
|
2893
3031
|
addedOn: "Added on",
|
|
2894
3032
|
active: "Active",
|
|
2895
3033
|
inactive: "Inactive",
|
|
2896
|
-
replaceCard: "Replace card",
|
|
2897
3034
|
makeDefault: "Make default",
|
|
2898
3035
|
defaultMethod: "Default method",
|
|
2899
3036
|
remove: "Remove",
|
|
2900
3037
|
addNewCard: "Add a new card",
|
|
2901
3038
|
addNewCardDescription: "Your card details are tokenized securely via our payment provider.",
|
|
2902
3039
|
saveCard: "Save card",
|
|
2903
|
-
replaceCardTitle: "Replace card",
|
|
2904
|
-
replaceCardDescription: "Update this card with new billing details.",
|
|
2905
3040
|
cardAddedSuccess: "Card added successfully",
|
|
2906
3041
|
unableToAddCard: "Unable to add card",
|
|
2907
3042
|
cardRemoved: "Card removed",
|
|
2908
|
-
unableToRemoveCard: "Unable to remove card",
|
|
2909
3043
|
cardUpdated: "Card updated",
|
|
2910
|
-
|
|
3044
|
+
unableToRemoveCard: "Unable to remove card",
|
|
2911
3045
|
defaultPaymentMethodUpdated: "Default payment method updated",
|
|
2912
3046
|
unableToSetDefault: "Unable to set default payment method"
|
|
2913
3047
|
};
|
|
@@ -2929,9 +3063,8 @@ var PaymentMethodsSection = ({
|
|
|
2929
3063
|
remove: (id) => client.deletePaymentMethod(id),
|
|
2930
3064
|
activate: (id) => client.activatePaymentMethod(id)
|
|
2931
3065
|
};
|
|
2932
|
-
const [isModalOpen, setIsModalOpen] =
|
|
2933
|
-
const [deletingId, setDeletingId] =
|
|
2934
|
-
const [methodBeingReplaced, setMethodBeingReplaced] = React17.useState(null);
|
|
3066
|
+
const [isModalOpen, setIsModalOpen] = React15.useState(false);
|
|
3067
|
+
const [deletingId, setDeletingId] = React15.useState(null);
|
|
2935
3068
|
const notify = onNotify ?? notifyDefault3;
|
|
2936
3069
|
const t = { ...defaultTranslations3, ...customTranslations };
|
|
2937
3070
|
const queryKey = ["payments-ui", "payment-methods"];
|
|
@@ -2972,21 +3105,6 @@ var PaymentMethodsSection = ({
|
|
|
2972
3105
|
},
|
|
2973
3106
|
onSettled: () => setDeletingId(null)
|
|
2974
3107
|
});
|
|
2975
|
-
const replaceMutation = reactQuery.useMutation({
|
|
2976
|
-
mutationFn: ({ id, payload }) => paymentMethods.update(id, payload),
|
|
2977
|
-
onSuccess: () => {
|
|
2978
|
-
notify({ title: t.cardUpdated, status: "success" });
|
|
2979
|
-
setMethodBeingReplaced(null);
|
|
2980
|
-
void queryClient.invalidateQueries({ queryKey });
|
|
2981
|
-
},
|
|
2982
|
-
onError: (error) => {
|
|
2983
|
-
notify({
|
|
2984
|
-
title: t.unableToReplaceCard,
|
|
2985
|
-
description: error.message,
|
|
2986
|
-
status: "destructive"
|
|
2987
|
-
});
|
|
2988
|
-
}
|
|
2989
|
-
});
|
|
2990
3108
|
const activateMutation = reactQuery.useMutation({
|
|
2991
3109
|
mutationFn: (id) => paymentMethods.activate(id),
|
|
2992
3110
|
onSuccess: () => {
|
|
@@ -3001,12 +3119,12 @@ var PaymentMethodsSection = ({
|
|
|
3001
3119
|
});
|
|
3002
3120
|
}
|
|
3003
3121
|
});
|
|
3004
|
-
|
|
3122
|
+
React15.useEffect(() => {
|
|
3005
3123
|
if (!isModalOpen) {
|
|
3006
3124
|
createMutation.reset();
|
|
3007
3125
|
}
|
|
3008
3126
|
}, [createMutation, isModalOpen]);
|
|
3009
|
-
const payments =
|
|
3127
|
+
const payments = React15.useMemo(() => paymentQuery.data?.data ?? [], [paymentQuery.data]);
|
|
3010
3128
|
const loading = paymentQuery.isLoading || paymentQuery.isFetching;
|
|
3011
3129
|
const buildPayload = (token, billing) => ({
|
|
3012
3130
|
payment_token: token,
|
|
@@ -3024,18 +3142,10 @@ var PaymentMethodsSection = ({
|
|
|
3024
3142
|
const handleCardTokenize = (token, billing) => {
|
|
3025
3143
|
createMutation.mutate(buildPayload(token, billing));
|
|
3026
3144
|
};
|
|
3027
|
-
|
|
3028
|
-
if (!methodBeingReplaced) return;
|
|
3029
|
-
replaceMutation.mutate({ id: methodBeingReplaced.id, payload: buildPayload(token, billing) });
|
|
3030
|
-
};
|
|
3031
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(Card, { children: [
|
|
3145
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(Card, { className: "bg-bckground border-border rounded-md", children: [
|
|
3032
3146
|
/* @__PURE__ */ jsxRuntime.jsxs(CardHeader, { className: "flex flex-col gap-4 md:flex-row md:items-center md:justify-between", children: [
|
|
3033
3147
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3034
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3035
|
-
/* @__PURE__ */ jsxRuntime.jsx(lucideReact.WalletCards, { className: "h-5 w-5 text-emerald-400" }),
|
|
3036
|
-
" ",
|
|
3037
|
-
t.title
|
|
3038
|
-
] }),
|
|
3148
|
+
/* @__PURE__ */ jsxRuntime.jsx(CardTitle, { className: "flex items-center gap-2", children: t.title }),
|
|
3039
3149
|
/* @__PURE__ */ jsxRuntime.jsx(CardDescription, { children: t.description })
|
|
3040
3150
|
] }),
|
|
3041
3151
|
/* @__PURE__ */ jsxRuntime.jsxs(Button, { onClick: () => setIsModalOpen(true), children: [
|
|
@@ -3053,40 +3163,14 @@ var PaymentMethodsSection = ({
|
|
|
3053
3163
|
{
|
|
3054
3164
|
className: "rounded-lg border bg-white/5 p-4 shadow-sm",
|
|
3055
3165
|
children: [
|
|
3056
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "
|
|
3057
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
3058
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
3059
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3060
|
-
t.addedOn,
|
|
3061
|
-
" ",
|
|
3062
|
-
method.created_at ? new Date(method.created_at).toLocaleDateString() : "unknown date"
|
|
3063
|
-
] })
|
|
3166
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "space-y-4", children: [
|
|
3167
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex justify-between", children: [
|
|
3168
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-medium text-white", children: formatCardLabel2(method) }),
|
|
3169
|
+
/* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: method.is_active ? "default" : "secondary", children: method.is_active ? t.active : t.inactive })
|
|
3064
3170
|
] }),
|
|
3065
|
-
/* @__PURE__ */ jsxRuntime.
|
|
3066
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3067
|
-
Badge,
|
|
3068
|
-
{
|
|
3069
|
-
variant: method.is_active ? "default" : "secondary",
|
|
3070
|
-
children: method.is_active ? t.active : t.inactive
|
|
3071
|
-
}
|
|
3072
|
-
),
|
|
3073
|
-
method.failure_reason && /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "destructive", children: method.failure_reason })
|
|
3074
|
-
] })
|
|
3171
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { children: method.failure_reason && /* @__PURE__ */ jsxRuntime.jsx(Badge, { variant: "destructive", children: method.failure_reason }) })
|
|
3075
3172
|
] }),
|
|
3076
3173
|
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 flex flex-wrap gap-2", children: [
|
|
3077
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3078
|
-
Button,
|
|
3079
|
-
{
|
|
3080
|
-
variant: "ghost",
|
|
3081
|
-
className: "text-blue-400",
|
|
3082
|
-
disabled: replaceMutation.isPending && methodBeingReplaced?.id === method.id,
|
|
3083
|
-
onClick: () => setMethodBeingReplaced(method),
|
|
3084
|
-
children: [
|
|
3085
|
-
replaceMutation.isPending && methodBeingReplaced?.id === method.id ? /* @__PURE__ */ jsxRuntime.jsx(lucideReact.Loader2, { className: "mr-2 h-4 w-4 animate-spin" }) : /* @__PURE__ */ jsxRuntime.jsx(lucideReact.CreditCard, { className: "mr-2 h-4 w-4" }),
|
|
3086
|
-
t.replaceCard
|
|
3087
|
-
]
|
|
3088
|
-
}
|
|
3089
|
-
),
|
|
3090
3174
|
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
3091
3175
|
Button,
|
|
3092
3176
|
{
|
|
@@ -3117,55 +3201,34 @@ var PaymentMethodsSection = ({
|
|
|
3117
3201
|
},
|
|
3118
3202
|
method.id
|
|
3119
3203
|
)) }) }),
|
|
3120
|
-
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isModalOpen, onOpenChange: setIsModalOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3121
|
-
|
|
3122
|
-
|
|
3123
|
-
|
|
3124
|
-
|
|
3125
|
-
|
|
3126
|
-
|
|
3127
|
-
|
|
3128
|
-
|
|
3129
|
-
|
|
3130
|
-
|
|
3131
|
-
|
|
3132
|
-
|
|
3133
|
-
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
|
|
3137
|
-
|
|
3138
|
-
|
|
3139
|
-
|
|
3140
|
-
|
|
3141
|
-
|
|
3142
|
-
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
/* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: t.replaceCardTitle }),
|
|
3146
|
-
/* @__PURE__ */ jsxRuntime.jsx(DialogDescription, { children: t.replaceCardDescription })
|
|
3147
|
-
] }),
|
|
3148
|
-
methodBeingReplaced && /* @__PURE__ */ jsxRuntime.jsx(
|
|
3149
|
-
CardDetailsForm,
|
|
3150
|
-
{
|
|
3151
|
-
visible: true,
|
|
3152
|
-
collectPrefix: `${collectPrefix}-replace-${methodBeingReplaced.id}`,
|
|
3153
|
-
submitting: replaceMutation.isPending,
|
|
3154
|
-
submitLabel: t.replaceCard,
|
|
3155
|
-
defaultValues: {
|
|
3156
|
-
email: userEmail ?? "",
|
|
3157
|
-
country: defaultCountry,
|
|
3158
|
-
provider
|
|
3159
|
-
},
|
|
3160
|
-
externalError: replaceMutation.error?.message ?? null,
|
|
3161
|
-
onTokenize: handleReplaceTokenize,
|
|
3162
|
-
className: "rounded-2xl border bg-white/5 p-6"
|
|
3163
|
-
}
|
|
3164
|
-
)
|
|
3165
|
-
] }) })
|
|
3204
|
+
/* @__PURE__ */ jsxRuntime.jsx(Dialog, { open: isModalOpen, onOpenChange: setIsModalOpen, children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
3205
|
+
DialogContent,
|
|
3206
|
+
{
|
|
3207
|
+
className: "max-w-3xl max-h-[90vh] overflow-y-auto border-border rounded-md [&::-webkit-scrollbar]:hidden",
|
|
3208
|
+
children: [
|
|
3209
|
+
/* @__PURE__ */ jsxRuntime.jsx(DialogHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(DialogTitle, { children: t.addNewCard }) }),
|
|
3210
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
3211
|
+
CardDetailsForm,
|
|
3212
|
+
{
|
|
3213
|
+
visible: isModalOpen,
|
|
3214
|
+
submitLabel: t.saveCard,
|
|
3215
|
+
collectPrefix,
|
|
3216
|
+
onTokenize: handleCardTokenize,
|
|
3217
|
+
submitting: createMutation.isPending,
|
|
3218
|
+
defaultValues: {
|
|
3219
|
+
provider,
|
|
3220
|
+
email: userEmail ?? "",
|
|
3221
|
+
country: defaultCountry
|
|
3222
|
+
},
|
|
3223
|
+
externalError: createMutation.error?.message ?? null
|
|
3224
|
+
}
|
|
3225
|
+
)
|
|
3226
|
+
]
|
|
3227
|
+
}
|
|
3228
|
+
) })
|
|
3166
3229
|
] });
|
|
3167
3230
|
};
|
|
3168
|
-
var Checkbox =
|
|
3231
|
+
var Checkbox = React15__namespace.forwardRef(({ className, ...props }, ref) => /* @__PURE__ */ jsxRuntime.jsx(
|
|
3169
3232
|
CheckboxPrimitive__namespace.Root,
|
|
3170
3233
|
{
|
|
3171
3234
|
ref,
|
|
@@ -3192,9 +3255,9 @@ var initialState = {
|
|
|
3192
3255
|
termsAccepted: false
|
|
3193
3256
|
};
|
|
3194
3257
|
var WalletDialog = ({ open, onOpenChange }) => {
|
|
3195
|
-
const [form, setForm] =
|
|
3196
|
-
const [errors, setErrors] =
|
|
3197
|
-
const validators =
|
|
3258
|
+
const [form, setForm] = React15.useState(initialState);
|
|
3259
|
+
const [errors, setErrors] = React15.useState({});
|
|
3260
|
+
const validators = React15.useMemo(
|
|
3198
3261
|
() => ({
|
|
3199
3262
|
nameOnCard: (value) => !value ? "Name is required" : void 0,
|
|
3200
3263
|
cardNumber: (value) => /^\d{16}$/.test(value) ? void 0 : "Card number must be 16 digits",
|
|
@@ -3287,10 +3350,10 @@ var WalletDialog = ({ open, onOpenChange }) => {
|
|
|
3287
3350
|
var useTokenBalance = (tokens) => {
|
|
3288
3351
|
const { publicKey } = walletAdapterReact.useWallet();
|
|
3289
3352
|
const { connection } = walletAdapterReact.useConnection();
|
|
3290
|
-
const [balances, setBalances] =
|
|
3291
|
-
const [isLoading, setIsLoading] =
|
|
3292
|
-
const [error, setError] =
|
|
3293
|
-
const fetchTokenBalance =
|
|
3353
|
+
const [balances, setBalances] = React15.useState([]);
|
|
3354
|
+
const [isLoading, setIsLoading] = React15.useState(false);
|
|
3355
|
+
const [error, setError] = React15.useState(null);
|
|
3356
|
+
const fetchTokenBalance = React15.useCallback(
|
|
3294
3357
|
async (token, walletAddress) => {
|
|
3295
3358
|
try {
|
|
3296
3359
|
const mintPublicKey = new web3_js.PublicKey(token.mint);
|
|
@@ -3331,8 +3394,8 @@ var useTokenBalance = (tokens) => {
|
|
|
3331
3394
|
},
|
|
3332
3395
|
[connection]
|
|
3333
3396
|
);
|
|
3334
|
-
const tokensKey =
|
|
3335
|
-
|
|
3397
|
+
const tokensKey = React15.useMemo(() => tokens.map((t) => t.mint).join(","), [tokens]);
|
|
3398
|
+
React15.useEffect(() => {
|
|
3336
3399
|
if (!publicKey || tokens.length === 0) {
|
|
3337
3400
|
setBalances([]);
|
|
3338
3401
|
return;
|
|
@@ -3356,20 +3419,20 @@ var useTokenBalance = (tokens) => {
|
|
|
3356
3419
|
};
|
|
3357
3420
|
fetchAllBalances();
|
|
3358
3421
|
}, [publicKey, tokensKey, fetchTokenBalance]);
|
|
3359
|
-
const getTokenBalance =
|
|
3422
|
+
const getTokenBalance = React15.useCallback(
|
|
3360
3423
|
(tokenSymbol) => {
|
|
3361
3424
|
return balances.find((balance) => balance.token.symbol === tokenSymbol);
|
|
3362
3425
|
},
|
|
3363
3426
|
[balances]
|
|
3364
3427
|
);
|
|
3365
|
-
const hasSufficientBalance =
|
|
3428
|
+
const hasSufficientBalance = React15.useCallback(
|
|
3366
3429
|
(tokenSymbol, requiredAmount) => {
|
|
3367
3430
|
const balance = getTokenBalance(tokenSymbol);
|
|
3368
3431
|
return balance ? balance.uiAmount >= requiredAmount : false;
|
|
3369
3432
|
},
|
|
3370
3433
|
[getTokenBalance]
|
|
3371
3434
|
);
|
|
3372
|
-
const getFormattedBalance =
|
|
3435
|
+
const getFormattedBalance = React15.useCallback(
|
|
3373
3436
|
(tokenSymbol) => {
|
|
3374
3437
|
const balance = getTokenBalance(tokenSymbol);
|
|
3375
3438
|
if (!balance) return "0.00";
|
|
@@ -3383,7 +3446,7 @@ var useTokenBalance = (tokens) => {
|
|
|
3383
3446
|
},
|
|
3384
3447
|
[getTokenBalance]
|
|
3385
3448
|
);
|
|
3386
|
-
const refreshBalances =
|
|
3449
|
+
const refreshBalances = React15.useCallback(async () => {
|
|
3387
3450
|
if (!publicKey || tokens.length === 0) {
|
|
3388
3451
|
setBalances([]);
|
|
3389
3452
|
return;
|
|
@@ -3404,7 +3467,7 @@ var useTokenBalance = (tokens) => {
|
|
|
3404
3467
|
setIsLoading(false);
|
|
3405
3468
|
}
|
|
3406
3469
|
}, [publicKey, tokens, fetchTokenBalance]);
|
|
3407
|
-
const getTotalValue =
|
|
3470
|
+
const getTotalValue = React15.useCallback(
|
|
3408
3471
|
(priceData) => {
|
|
3409
3472
|
if (!priceData) return 0;
|
|
3410
3473
|
return balances.reduce((total, balance) => {
|
|
@@ -3443,21 +3506,21 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3443
3506
|
retryInterval = 1e4
|
|
3444
3507
|
// 10 seconds
|
|
3445
3508
|
} = options;
|
|
3446
|
-
const [status, setStatus] =
|
|
3447
|
-
const [paymentStatus, setPaymentStatus] =
|
|
3448
|
-
const [isLoading, setIsLoading] =
|
|
3449
|
-
const [error, setError] =
|
|
3450
|
-
const [retryCount, setRetryCount] =
|
|
3451
|
-
const intervalRef =
|
|
3452
|
-
const isMonitoringRef =
|
|
3453
|
-
|
|
3509
|
+
const [status, setStatus] = React15.useState(null);
|
|
3510
|
+
const [paymentStatus, setPaymentStatus] = React15.useState(null);
|
|
3511
|
+
const [isLoading, setIsLoading] = React15.useState(false);
|
|
3512
|
+
const [error, setError] = React15.useState(null);
|
|
3513
|
+
const [retryCount, setRetryCount] = React15.useState(0);
|
|
3514
|
+
const intervalRef = React15.useRef(null);
|
|
3515
|
+
const isMonitoringRef = React15.useRef(false);
|
|
3516
|
+
React15.useEffect(() => {
|
|
3454
3517
|
return () => {
|
|
3455
3518
|
if (intervalRef.current) {
|
|
3456
3519
|
clearInterval(intervalRef.current);
|
|
3457
3520
|
}
|
|
3458
3521
|
};
|
|
3459
3522
|
}, []);
|
|
3460
|
-
const checkTransactionStatus =
|
|
3523
|
+
const checkTransactionStatus = React15.useCallback(
|
|
3461
3524
|
async (signature) => {
|
|
3462
3525
|
try {
|
|
3463
3526
|
const statusResponse = await connection.getSignatureStatus(signature, {
|
|
@@ -3502,7 +3565,7 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3502
3565
|
},
|
|
3503
3566
|
[connection]
|
|
3504
3567
|
);
|
|
3505
|
-
const checkPaymentStatus =
|
|
3568
|
+
const checkPaymentStatus = React15.useCallback(
|
|
3506
3569
|
async (id) => {
|
|
3507
3570
|
try {
|
|
3508
3571
|
return await client.getPaymentStatus(id);
|
|
@@ -3516,7 +3579,7 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3516
3579
|
},
|
|
3517
3580
|
[client]
|
|
3518
3581
|
);
|
|
3519
|
-
const startMonitoring =
|
|
3582
|
+
const startMonitoring = React15.useCallback(async () => {
|
|
3520
3583
|
if (isMonitoringRef.current || !transactionId && !purchaseId) {
|
|
3521
3584
|
return;
|
|
3522
3585
|
}
|
|
@@ -3604,14 +3667,14 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3604
3667
|
retryInterval,
|
|
3605
3668
|
retryCount
|
|
3606
3669
|
]);
|
|
3607
|
-
const stopMonitoring =
|
|
3670
|
+
const stopMonitoring = React15.useCallback(() => {
|
|
3608
3671
|
if (intervalRef.current) {
|
|
3609
3672
|
clearInterval(intervalRef.current);
|
|
3610
3673
|
}
|
|
3611
3674
|
isMonitoringRef.current = false;
|
|
3612
3675
|
setIsLoading(false);
|
|
3613
3676
|
}, []);
|
|
3614
|
-
const checkStatus =
|
|
3677
|
+
const checkStatus = React15.useCallback(async () => {
|
|
3615
3678
|
if (!transactionId && !purchaseId) return;
|
|
3616
3679
|
setIsLoading(true);
|
|
3617
3680
|
setError(null);
|
|
@@ -3636,7 +3699,7 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3636
3699
|
setIsLoading(false);
|
|
3637
3700
|
}
|
|
3638
3701
|
}, [transactionId, purchaseId, checkTransactionStatus, checkPaymentStatus]);
|
|
3639
|
-
|
|
3702
|
+
React15.useEffect(() => {
|
|
3640
3703
|
if ((transactionId || purchaseId) && !isMonitoringRef.current) {
|
|
3641
3704
|
startMonitoring();
|
|
3642
3705
|
}
|
|
@@ -3644,7 +3707,7 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3644
3707
|
stopMonitoring();
|
|
3645
3708
|
};
|
|
3646
3709
|
}, [transactionId, purchaseId, startMonitoring, stopMonitoring]);
|
|
3647
|
-
const getConfirmationStatus =
|
|
3710
|
+
const getConfirmationStatus = React15.useCallback(() => {
|
|
3648
3711
|
if (paymentStatus?.status === "confirmed") return "confirmed";
|
|
3649
3712
|
if (paymentStatus?.status === "failed") return "failed";
|
|
3650
3713
|
if (status?.confirmationStatus === "finalized") return "confirmed";
|
|
@@ -3653,7 +3716,7 @@ var usePaymentStatus = (options = {}) => {
|
|
|
3653
3716
|
return "failed";
|
|
3654
3717
|
return "pending";
|
|
3655
3718
|
}, [status, paymentStatus]);
|
|
3656
|
-
const getSolscanUrl =
|
|
3719
|
+
const getSolscanUrl = React15.useCallback(
|
|
3657
3720
|
(signature) => {
|
|
3658
3721
|
const txId = signature || transactionId;
|
|
3659
3722
|
if (!txId) return null;
|