@superlogic/spree-pay 0.1.37 → 0.1.39
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/build/index.cjs +674 -466
- package/build/index.css +69 -38
- package/build/index.d.cts +7 -1
- package/build/index.d.ts +7 -1
- package/build/index.js +648 -440
- package/package.json +3 -2
package/build/index.cjs
CHANGED
|
@@ -39,12 +39,12 @@ __export(index_exports, {
|
|
|
39
39
|
module.exports = __toCommonJS(index_exports);
|
|
40
40
|
|
|
41
41
|
// src/SpreePay.tsx
|
|
42
|
-
var
|
|
43
|
-
var
|
|
42
|
+
var import_react19 = require("react");
|
|
43
|
+
var import_nice_modal_react9 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
44
44
|
var import_swr5 = require("swr");
|
|
45
45
|
|
|
46
46
|
// package.json
|
|
47
|
-
var version = "0.1.
|
|
47
|
+
var version = "0.1.39";
|
|
48
48
|
|
|
49
49
|
// src/context/SpreePayActionsContext.tsx
|
|
50
50
|
var import_react = require("react");
|
|
@@ -65,6 +65,7 @@ var PaymentError = class extends Error {
|
|
|
65
65
|
var PaymentType = /* @__PURE__ */ ((PaymentType2) => {
|
|
66
66
|
PaymentType2["CREDIT_CARD"] = "CREDIT_CARD";
|
|
67
67
|
PaymentType2["CRYPTO"] = "CRYPTO";
|
|
68
|
+
PaymentType2["CDC"] = "CDC";
|
|
68
69
|
PaymentType2["CREDIT_CARD_SPLIT"] = "SPLIT";
|
|
69
70
|
PaymentType2["POINTS"] = "POINTS";
|
|
70
71
|
return PaymentType2;
|
|
@@ -374,8 +375,174 @@ var getTransactionFee = (amount = 0, transactionFeePercentage) => {
|
|
|
374
375
|
return Math.round((fee + Number.EPSILON) * 100) / 100;
|
|
375
376
|
};
|
|
376
377
|
|
|
377
|
-
// src/components/
|
|
378
|
+
// src/components/common/PointsSwitch.tsx
|
|
379
|
+
var import_react3 = require("react");
|
|
380
|
+
|
|
381
|
+
// src/hooks/useSlapiBalance.ts
|
|
382
|
+
var import_swr2 = __toESM(require("swr"), 1);
|
|
383
|
+
var useSlapiBalance = () => {
|
|
384
|
+
const { data, isLoading, mutate } = (0, import_swr2.default)(`/v1/loyalty/accounts`);
|
|
385
|
+
return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
|
|
386
|
+
};
|
|
387
|
+
|
|
388
|
+
// src/ui/label.tsx
|
|
389
|
+
var LabelPrimitive = __toESM(require("@radix-ui/react-label"), 1);
|
|
378
390
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
391
|
+
function Label({ className, ...props }) {
|
|
392
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
393
|
+
LabelPrimitive.Root,
|
|
394
|
+
{
|
|
395
|
+
"data-slot": "label",
|
|
396
|
+
className: cn(
|
|
397
|
+
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
398
|
+
className
|
|
399
|
+
),
|
|
400
|
+
...props
|
|
401
|
+
}
|
|
402
|
+
);
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
// src/ui/switch.tsx
|
|
406
|
+
var SwitchPrimitive = __toESM(require("@radix-ui/react-switch"), 1);
|
|
407
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
408
|
+
function Switch({ className, ...props }) {
|
|
409
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
410
|
+
SwitchPrimitive.Root,
|
|
411
|
+
{
|
|
412
|
+
"data-slot": "switch",
|
|
413
|
+
className: cn(
|
|
414
|
+
"peer focus-visible:border-ring focus-visible:ring-ring/50 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-(--s-brand) data-[state=unchecked]:bg-(--s-tertiary)",
|
|
415
|
+
className
|
|
416
|
+
),
|
|
417
|
+
...props,
|
|
418
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
419
|
+
SwitchPrimitive.Thumb,
|
|
420
|
+
{
|
|
421
|
+
"data-slot": "switch-thumb",
|
|
422
|
+
className: "pointer-events-none block size-4 rounded-full bg-(--s-default) ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
|
|
423
|
+
}
|
|
424
|
+
)
|
|
425
|
+
}
|
|
426
|
+
);
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
// src/components/common/InfoBanner.tsx
|
|
430
|
+
var import_xss = __toESM(require("xss"), 1);
|
|
431
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
432
|
+
var InfoBanner = (props) => {
|
|
433
|
+
const { type = "info", message } = props;
|
|
434
|
+
if (!message) return null;
|
|
435
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
436
|
+
"div",
|
|
437
|
+
{
|
|
438
|
+
className: cn("flex w-full gap-1.5 rounded-md p-2", {
|
|
439
|
+
"border border-(--b-secondary)": type === "info",
|
|
440
|
+
"bg-(--s-warning)/10": type === "warning"
|
|
441
|
+
}),
|
|
442
|
+
children: [
|
|
443
|
+
type === "info" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
444
|
+
"svg",
|
|
445
|
+
{
|
|
446
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
447
|
+
fill: "none",
|
|
448
|
+
viewBox: "0 0 20 20",
|
|
449
|
+
className: "size-5 shrink-0 text-(--positive)",
|
|
450
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
451
|
+
"path",
|
|
452
|
+
{
|
|
453
|
+
fill: "currentColor",
|
|
454
|
+
d: "M10 17.92a2.2 2.2 0 0 1-1.59-.66 4 4 0 0 0-1.07-.81q-.45-.2-1.35-.2-.94 0-1.6-.65a2.2 2.2 0 0 1-.65-1.59q0-.9-.19-1.34a4 4 0 0 0-.8-1.08 2.2 2.2 0 0 1-.5-2.44q.17-.41.5-.74.6-.62.8-1.07t.2-1.35q0-.94.65-1.6.65-.65 1.59-.65.9 0 1.34-.19.46-.2 1.08-.81A2.2 2.2 0 0 1 10 2.08a2.3 2.3 0 0 1 1.59.66q.62.62 1.07.81t1.35.2q.94 0 1.6.65.65.64.65 1.59 0 .9.19 1.34.2.46.81 1.08a2.2 2.2 0 0 1 .66 1.59 2.2 2.2 0 0 1-.66 1.59q-.61.63-.81 1.07t-.2 1.35q0 .94-.65 1.6-.64.65-1.59.65-.9 0-1.34.19-.45.2-1.08.8a2.2 2.2 0 0 1-1.59.67m0-1.25q.2 0 .39-.08a1 1 0 0 0 .31-.21q.8-.8 1.5-1.09.7-.28 1.81-.28.42 0 .71-.29.3-.29.29-.7 0-1.13.28-1.82.3-.7 1.08-1.5.3-.3.3-.7t-.3-.7a5 5 0 0 1-1.08-1.5 5 5 0 0 1-.28-1.8q0-.42-.29-.71a1 1 0 0 0-.7-.29q-1.14 0-1.83-.28a5 5 0 0 1-1.5-1.08 1 1 0 0 0-.69-.3 1 1 0 0 0-.7.3q-.8.8-1.5 1.08T6 4.99q-.42 0-.71.29a1 1 0 0 0-.29.7q0 1.14-.28 1.83t-1.09 1.5q-.29.28-.29.69t.3.7q.8.8 1.08 1.5T5 14.01q0 .42.29.71.29.3.7.29 1.14 0 1.83.28t1.5 1.09a1 1 0 0 0 .7.29m2.03-3.62q.43 0 .73-.3t.3-.72a1 1 0 0 0-.3-.73 1 1 0 0 0-.73-.3 1 1 0 0 0-.73.3 1 1 0 0 0-.3.73q0 .43.3.73t.73.3m-4.53-.54q.18.18.43.18a.6.6 0 0 0 .43-.18l4.14-4.12a.6.6 0 0 0 .2-.44.6.6 0 0 0-.2-.45.6.6 0 0 0-.44-.2.6.6 0 0 0-.45.2l-4.12 4.14a.6.6 0 0 0-.18.43q0 .25.19.44M7.97 9a1 1 0 0 0 .74-.3 1 1 0 0 0 .3-.74q0-.43-.3-.73a1 1 0 0 0-.74-.3q-.43 0-.73.3t-.3.73.3.73.73.3"
|
|
455
|
+
}
|
|
456
|
+
)
|
|
457
|
+
}
|
|
458
|
+
),
|
|
459
|
+
type === "warning" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
460
|
+
"svg",
|
|
461
|
+
{
|
|
462
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
463
|
+
fill: "none",
|
|
464
|
+
viewBox: "0 0 20 20",
|
|
465
|
+
className: "size-5 shrink-0 text-(--warning)",
|
|
466
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
467
|
+
"path",
|
|
468
|
+
{
|
|
469
|
+
fill: "currentColor",
|
|
470
|
+
d: "M10 13.96a.6.6 0 0 0 .44-.18.6.6 0 0 0 .18-.45V9.8a.6.6 0 0 0-.18-.44.6.6 0 0 0-.44-.18.6.6 0 0 0-.45.18.6.6 0 0 0-.18.44v3.54q0 .27.18.45a.6.6 0 0 0 .45.18m0-6.22q.29 0 .48-.2.2-.18.2-.47 0-.3-.2-.48a.7.7 0 0 0-.48-.2q-.3 0-.48.2a.7.7 0 0 0-.2.48q0 .29.2.48.2.2.48.19m0 10.18q-1.64 0-3.09-.63a8 8 0 0 1-4.2-4.2 8 8 0 0 1-.63-3.1q0-1.64.63-3.09a8 8 0 0 1 4.2-4.2q1.45-.63 3.09-.63 1.65 0 3.08.63a8 8 0 0 1 4.21 4.2q.63 1.45.63 3.09t-.63 3.09a8 8 0 0 1-4.2 4.2q-1.46.63-3.09.63m0-1.25q2.8 0 4.73-1.94A6.4 6.4 0 0 0 16.67 10q0-2.8-1.94-4.73A6.4 6.4 0 0 0 10 3.33q-2.8 0-4.73 1.94A6.4 6.4 0 0 0 3.33 10q0 2.8 1.94 4.73A6.4 6.4 0 0 0 10 16.67"
|
|
471
|
+
}
|
|
472
|
+
)
|
|
473
|
+
}
|
|
474
|
+
),
|
|
475
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
476
|
+
"p",
|
|
477
|
+
{
|
|
478
|
+
className: "text-[14px] leading-5 text-(--primary) [&_a]:underline",
|
|
479
|
+
dangerouslySetInnerHTML: { __html: (0, import_xss.default)(message) }
|
|
480
|
+
}
|
|
481
|
+
)
|
|
482
|
+
]
|
|
483
|
+
}
|
|
484
|
+
);
|
|
485
|
+
};
|
|
486
|
+
|
|
487
|
+
// src/components/common/PointsSwitch.tsx
|
|
488
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
489
|
+
var PointsSwitch = (props) => {
|
|
490
|
+
const { disabled = false, value, onChange, message } = props;
|
|
491
|
+
const { spreePayConfig } = useSpreePayConfig();
|
|
492
|
+
const { appProps } = useStaticConfig();
|
|
493
|
+
const { balance } = useSlapiBalance();
|
|
494
|
+
const id = (0, import_react3.useId)();
|
|
495
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex flex-col gap-6", children: [
|
|
496
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
|
|
497
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
498
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(Switch, { checked: value, onCheckedChange: onChange, disabled, id }),
|
|
499
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
500
|
+
Label,
|
|
501
|
+
{
|
|
502
|
+
htmlFor: id,
|
|
503
|
+
className: "text-md flex-col items-baseline gap-0 leading-[1.3] font-medium text-(--brand-primary) sm:flex-row sm:gap-2 md:text-[22px]",
|
|
504
|
+
children: [
|
|
505
|
+
"Use Points ",
|
|
506
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-xs font-medium text-(--tertiary)", children: "Optional" })
|
|
507
|
+
]
|
|
508
|
+
}
|
|
509
|
+
)
|
|
510
|
+
] }),
|
|
511
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className: "flex items-center gap-2.5", children: [
|
|
512
|
+
balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("p", { className: "flex-1 text-right text-sm font-medium text-(--brand-primary)", children: [
|
|
513
|
+
formatPoints(balance.availablePoints, spreePayConfig?.pointsTitle),
|
|
514
|
+
!!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { className: "text-(--secondary)", children: ` \xB7 ${formatUSD(balance.availablePoints * spreePayConfig.pointsConversionRatio)}` })
|
|
515
|
+
] }) : null,
|
|
516
|
+
Boolean(appProps.topUpLink) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
517
|
+
"a",
|
|
518
|
+
{
|
|
519
|
+
className: "cursor-pointer rounded-full bg-(--primary) px-2 py-1.5 text-xs font-medium text-(--inverse)",
|
|
520
|
+
rel: "noreferrer",
|
|
521
|
+
target: "_blank",
|
|
522
|
+
href: appProps.topUpLink,
|
|
523
|
+
children: "Top Up"
|
|
524
|
+
}
|
|
525
|
+
)
|
|
526
|
+
] })
|
|
527
|
+
] }),
|
|
528
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(InfoBanner, { type: "warning", message })
|
|
529
|
+
] });
|
|
530
|
+
};
|
|
531
|
+
|
|
532
|
+
// src/components/common/Legal.tsx
|
|
533
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
534
|
+
var Legal = () => {
|
|
535
|
+
const { spreePayConfig } = useSpreePayConfig();
|
|
536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("p", { className: "text-center text-xs leading-5 font-medium text-(--secondary)", children: [
|
|
537
|
+
"By clicking on the button below I acknowledge that I have read and accepted the",
|
|
538
|
+
" ",
|
|
539
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("a", { className: "underline", href: spreePayConfig?.termsConditionsUrl, target: "_blank", rel: "noreferrer", children: "Terms and Conditions" }),
|
|
540
|
+
"."
|
|
541
|
+
] });
|
|
542
|
+
};
|
|
543
|
+
|
|
544
|
+
// src/components/CheckoutButton.tsx
|
|
545
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
379
546
|
var CheckoutButton = ({ isLoggedIn }) => {
|
|
380
547
|
const { appProps, staticConfig } = useStaticConfig();
|
|
381
548
|
const { amount, onProcess, isProcessing, transactionFeePercentage } = appProps;
|
|
@@ -389,7 +556,7 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
389
556
|
const isCrypto = type === "CRYPTO" /* CRYPTO */;
|
|
390
557
|
const getCheckoutContent = () => {
|
|
391
558
|
if (!!isProcessing || isInternalProcessing) {
|
|
392
|
-
return /* @__PURE__ */ (0,
|
|
559
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Spinner, { className: "inline", size: "sm" });
|
|
393
560
|
}
|
|
394
561
|
if (isCC && amount) {
|
|
395
562
|
if (splitAmount && usdAmount) {
|
|
@@ -409,14 +576,9 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
409
576
|
return "Checkout";
|
|
410
577
|
};
|
|
411
578
|
const checkoutClass = "text-(--inverse) h-14 w-full cursor-pointer rounded-4xl bg-(--s-brand) hover:bg-(--s-brand-hover) px-4 text-center text-xl leading-6 font-medium disabled:cursor-not-allowed disabled:bg-(--s-disabled) disabled:text-(--disabled)";
|
|
412
|
-
return /* @__PURE__ */ (0,
|
|
413
|
-
/* @__PURE__ */ (0,
|
|
414
|
-
|
|
415
|
-
" ",
|
|
416
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { className: "underline", href: spreePayConfig?.termsConditionsUrl, target: "_blank", rel: "noreferrer", children: "Terms and Conditions" }),
|
|
417
|
-
"."
|
|
418
|
-
] }),
|
|
419
|
-
isLoggedIn ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: onProcess && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("button", { disabled: isDisabled, onClick: onProcess, className: checkoutClass, children: getCheckoutContent() }) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
579
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex w-full flex-col gap-4 bg-(--s-default) p-6 text-xs leading-5 font-medium text-(--secondary) md:px-7", children: [
|
|
580
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(Legal, {}),
|
|
581
|
+
isLoggedIn ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: onProcess && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("button", { disabled: isDisabled, onClick: onProcess, className: checkoutClass, children: getCheckoutContent() }) }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
420
582
|
"a",
|
|
421
583
|
{
|
|
422
584
|
href: `${staticConfig.keycloakUrl}/realms/${env.tenantId}/protocol/openid-connect/auth?client_id=${staticConfig.keycloakClientId}&response_type=code&redirect_uri=${window.location.href}`,
|
|
@@ -424,9 +586,9 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
424
586
|
children: "Log in / Sign up for an AIR account"
|
|
425
587
|
}
|
|
426
588
|
),
|
|
427
|
-
/* @__PURE__ */ (0,
|
|
428
|
-
/* @__PURE__ */ (0,
|
|
429
|
-
/* @__PURE__ */ (0,
|
|
589
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("a", { href: "https://www.spree.finance/", className: "flex items-center justify-center gap-2 hover:underline", children: [
|
|
590
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("p", { children: "Powered by" }),
|
|
591
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("svg", { className: "shrink-0", xmlns: "http://www.w3.org/2000/svg", width: "66", height: "30", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
430
592
|
"path",
|
|
431
593
|
{
|
|
432
594
|
fill: "currentColor",
|
|
@@ -444,7 +606,7 @@ var import_react13 = require("react");
|
|
|
444
606
|
var import_nice_modal_react2 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
445
607
|
|
|
446
608
|
// src/modals/Iframe3ds.tsx
|
|
447
|
-
var
|
|
609
|
+
var import_react5 = require("react");
|
|
448
610
|
var import_nice_modal_react = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
449
611
|
|
|
450
612
|
// src/services/eventBus.ts
|
|
@@ -466,30 +628,30 @@ var DialogPrimitive = __toESM(require("@radix-ui/react-dialog"), 1);
|
|
|
466
628
|
var import_lucide_react = require("lucide-react");
|
|
467
629
|
|
|
468
630
|
// src/ui/portal.ts
|
|
469
|
-
var
|
|
470
|
-
var PortalContainerContext =
|
|
631
|
+
var import_react4 = __toESM(require("react"), 1);
|
|
632
|
+
var PortalContainerContext = import_react4.default.createContext({ container: null });
|
|
471
633
|
function PortalContainerProvider({
|
|
472
634
|
container,
|
|
473
635
|
children
|
|
474
636
|
}) {
|
|
475
|
-
return
|
|
637
|
+
return import_react4.default.createElement(PortalContainerContext.Provider, { value: { container } }, children);
|
|
476
638
|
}
|
|
477
639
|
function usePortalContainer() {
|
|
478
|
-
return
|
|
640
|
+
return import_react4.default.useContext(PortalContainerContext).container;
|
|
479
641
|
}
|
|
480
642
|
|
|
481
643
|
// src/ui/dialog.tsx
|
|
482
|
-
var
|
|
644
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
483
645
|
function Dialog({ ...props }) {
|
|
484
|
-
return /* @__PURE__ */ (0,
|
|
646
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DialogPrimitive.Root, { "data-slot": "dialog", ...props });
|
|
485
647
|
}
|
|
486
648
|
function DialogPortal({ ...props }) {
|
|
487
649
|
const container = usePortalContainer();
|
|
488
650
|
const safeContainer = container && document.body.contains(container) ? container : void 0;
|
|
489
|
-
return /* @__PURE__ */ (0,
|
|
651
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DialogPrimitive.Portal, { container: safeContainer, "data-slot": "dialog-portal", ...props });
|
|
490
652
|
}
|
|
491
653
|
function DialogOverlay({ className, ...props }) {
|
|
492
|
-
return /* @__PURE__ */ (0,
|
|
654
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
493
655
|
DialogPrimitive.Overlay,
|
|
494
656
|
{
|
|
495
657
|
"data-slot": "dialog-overlay",
|
|
@@ -507,9 +669,9 @@ function DialogContent({
|
|
|
507
669
|
showCloseButton = true,
|
|
508
670
|
...props
|
|
509
671
|
}) {
|
|
510
|
-
return /* @__PURE__ */ (0,
|
|
511
|
-
/* @__PURE__ */ (0,
|
|
512
|
-
/* @__PURE__ */ (0,
|
|
672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(DialogPortal, { "data-slot": "dialog-portal", children: [
|
|
673
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(DialogOverlay, {}),
|
|
674
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
513
675
|
DialogPrimitive.Content,
|
|
514
676
|
{
|
|
515
677
|
"data-slot": "dialog-content",
|
|
@@ -520,14 +682,14 @@ function DialogContent({
|
|
|
520
682
|
...props,
|
|
521
683
|
children: [
|
|
522
684
|
children,
|
|
523
|
-
showCloseButton && /* @__PURE__ */ (0,
|
|
685
|
+
showCloseButton && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
524
686
|
DialogPrimitive.Close,
|
|
525
687
|
{
|
|
526
688
|
"data-slot": "dialog-close",
|
|
527
689
|
className: "ring-offset-background focus:ring-ring 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 data-[state=open]:bg-(--accent) [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
|
|
528
690
|
children: [
|
|
529
|
-
/* @__PURE__ */ (0,
|
|
530
|
-
/* @__PURE__ */ (0,
|
|
691
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(import_lucide_react.XIcon, {}),
|
|
692
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "sr-only", children: "Close" })
|
|
531
693
|
]
|
|
532
694
|
}
|
|
533
695
|
)
|
|
@@ -537,7 +699,7 @@ function DialogContent({
|
|
|
537
699
|
] });
|
|
538
700
|
}
|
|
539
701
|
function DialogTitle({ className, ...props }) {
|
|
540
|
-
return /* @__PURE__ */ (0,
|
|
702
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
541
703
|
DialogPrimitive.Title,
|
|
542
704
|
{
|
|
543
705
|
"data-slot": "dialog-title",
|
|
@@ -547,7 +709,7 @@ function DialogTitle({ className, ...props }) {
|
|
|
547
709
|
);
|
|
548
710
|
}
|
|
549
711
|
function DialogDescription({ className, ...props }) {
|
|
550
|
-
return /* @__PURE__ */ (0,
|
|
712
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
551
713
|
DialogPrimitive.Description,
|
|
552
714
|
{
|
|
553
715
|
"data-slot": "dialog-description",
|
|
@@ -558,10 +720,10 @@ function DialogDescription({ className, ...props }) {
|
|
|
558
720
|
}
|
|
559
721
|
|
|
560
722
|
// src/modals/Iframe3ds.tsx
|
|
561
|
-
var
|
|
723
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
562
724
|
var Iframe3ds = import_nice_modal_react.default.create(({ url }) => {
|
|
563
725
|
const modal = (0, import_nice_modal_react.useModal)();
|
|
564
|
-
(0,
|
|
726
|
+
(0, import_react5.useEffect)(() => {
|
|
565
727
|
return bus.on("paymentIntent", (data) => {
|
|
566
728
|
modal.resolve(data.paymentIntent);
|
|
567
729
|
modal.remove();
|
|
@@ -571,9 +733,17 @@ var Iframe3ds = import_nice_modal_react.default.create(({ url }) => {
|
|
|
571
733
|
modal.reject();
|
|
572
734
|
modal.remove();
|
|
573
735
|
};
|
|
574
|
-
return /* @__PURE__ */ (0,
|
|
575
|
-
/* @__PURE__ */ (0,
|
|
576
|
-
/* @__PURE__ */ (0,
|
|
736
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(Dialog, { open: modal.visible, onOpenChange: handleClose, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(DialogContent, { className: "max-h-[600px] w-full max-w-[680px] p-0", children: [
|
|
737
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(DialogTitle, { className: "hidden", children: "Payment Verification" }),
|
|
738
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
739
|
+
"iframe",
|
|
740
|
+
{
|
|
741
|
+
src: url,
|
|
742
|
+
id: "3ds-iframe",
|
|
743
|
+
title: "Payment Verificatio",
|
|
744
|
+
className: "h-[731px] w-full rounded-lg border-0"
|
|
745
|
+
}
|
|
746
|
+
)
|
|
577
747
|
] }) });
|
|
578
748
|
});
|
|
579
749
|
Iframe3ds.displayName = "Iframe3ds";
|
|
@@ -687,6 +857,9 @@ var SlapiPaymentService = {
|
|
|
687
857
|
validate3DS: ({ paymentId }) => {
|
|
688
858
|
return slapiApi.post("/v1/payments/validate", { paymentId, type: "CREDIT_CARD" /* CREDIT_CARD */ }).then((data) => ({ data }));
|
|
689
859
|
},
|
|
860
|
+
validateCDC: ({ paymentId }) => {
|
|
861
|
+
return slapiApi.post("/v1/payments/validate", { paymentId, type: "CDC" /* CDC */ }).then((data) => ({ data }));
|
|
862
|
+
},
|
|
690
863
|
validatePoints: ({ paymentId, txHash }) => {
|
|
691
864
|
return slapiApi.post("/v1/payments/validate", { txHash, paymentId, type: "POINTS" /* POINTS */ }).then((data) => ({ data }));
|
|
692
865
|
},
|
|
@@ -1017,9 +1190,9 @@ var useSplitCardPayments = (mode = "web2") => {
|
|
|
1017
1190
|
};
|
|
1018
1191
|
|
|
1019
1192
|
// src/hooks/useCards.ts
|
|
1020
|
-
var
|
|
1193
|
+
var import_swr3 = __toESM(require("swr"), 1);
|
|
1021
1194
|
var useCards = () => {
|
|
1022
|
-
const { data, isLoading, mutate } = (0,
|
|
1195
|
+
const { data, isLoading, mutate } = (0, import_swr3.default)(`/v1/payments/cards`);
|
|
1023
1196
|
return {
|
|
1024
1197
|
cards: data?.data.filter((c) => c.active) || [],
|
|
1025
1198
|
cardsIsLoading: isLoading,
|
|
@@ -1027,20 +1200,13 @@ var useCards = () => {
|
|
|
1027
1200
|
};
|
|
1028
1201
|
};
|
|
1029
1202
|
|
|
1030
|
-
// src/hooks/useSlapiBalance.ts
|
|
1031
|
-
var import_swr3 = __toESM(require("swr"), 1);
|
|
1032
|
-
var useSlapiBalance = () => {
|
|
1033
|
-
const { data, isLoading, mutate } = (0, import_swr3.default)(`/v1/loyalty/accounts`);
|
|
1034
|
-
return { balance: data?.detail, isBalanceLoading: isLoading, mutateBalance: mutate };
|
|
1035
|
-
};
|
|
1036
|
-
|
|
1037
1203
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
1038
|
-
var
|
|
1204
|
+
var import_react7 = require("react");
|
|
1039
1205
|
var import_react_stripe_js2 = require("@stripe/react-stripe-js");
|
|
1040
1206
|
var import_stripe_js = require("@stripe/stripe-js");
|
|
1041
1207
|
|
|
1042
1208
|
// src/components/CreditCardTab/CreditCard/CardsList.tsx
|
|
1043
|
-
var
|
|
1209
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1044
1210
|
var isRemoveDisabled = true;
|
|
1045
1211
|
var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
1046
1212
|
const handleSelect = () => {
|
|
@@ -1050,7 +1216,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
1050
1216
|
e.stopPropagation();
|
|
1051
1217
|
if (isSelected || isRemoveDisabled) return;
|
|
1052
1218
|
};
|
|
1053
|
-
return /* @__PURE__ */ (0,
|
|
1219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1054
1220
|
"button",
|
|
1055
1221
|
{
|
|
1056
1222
|
type: "button",
|
|
@@ -1062,29 +1228,29 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
1062
1228
|
}
|
|
1063
1229
|
),
|
|
1064
1230
|
children: [
|
|
1065
|
-
/* @__PURE__ */ (0,
|
|
1231
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1066
1232
|
"div",
|
|
1067
1233
|
{
|
|
1068
1234
|
className: cn("flex h-full w-11 shrink-0 items-center justify-center border-r border-(--b-inverse)", {
|
|
1069
1235
|
"border-(--b-brand)": isSelected
|
|
1070
1236
|
}),
|
|
1071
|
-
children: /* @__PURE__ */ (0,
|
|
1237
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: isSelected && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) })
|
|
1072
1238
|
}
|
|
1073
1239
|
),
|
|
1074
|
-
/* @__PURE__ */ (0,
|
|
1240
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(
|
|
1075
1241
|
"div",
|
|
1076
1242
|
{
|
|
1077
1243
|
className: cn("flex h-full w-full items-center justify-between rounded-r-sm px-3", {
|
|
1078
1244
|
"border-(--primary)": isSelected
|
|
1079
1245
|
}),
|
|
1080
1246
|
children: [
|
|
1081
|
-
/* @__PURE__ */ (0,
|
|
1082
|
-
/* @__PURE__ */ (0,
|
|
1083
|
-
/* @__PURE__ */ (0,
|
|
1247
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { className: "text-sm font-medium text-(--brand-primary)", children: card.schema }) }),
|
|
1248
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1249
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("p", { className: "text-sm font-medium text-(--secondary)", children: [
|
|
1084
1250
|
"Ending in ",
|
|
1085
|
-
/* @__PURE__ */ (0,
|
|
1251
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("span", { className: "text-(--brand-primary)", children: card.lastFourNumbers })
|
|
1086
1252
|
] }),
|
|
1087
|
-
/* @__PURE__ */ (0,
|
|
1253
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1088
1254
|
"div",
|
|
1089
1255
|
{
|
|
1090
1256
|
onClick: handleRemoveCard,
|
|
@@ -1092,7 +1258,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
1092
1258
|
"cursor-not-allowed opacity-50": isSelected || isRemoveDisabled
|
|
1093
1259
|
// 'cursor-pointer': !isSelected || !isRemoveDisabled,
|
|
1094
1260
|
}),
|
|
1095
|
-
children: /* @__PURE__ */ (0,
|
|
1261
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "20", height: "20", fill: "currentColor", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1096
1262
|
"path",
|
|
1097
1263
|
{
|
|
1098
1264
|
fill: "currentColor",
|
|
@@ -1112,20 +1278,20 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
1112
1278
|
var CardsList = ({ selectedCard, setCard }) => {
|
|
1113
1279
|
const { cards, cardsIsLoading } = useCards();
|
|
1114
1280
|
if (cardsIsLoading) {
|
|
1115
|
-
return /* @__PURE__ */ (0,
|
|
1281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "h-11 animate-pulse rounded-sm bg-(--s-primary)" }) });
|
|
1116
1282
|
}
|
|
1117
1283
|
if (cards.length === 0) return null;
|
|
1118
|
-
return /* @__PURE__ */ (0,
|
|
1284
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex w-full flex-col gap-4", children: cards.map((card) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CardListItem, { isSelected: selectedCard?.id === card.id, onSelect: setCard, card }, card.id)) });
|
|
1119
1285
|
};
|
|
1120
1286
|
|
|
1121
1287
|
// src/components/CreditCardTab/CreditCard/CreditCardForm.tsx
|
|
1122
|
-
var
|
|
1288
|
+
var import_react6 = require("react");
|
|
1123
1289
|
var import_react_stripe_js = require("@stripe/react-stripe-js");
|
|
1124
1290
|
|
|
1125
1291
|
// src/ui/button.tsx
|
|
1126
1292
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
1127
1293
|
var import_class_variance_authority = require("class-variance-authority");
|
|
1128
|
-
var
|
|
1294
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1129
1295
|
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
1130
1296
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
1131
1297
|
{
|
|
@@ -1160,15 +1326,15 @@ function Button({
|
|
|
1160
1326
|
...props
|
|
1161
1327
|
}) {
|
|
1162
1328
|
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
1163
|
-
return /* @__PURE__ */ (0,
|
|
1329
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(Comp, { "data-slot": "button", className: cn(buttonVariants({ variant, size, className })), ...props });
|
|
1164
1330
|
}
|
|
1165
1331
|
|
|
1166
1332
|
// src/ui/checkbox.tsx
|
|
1167
1333
|
var CheckboxPrimitive = __toESM(require("@radix-ui/react-checkbox"), 1);
|
|
1168
1334
|
var import_lucide_react2 = require("lucide-react");
|
|
1169
|
-
var
|
|
1335
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1170
1336
|
function Checkbox({ className, ...props }) {
|
|
1171
|
-
return /* @__PURE__ */ (0,
|
|
1337
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1172
1338
|
CheckboxPrimitive.Root,
|
|
1173
1339
|
{
|
|
1174
1340
|
"data-slot": "checkbox",
|
|
@@ -1177,37 +1343,20 @@ function Checkbox({ className, ...props }) {
|
|
|
1177
1343
|
className
|
|
1178
1344
|
),
|
|
1179
1345
|
...props,
|
|
1180
|
-
children: /* @__PURE__ */ (0,
|
|
1346
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1181
1347
|
CheckboxPrimitive.Indicator,
|
|
1182
1348
|
{
|
|
1183
1349
|
"data-slot": "checkbox-indicator",
|
|
1184
1350
|
className: "flex items-center justify-center text-current transition-none",
|
|
1185
|
-
children: /* @__PURE__ */ (0,
|
|
1351
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(import_lucide_react2.CheckIcon, { className: "size-3.5 text-(--inverse)" })
|
|
1186
1352
|
}
|
|
1187
1353
|
)
|
|
1188
1354
|
}
|
|
1189
1355
|
);
|
|
1190
1356
|
}
|
|
1191
1357
|
|
|
1192
|
-
// src/ui/label.tsx
|
|
1193
|
-
var LabelPrimitive = __toESM(require("@radix-ui/react-label"), 1);
|
|
1194
|
-
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1195
|
-
function Label({ className, ...props }) {
|
|
1196
|
-
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1197
|
-
LabelPrimitive.Root,
|
|
1198
|
-
{
|
|
1199
|
-
"data-slot": "label",
|
|
1200
|
-
className: cn(
|
|
1201
|
-
"flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
|
|
1202
|
-
className
|
|
1203
|
-
),
|
|
1204
|
-
...props
|
|
1205
|
-
}
|
|
1206
|
-
);
|
|
1207
|
-
}
|
|
1208
|
-
|
|
1209
1358
|
// src/components/CreditCardTab/CreditCard/CreditCardForm.tsx
|
|
1210
|
-
var
|
|
1359
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
1211
1360
|
var styleDark = {
|
|
1212
1361
|
base: {
|
|
1213
1362
|
fontSize: "16px",
|
|
@@ -1240,11 +1389,11 @@ var stripeElementClasses = {
|
|
|
1240
1389
|
focus: "border-ring ring-ring/50 ring-2"
|
|
1241
1390
|
};
|
|
1242
1391
|
var CreditCardForm = ({ cancel, saveCard }) => {
|
|
1243
|
-
const [cardError, setCardError] = (0,
|
|
1392
|
+
const [cardError, setCardError] = (0, import_react6.useState)(void 0);
|
|
1244
1393
|
const { env } = useSpreePayEnv();
|
|
1245
1394
|
const elements = (0, import_react_stripe_js.useElements)();
|
|
1246
1395
|
const stripe = (0, import_react_stripe_js.useStripe)();
|
|
1247
|
-
const id = (0,
|
|
1396
|
+
const id = (0, import_react6.useId)();
|
|
1248
1397
|
const handleSaveCard = async () => {
|
|
1249
1398
|
if (!elements || !stripe) return;
|
|
1250
1399
|
setCardError(void 0);
|
|
@@ -1280,9 +1429,9 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
1280
1429
|
}
|
|
1281
1430
|
};
|
|
1282
1431
|
const isDarkMode = env.tenantId === "cdc";
|
|
1283
|
-
return /* @__PURE__ */ (0,
|
|
1284
|
-
/* @__PURE__ */ (0,
|
|
1285
|
-
/* @__PURE__ */ (0,
|
|
1432
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(import_jsx_runtime15.Fragment, { children: [
|
|
1433
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex w-full flex-col gap-4", children: [
|
|
1434
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1286
1435
|
import_react_stripe_js.CardNumberElement,
|
|
1287
1436
|
{
|
|
1288
1437
|
options: {
|
|
@@ -1292,8 +1441,8 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
1292
1441
|
}
|
|
1293
1442
|
}
|
|
1294
1443
|
),
|
|
1295
|
-
/* @__PURE__ */ (0,
|
|
1296
|
-
/* @__PURE__ */ (0,
|
|
1444
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex w-full gap-4", children: [
|
|
1445
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1297
1446
|
import_react_stripe_js.CardExpiryElement,
|
|
1298
1447
|
{
|
|
1299
1448
|
options: {
|
|
@@ -1303,7 +1452,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
1303
1452
|
}
|
|
1304
1453
|
}
|
|
1305
1454
|
),
|
|
1306
|
-
/* @__PURE__ */ (0,
|
|
1455
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1307
1456
|
import_react_stripe_js.CardCvcElement,
|
|
1308
1457
|
{
|
|
1309
1458
|
options: {
|
|
@@ -1314,14 +1463,14 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
1314
1463
|
}
|
|
1315
1464
|
)
|
|
1316
1465
|
] }),
|
|
1317
|
-
cardError && /* @__PURE__ */ (0,
|
|
1466
|
+
cardError && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("p", { className: "text-destructive mt-1 text-sm", children: cardError })
|
|
1318
1467
|
] }),
|
|
1319
|
-
/* @__PURE__ */ (0,
|
|
1320
|
-
/* @__PURE__ */ (0,
|
|
1321
|
-
/* @__PURE__ */ (0,
|
|
1468
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
1469
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Checkbox, { disabled: true, checked: true, id: "saveCard" }),
|
|
1470
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Label, { className: "text-sm font-medium", htmlFor: "saveCard", children: "Save card for future purchases" })
|
|
1322
1471
|
] }),
|
|
1323
|
-
/* @__PURE__ */ (0,
|
|
1324
|
-
/* @__PURE__ */ (0,
|
|
1472
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex w-full justify-end gap-2", children: [
|
|
1473
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1325
1474
|
Button,
|
|
1326
1475
|
{
|
|
1327
1476
|
variant: "outline",
|
|
@@ -1330,7 +1479,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
1330
1479
|
children: "Cancel"
|
|
1331
1480
|
}
|
|
1332
1481
|
),
|
|
1333
|
-
/* @__PURE__ */ (0,
|
|
1482
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1334
1483
|
Button,
|
|
1335
1484
|
{
|
|
1336
1485
|
className: "bg-(--s-brand) font-medium text-(--inverse) hover:bg-(--s-brand-hover)",
|
|
@@ -1343,13 +1492,13 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
1343
1492
|
};
|
|
1344
1493
|
|
|
1345
1494
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
1346
|
-
var
|
|
1495
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
1347
1496
|
var StripeWrapper = (props) => {
|
|
1348
|
-
const stripePromise = (0,
|
|
1349
|
-
return /* @__PURE__ */ (0,
|
|
1497
|
+
const stripePromise = (0, import_react7.useMemo)(() => (0, import_stripe_js.loadStripe)(props.publicKey), [props.publicKey]);
|
|
1498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_stripe_js2.Elements, { stripe: stripePromise, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CreditCardForm, { cancel: props.onCancel, saveCard: props.saveNewCard }) });
|
|
1350
1499
|
};
|
|
1351
1500
|
var CreditCard = () => {
|
|
1352
|
-
const [showForm, setShowForm] = (0,
|
|
1501
|
+
const [showForm, setShowForm] = (0, import_react7.useState)(false);
|
|
1353
1502
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
1354
1503
|
const { mutateCards } = useCards();
|
|
1355
1504
|
const { spreePayConfig } = useSpreePayConfig();
|
|
@@ -1364,17 +1513,18 @@ var CreditCard = () => {
|
|
|
1364
1513
|
const handleCancel = () => {
|
|
1365
1514
|
setShowForm(false);
|
|
1366
1515
|
};
|
|
1367
|
-
return /* @__PURE__ */ (0,
|
|
1368
|
-
/* @__PURE__ */ (0,
|
|
1369
|
-
!showForm && /* @__PURE__ */ (0,
|
|
1370
|
-
/* @__PURE__ */ (0,
|
|
1516
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
1517
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)("h3", { className: "text-[22px] leading-9 font-medium text-(--brand-primary)", children: "Your Cards" }),
|
|
1518
|
+
!showForm && /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
1519
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1371
1520
|
CardsList,
|
|
1372
1521
|
{
|
|
1373
1522
|
selectedCard: selectedPaymentMethod?.type === "CREDIT_CARD" /* CREDIT_CARD */ ? selectedPaymentMethod.method : null,
|
|
1374
1523
|
setCard
|
|
1375
1524
|
}
|
|
1376
1525
|
),
|
|
1377
|
-
/* @__PURE__ */ (0,
|
|
1526
|
+
spreePayConfig?.creditCard.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(InfoBanner, { message: spreePayConfig.creditCard.infoMessage }),
|
|
1527
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
1378
1528
|
"button",
|
|
1379
1529
|
{
|
|
1380
1530
|
onClick: () => setShowForm(true),
|
|
@@ -1384,94 +1534,13 @@ var CreditCard = () => {
|
|
|
1384
1534
|
}
|
|
1385
1535
|
)
|
|
1386
1536
|
] }),
|
|
1387
|
-
spreePayConfig?.stripePublicKey && showForm && /* @__PURE__ */ (0,
|
|
1537
|
+
spreePayConfig?.stripePublicKey && showForm && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(StripeWrapper, { onCancel: handleCancel, saveNewCard, publicKey: spreePayConfig.stripePublicKey })
|
|
1388
1538
|
] });
|
|
1389
1539
|
};
|
|
1390
1540
|
|
|
1391
1541
|
// src/components/CreditCardTab/Points/Points.tsx
|
|
1392
1542
|
var import_react12 = require("react");
|
|
1393
1543
|
|
|
1394
|
-
// src/components/common/PointsSwitch.tsx
|
|
1395
|
-
var import_react7 = require("react");
|
|
1396
|
-
|
|
1397
|
-
// src/ui/switch.tsx
|
|
1398
|
-
var SwitchPrimitive = __toESM(require("@radix-ui/react-switch"), 1);
|
|
1399
|
-
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
1400
|
-
function Switch({ className, ...props }) {
|
|
1401
|
-
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1402
|
-
SwitchPrimitive.Root,
|
|
1403
|
-
{
|
|
1404
|
-
"data-slot": "switch",
|
|
1405
|
-
className: cn(
|
|
1406
|
-
"peer focus-visible:border-ring focus-visible:ring-ring/50 inline-flex h-[1.15rem] w-8 shrink-0 items-center rounded-full border border-transparent shadow-xs transition-all outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-(--brand-primary) data-[state=unchecked]:bg-(--brand-primary)",
|
|
1407
|
-
className
|
|
1408
|
-
),
|
|
1409
|
-
...props,
|
|
1410
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
1411
|
-
SwitchPrimitive.Thumb,
|
|
1412
|
-
{
|
|
1413
|
-
"data-slot": "switch-thumb",
|
|
1414
|
-
className: "pointer-events-none block size-4 rounded-full bg-(--s-default) ring-0 transition-transform data-[state=checked]:translate-x-[calc(100%-2px)] data-[state=unchecked]:translate-x-0"
|
|
1415
|
-
}
|
|
1416
|
-
)
|
|
1417
|
-
}
|
|
1418
|
-
);
|
|
1419
|
-
}
|
|
1420
|
-
|
|
1421
|
-
// src/components/common/PointsSwitch.tsx
|
|
1422
|
-
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
1423
|
-
var PointsSwitch = (props) => {
|
|
1424
|
-
const { disabled = false, value, onChange, message } = props;
|
|
1425
|
-
const { spreePayConfig } = useSpreePayConfig();
|
|
1426
|
-
const { appProps } = useStaticConfig();
|
|
1427
|
-
const { balance } = useSlapiBalance();
|
|
1428
|
-
const id = (0, import_react7.useId)();
|
|
1429
|
-
return /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex flex-col gap-6", children: [
|
|
1430
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1431
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
1432
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Switch, { checked: value, onCheckedChange: onChange, disabled, id }),
|
|
1433
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)(
|
|
1434
|
-
Label,
|
|
1435
|
-
{
|
|
1436
|
-
htmlFor: id,
|
|
1437
|
-
className: "text-md flex-col items-baseline gap-0 leading-[1.3] font-medium text-(--brand-primary) sm:flex-row sm:gap-2 md:text-[22px]",
|
|
1438
|
-
children: [
|
|
1439
|
-
"Use Points ",
|
|
1440
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-xs font-medium text-(--tertiary)", children: "Optional" })
|
|
1441
|
-
]
|
|
1442
|
-
}
|
|
1443
|
-
)
|
|
1444
|
-
] }),
|
|
1445
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex items-center gap-2.5", children: [
|
|
1446
|
-
balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("p", { className: "flex-1 text-right text-sm font-medium text-(--brand-primary)", children: [
|
|
1447
|
-
formatPoints(balance.availablePoints, spreePayConfig?.pointsTitle),
|
|
1448
|
-
!!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)("span", { className: "text-(--secondary)", children: ` \xB7 ${formatUSD(balance.availablePoints * spreePayConfig.pointsConversionRatio)}` })
|
|
1449
|
-
] }) : null,
|
|
1450
|
-
Boolean(appProps.topUpLink) && /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1451
|
-
"a",
|
|
1452
|
-
{
|
|
1453
|
-
className: "cursor-pointer rounded-full bg-(--primary) px-2 py-1.5 text-xs font-medium text-(--inverse)",
|
|
1454
|
-
rel: "noreferrer",
|
|
1455
|
-
target: "_blank",
|
|
1456
|
-
href: appProps.topUpLink,
|
|
1457
|
-
children: "Top Up"
|
|
1458
|
-
}
|
|
1459
|
-
)
|
|
1460
|
-
] })
|
|
1461
|
-
] }),
|
|
1462
|
-
message && /* @__PURE__ */ (0, import_jsx_runtime14.jsxs)("div", { className: "flex gap-1 rounded-sm border border-(--accent)/20 bg-(--accent)/5 p-1.5", children: [
|
|
1463
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("svg", { className: "size-4 shrink-0", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(
|
|
1464
|
-
"path",
|
|
1465
|
-
{
|
|
1466
|
-
fill: "currentColor",
|
|
1467
|
-
d: "M9.6 13.8h.8V9.2h-.8zM10 8q.2 0 .4-.2l.1-.3-.1-.4L10 7l-.4.1-.1.4.1.3zm0 9.5a7 7 0 0 1-5.3-2.2 8 8 0 0 1-1.6-8.2 8 8 0 0 1 4-4q1.4-.6 2.9-.6a7 7 0 0 1 5.3 2.2 8 8 0 0 1 1.6 8.2 8 8 0 0 1-4 4q-1.4.6-2.9.6m0-.8q2.8 0 4.7-2 2-1.9 2-4.7t-2-4.7a6 6 0 0 0-4.7-2q-2.8 0-4.7 2a6 6 0 0 0-2 4.7q0 2.8 2 4.7 1.9 2 4.7 2"
|
|
1468
|
-
}
|
|
1469
|
-
) }),
|
|
1470
|
-
/* @__PURE__ */ (0, import_jsx_runtime14.jsx)("p", { className: "text-xs leading-4 font-medium text-(--brand-primary)", children: message })
|
|
1471
|
-
] })
|
|
1472
|
-
] });
|
|
1473
|
-
};
|
|
1474
|
-
|
|
1475
1544
|
// src/components/CreditCardTab/Points/SplitBlock.tsx
|
|
1476
1545
|
var import_react11 = require("react");
|
|
1477
1546
|
var import_airkit2 = require("@mocanetwork/airkit");
|
|
@@ -1480,9 +1549,9 @@ var import_airkit2 = require("@mocanetwork/airkit");
|
|
|
1480
1549
|
var import_react10 = require("react");
|
|
1481
1550
|
|
|
1482
1551
|
// src/ui/input.tsx
|
|
1483
|
-
var
|
|
1552
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
1484
1553
|
function Input({ className, type, ...props }) {
|
|
1485
|
-
return /* @__PURE__ */ (0,
|
|
1554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
1486
1555
|
"input",
|
|
1487
1556
|
{
|
|
1488
1557
|
type,
|
|
@@ -1559,7 +1628,7 @@ function useComposedRefs(...refs) {
|
|
|
1559
1628
|
|
|
1560
1629
|
// ../../node_modules/@radix-ui/react-context/dist/index.mjs
|
|
1561
1630
|
var React3 = __toESM(require("react"), 1);
|
|
1562
|
-
var
|
|
1631
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
1563
1632
|
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
1564
1633
|
let defaultContexts = [];
|
|
1565
1634
|
function createContext32(rootComponentName, defaultContext) {
|
|
@@ -1570,7 +1639,7 @@ function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
|
1570
1639
|
const { scope, children, ...context } = props;
|
|
1571
1640
|
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
1572
1641
|
const value = React3.useMemo(() => context, Object.values(context));
|
|
1573
|
-
return /* @__PURE__ */ (0,
|
|
1642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(Context.Provider, { value, children });
|
|
1574
1643
|
};
|
|
1575
1644
|
Provider.displayName = rootComponentName + "Provider";
|
|
1576
1645
|
function useContext22(consumerName, scope) {
|
|
@@ -1695,7 +1764,7 @@ function isFunction(value) {
|
|
|
1695
1764
|
|
|
1696
1765
|
// ../../node_modules/@radix-ui/react-direction/dist/index.mjs
|
|
1697
1766
|
var React6 = __toESM(require("react"), 1);
|
|
1698
|
-
var
|
|
1767
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
1699
1768
|
var DirectionContext = React6.createContext(void 0);
|
|
1700
1769
|
function useDirection(localDir) {
|
|
1701
1770
|
const globalDir = React6.useContext(DirectionContext);
|
|
@@ -1756,7 +1825,7 @@ function useSize(element) {
|
|
|
1756
1825
|
var React9 = __toESM(require("react"), 1);
|
|
1757
1826
|
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
1758
1827
|
var import_react_slot2 = require("@radix-ui/react-slot");
|
|
1759
|
-
var
|
|
1828
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
1760
1829
|
var NODES = [
|
|
1761
1830
|
"a",
|
|
1762
1831
|
"button",
|
|
@@ -1784,7 +1853,7 @@ var Primitive = NODES.reduce((primitive, node) => {
|
|
|
1784
1853
|
if (typeof window !== "undefined") {
|
|
1785
1854
|
window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
|
|
1786
1855
|
}
|
|
1787
|
-
return /* @__PURE__ */ (0,
|
|
1856
|
+
return /* @__PURE__ */ (0, import_jsx_runtime20.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
1788
1857
|
});
|
|
1789
1858
|
Node2.displayName = `Primitive.${node}`;
|
|
1790
1859
|
return { ...primitive, [node]: Node2 };
|
|
@@ -1793,10 +1862,10 @@ var Primitive = NODES.reduce((primitive, node) => {
|
|
|
1793
1862
|
// ../../node_modules/@radix-ui/react-collection/dist/index.mjs
|
|
1794
1863
|
var import_react8 = __toESM(require("react"), 1);
|
|
1795
1864
|
var import_react_slot3 = require("@radix-ui/react-slot");
|
|
1796
|
-
var
|
|
1865
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
1797
1866
|
var import_react9 = __toESM(require("react"), 1);
|
|
1798
1867
|
var import_react_slot4 = require("@radix-ui/react-slot");
|
|
1799
|
-
var
|
|
1868
|
+
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
1800
1869
|
function createCollection(name) {
|
|
1801
1870
|
const PROVIDER_NAME = name + "CollectionProvider";
|
|
1802
1871
|
const [createCollectionContext, createCollectionScope2] = createContextScope(PROVIDER_NAME);
|
|
@@ -1808,7 +1877,7 @@ function createCollection(name) {
|
|
|
1808
1877
|
const { scope, children } = props;
|
|
1809
1878
|
const ref = import_react8.default.useRef(null);
|
|
1810
1879
|
const itemMap = import_react8.default.useRef(/* @__PURE__ */ new Map()).current;
|
|
1811
|
-
return /* @__PURE__ */ (0,
|
|
1880
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
1812
1881
|
};
|
|
1813
1882
|
CollectionProvider.displayName = PROVIDER_NAME;
|
|
1814
1883
|
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
@@ -1818,7 +1887,7 @@ function createCollection(name) {
|
|
|
1818
1887
|
const { scope, children } = props;
|
|
1819
1888
|
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
1820
1889
|
const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
1821
|
-
return /* @__PURE__ */ (0,
|
|
1890
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CollectionSlotImpl, { ref: composedRefs, children });
|
|
1822
1891
|
}
|
|
1823
1892
|
);
|
|
1824
1893
|
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
@@ -1835,7 +1904,7 @@ function createCollection(name) {
|
|
|
1835
1904
|
context.itemMap.set(ref, { ref, ...itemData });
|
|
1836
1905
|
return () => void context.itemMap.delete(ref);
|
|
1837
1906
|
});
|
|
1838
|
-
return /* @__PURE__ */ (0,
|
|
1907
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CollectionItemSlotImpl, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
|
|
1839
1908
|
}
|
|
1840
1909
|
);
|
|
1841
1910
|
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
@@ -1861,7 +1930,7 @@ function createCollection(name) {
|
|
|
1861
1930
|
}
|
|
1862
1931
|
|
|
1863
1932
|
// ../../node_modules/@radix-ui/react-slider/dist/index.mjs
|
|
1864
|
-
var
|
|
1933
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
1865
1934
|
var PAGE_KEYS = ["PageUp", "PageDown"];
|
|
1866
1935
|
var ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
|
|
1867
1936
|
var BACK_KEYS = {
|
|
@@ -1939,7 +2008,7 @@ var Slider = React11.forwardRef(
|
|
|
1939
2008
|
}
|
|
1940
2009
|
});
|
|
1941
2010
|
}
|
|
1942
|
-
return /* @__PURE__ */ (0,
|
|
2011
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1943
2012
|
SliderProvider,
|
|
1944
2013
|
{
|
|
1945
2014
|
scope: props.__scopeSlider,
|
|
@@ -1952,7 +2021,7 @@ var Slider = React11.forwardRef(
|
|
|
1952
2021
|
values,
|
|
1953
2022
|
orientation,
|
|
1954
2023
|
form,
|
|
1955
|
-
children: /* @__PURE__ */ (0,
|
|
2024
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Collection.Provider, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Collection.Slot, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
1956
2025
|
SliderOrientation,
|
|
1957
2026
|
{
|
|
1958
2027
|
"aria-disabled": disabled,
|
|
@@ -2021,7 +2090,7 @@ var SliderHorizontal = React11.forwardRef(
|
|
|
2021
2090
|
rectRef.current = rect;
|
|
2022
2091
|
return value(pointerPosition - rect.left);
|
|
2023
2092
|
}
|
|
2024
|
-
return /* @__PURE__ */ (0,
|
|
2093
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2025
2094
|
SliderOrientationProvider,
|
|
2026
2095
|
{
|
|
2027
2096
|
scope: props.__scopeSlider,
|
|
@@ -2029,7 +2098,7 @@ var SliderHorizontal = React11.forwardRef(
|
|
|
2029
2098
|
endEdge: isSlidingFromLeft ? "right" : "left",
|
|
2030
2099
|
direction: isSlidingFromLeft ? 1 : -1,
|
|
2031
2100
|
size: "width",
|
|
2032
|
-
children: /* @__PURE__ */ (0,
|
|
2101
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2033
2102
|
SliderImpl,
|
|
2034
2103
|
{
|
|
2035
2104
|
dir: direction,
|
|
@@ -2087,7 +2156,7 @@ var SliderVertical = React11.forwardRef(
|
|
|
2087
2156
|
rectRef.current = rect;
|
|
2088
2157
|
return value(pointerPosition - rect.top);
|
|
2089
2158
|
}
|
|
2090
|
-
return /* @__PURE__ */ (0,
|
|
2159
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2091
2160
|
SliderOrientationProvider,
|
|
2092
2161
|
{
|
|
2093
2162
|
scope: props.__scopeSlider,
|
|
@@ -2095,7 +2164,7 @@ var SliderVertical = React11.forwardRef(
|
|
|
2095
2164
|
endEdge: isSlidingFromBottom ? "top" : "bottom",
|
|
2096
2165
|
size: "height",
|
|
2097
2166
|
direction: isSlidingFromBottom ? 1 : -1,
|
|
2098
|
-
children: /* @__PURE__ */ (0,
|
|
2167
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2099
2168
|
SliderImpl,
|
|
2100
2169
|
{
|
|
2101
2170
|
"data-orientation": "vertical",
|
|
@@ -2141,7 +2210,7 @@ var SliderImpl = React11.forwardRef(
|
|
|
2141
2210
|
...sliderProps
|
|
2142
2211
|
} = props;
|
|
2143
2212
|
const context = useSliderContext(SLIDER_NAME, __scopeSlider);
|
|
2144
|
-
return /* @__PURE__ */ (0,
|
|
2213
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2145
2214
|
Primitive.span,
|
|
2146
2215
|
{
|
|
2147
2216
|
...sliderProps,
|
|
@@ -2188,7 +2257,7 @@ var SliderTrack = React11.forwardRef(
|
|
|
2188
2257
|
(props, forwardedRef) => {
|
|
2189
2258
|
const { __scopeSlider, ...trackProps } = props;
|
|
2190
2259
|
const context = useSliderContext(TRACK_NAME, __scopeSlider);
|
|
2191
|
-
return /* @__PURE__ */ (0,
|
|
2260
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2192
2261
|
Primitive.span,
|
|
2193
2262
|
{
|
|
2194
2263
|
"data-disabled": context.disabled ? "" : void 0,
|
|
@@ -2214,7 +2283,7 @@ var SliderRange = React11.forwardRef(
|
|
|
2214
2283
|
);
|
|
2215
2284
|
const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0;
|
|
2216
2285
|
const offsetEnd = 100 - Math.max(...percentages);
|
|
2217
|
-
return /* @__PURE__ */ (0,
|
|
2286
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2218
2287
|
Primitive.span,
|
|
2219
2288
|
{
|
|
2220
2289
|
"data-orientation": context.orientation,
|
|
@@ -2241,7 +2310,7 @@ var SliderThumb = React11.forwardRef(
|
|
|
2241
2310
|
() => thumb ? getItems().findIndex((item) => item.ref.current === thumb) : -1,
|
|
2242
2311
|
[getItems, thumb]
|
|
2243
2312
|
);
|
|
2244
|
-
return /* @__PURE__ */ (0,
|
|
2313
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(SliderThumbImpl, { ...props, ref: composedRefs, index });
|
|
2245
2314
|
}
|
|
2246
2315
|
);
|
|
2247
2316
|
var SliderThumbImpl = React11.forwardRef(
|
|
@@ -2266,7 +2335,7 @@ var SliderThumbImpl = React11.forwardRef(
|
|
|
2266
2335
|
};
|
|
2267
2336
|
}
|
|
2268
2337
|
}, [thumb, context.thumbs]);
|
|
2269
|
-
return /* @__PURE__ */ (0,
|
|
2338
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsxs)(
|
|
2270
2339
|
"span",
|
|
2271
2340
|
{
|
|
2272
2341
|
style: {
|
|
@@ -2275,7 +2344,7 @@ var SliderThumbImpl = React11.forwardRef(
|
|
|
2275
2344
|
[orientation.startEdge]: `calc(${percent}% + ${thumbInBoundsOffset}px)`
|
|
2276
2345
|
},
|
|
2277
2346
|
children: [
|
|
2278
|
-
/* @__PURE__ */ (0,
|
|
2347
|
+
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(Collection.ItemSlot, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2279
2348
|
Primitive.span,
|
|
2280
2349
|
{
|
|
2281
2350
|
role: "slider",
|
|
@@ -2295,7 +2364,7 @@ var SliderThumbImpl = React11.forwardRef(
|
|
|
2295
2364
|
})
|
|
2296
2365
|
}
|
|
2297
2366
|
) }),
|
|
2298
|
-
isFormControl && /* @__PURE__ */ (0,
|
|
2367
|
+
isFormControl && /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2299
2368
|
SliderBubbleInput,
|
|
2300
2369
|
{
|
|
2301
2370
|
name: name ?? (context.name ? context.name + (context.values.length > 1 ? "[]" : "") : void 0),
|
|
@@ -2328,7 +2397,7 @@ var SliderBubbleInput = React11.forwardRef(
|
|
|
2328
2397
|
input.dispatchEvent(event);
|
|
2329
2398
|
}
|
|
2330
2399
|
}, [prevValue, value]);
|
|
2331
|
-
return /* @__PURE__ */ (0,
|
|
2400
|
+
return /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2332
2401
|
Primitive.input,
|
|
2333
2402
|
{
|
|
2334
2403
|
style: { display: "none" },
|
|
@@ -2410,14 +2479,14 @@ function cn2(...inputs) {
|
|
|
2410
2479
|
}
|
|
2411
2480
|
|
|
2412
2481
|
// src/ui/slider.tsx
|
|
2413
|
-
var
|
|
2482
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
2414
2483
|
function Slider2(props) {
|
|
2415
2484
|
const { className, defaultValue, value, min = 0, max = 100, ...rest } = props;
|
|
2416
2485
|
const _values = React12.useMemo(
|
|
2417
2486
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
2418
2487
|
[value, defaultValue, min, max]
|
|
2419
2488
|
);
|
|
2420
|
-
return /* @__PURE__ */ (0,
|
|
2489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
2421
2490
|
Root5,
|
|
2422
2491
|
{
|
|
2423
2492
|
"data-slot": "slider",
|
|
@@ -2431,14 +2500,14 @@ function Slider2(props) {
|
|
|
2431
2500
|
),
|
|
2432
2501
|
...rest,
|
|
2433
2502
|
children: [
|
|
2434
|
-
/* @__PURE__ */ (0,
|
|
2503
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2435
2504
|
Track,
|
|
2436
2505
|
{
|
|
2437
2506
|
"data-slot": "slider-track",
|
|
2438
2507
|
className: cn2(
|
|
2439
2508
|
"relative grow overflow-hidden rounded-full bg-(--primary)/15 data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
|
|
2440
2509
|
),
|
|
2441
|
-
children: /* @__PURE__ */ (0,
|
|
2510
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2442
2511
|
Range,
|
|
2443
2512
|
{
|
|
2444
2513
|
"data-slot": "slider-range",
|
|
@@ -2449,7 +2518,7 @@ function Slider2(props) {
|
|
|
2449
2518
|
)
|
|
2450
2519
|
}
|
|
2451
2520
|
),
|
|
2452
|
-
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0,
|
|
2521
|
+
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2453
2522
|
Thumb2,
|
|
2454
2523
|
{
|
|
2455
2524
|
"data-slot": "slider-thumb",
|
|
@@ -2463,7 +2532,7 @@ function Slider2(props) {
|
|
|
2463
2532
|
}
|
|
2464
2533
|
|
|
2465
2534
|
// src/components/CreditCardTab/Points/PointsSelector.tsx
|
|
2466
|
-
var
|
|
2535
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
2467
2536
|
var PointsSelector = (props) => {
|
|
2468
2537
|
const { isDisabled, isSelected, onSelect, children } = props;
|
|
2469
2538
|
const { balance } = useSlapiBalance();
|
|
@@ -2482,18 +2551,20 @@ var PointsSelector = (props) => {
|
|
|
2482
2551
|
};
|
|
2483
2552
|
const pointsValue = String(Math.round(splitTokens));
|
|
2484
2553
|
const usdValue = formatUSD(usdAmount + getTransactionFee(usdAmount, appProps.transactionFeePercentage));
|
|
2485
|
-
return /* @__PURE__ */ (0,
|
|
2554
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
2486
2555
|
"button",
|
|
2487
2556
|
{
|
|
2488
2557
|
disabled: isDisabled,
|
|
2489
2558
|
onClick: onSelect,
|
|
2490
|
-
className: cn(
|
|
2491
|
-
"border-
|
|
2492
|
-
|
|
2493
|
-
|
|
2559
|
+
className: cn(
|
|
2560
|
+
"cursor-pointer overflow-hidden rounded-md border-2 border-transparent opacity-50 disabled:cursor-not-allowed",
|
|
2561
|
+
{
|
|
2562
|
+
"border-(--b-brand)": isSelected
|
|
2563
|
+
}
|
|
2564
|
+
),
|
|
2494
2565
|
children: [
|
|
2495
|
-
/* @__PURE__ */ (0,
|
|
2496
|
-
/* @__PURE__ */ (0,
|
|
2566
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex h-11 w-full bg-(--s-primary) hover:bg-(--s-primary-hover)", children: [
|
|
2567
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2497
2568
|
"div",
|
|
2498
2569
|
{
|
|
2499
2570
|
className: cn(
|
|
@@ -2502,14 +2573,14 @@ var PointsSelector = (props) => {
|
|
|
2502
2573
|
"border-(--b-brand)": isSelected
|
|
2503
2574
|
}
|
|
2504
2575
|
),
|
|
2505
|
-
children: /* @__PURE__ */ (0,
|
|
2576
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: isSelected && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) })
|
|
2506
2577
|
}
|
|
2507
2578
|
),
|
|
2508
|
-
/* @__PURE__ */ (0,
|
|
2579
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex h-full w-full items-center justify-between gap-2 px-2 sm:gap-3 sm:px-3", children })
|
|
2509
2580
|
] }),
|
|
2510
|
-
isSelected && /* @__PURE__ */ (0,
|
|
2511
|
-
/* @__PURE__ */ (0,
|
|
2512
|
-
/* @__PURE__ */ (0,
|
|
2581
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "px-2 pt-5 pb-2 sm:px-3 md:px-4", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex justify-between gap-2 sm:gap-3", children: [
|
|
2582
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
2583
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2513
2584
|
Input,
|
|
2514
2585
|
{
|
|
2515
2586
|
readOnly: true,
|
|
@@ -2520,9 +2591,9 @@ var PointsSelector = (props) => {
|
|
|
2520
2591
|
onClick: (e) => e.stopPropagation()
|
|
2521
2592
|
}
|
|
2522
2593
|
),
|
|
2523
|
-
/* @__PURE__ */ (0,
|
|
2594
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-left text-xs leading-5 text-(--tertiary)", children: "Points" })
|
|
2524
2595
|
] }),
|
|
2525
|
-
/* @__PURE__ */ (0,
|
|
2596
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex w-full items-center pb-6", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2526
2597
|
Slider2,
|
|
2527
2598
|
{
|
|
2528
2599
|
value: [splitTokens],
|
|
@@ -2534,8 +2605,8 @@ var PointsSelector = (props) => {
|
|
|
2534
2605
|
step
|
|
2535
2606
|
}
|
|
2536
2607
|
) }),
|
|
2537
|
-
/* @__PURE__ */ (0,
|
|
2538
|
-
/* @__PURE__ */ (0,
|
|
2608
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
2609
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
2539
2610
|
Input,
|
|
2540
2611
|
{
|
|
2541
2612
|
readOnly: true,
|
|
@@ -2546,7 +2617,7 @@ var PointsSelector = (props) => {
|
|
|
2546
2617
|
onClick: (e) => e.stopPropagation()
|
|
2547
2618
|
}
|
|
2548
2619
|
),
|
|
2549
|
-
/* @__PURE__ */ (0,
|
|
2620
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("p", { className: "text-left text-xs leading-5 text-(--tertiary)", children: "Card" })
|
|
2550
2621
|
] })
|
|
2551
2622
|
] }) })
|
|
2552
2623
|
]
|
|
@@ -2555,7 +2626,7 @@ var PointsSelector = (props) => {
|
|
|
2555
2626
|
};
|
|
2556
2627
|
|
|
2557
2628
|
// src/components/CreditCardTab/Points/SplitBlock.tsx
|
|
2558
|
-
var
|
|
2629
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
2559
2630
|
var SplitBlock = (props) => {
|
|
2560
2631
|
const { onToggle, isSelected, onSelect } = props;
|
|
2561
2632
|
const { balance, isBalanceLoading } = useSlapiBalance();
|
|
@@ -2599,21 +2670,21 @@ var SplitBlock = (props) => {
|
|
|
2599
2670
|
doInit();
|
|
2600
2671
|
}, [spreePayConfig?.pointsChain, initWallet, env.useWeb3Points]);
|
|
2601
2672
|
const isPointsSelectorDisabled = env.useWeb3Points ? !walletReady : false;
|
|
2602
|
-
return /* @__PURE__ */ (0,
|
|
2603
|
-
/* @__PURE__ */ (0,
|
|
2604
|
-
/* @__PURE__ */ (0,
|
|
2673
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(PointsSelector, { isDisabled: isPointsSelectorDisabled, onSelect: () => onSelect("air"), isSelected, children: [
|
|
2674
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("p", { className: "text-left text-xs font-medium text-(--brand-primary) sm:text-sm", children: [
|
|
2675
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-(--secondary)", children: "Available" }),
|
|
2605
2676
|
" ",
|
|
2606
2677
|
formatPoints(balance.availablePoints, pointsTitle),
|
|
2607
2678
|
" ",
|
|
2608
|
-
pointsConversionRatio && /* @__PURE__ */ (0,
|
|
2679
|
+
pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("span", { className: "text-(--secondary)", children: formatUSD(balance.availablePoints * pointsConversionRatio) })
|
|
2609
2680
|
] }) : null }),
|
|
2610
|
-
isBalanceLoading ? /* @__PURE__ */ (0,
|
|
2611
|
-
address && /* @__PURE__ */ (0,
|
|
2681
|
+
isBalanceLoading ? /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "h-4 w-6 animate-pulse bg-(--s-secondary)" }) : !balance?.availablePoints && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-sm font-medium text-(--brand-primary)", children: "No points available" }),
|
|
2682
|
+
address && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "text-sm font-medium text-(--brand-primary)", children: address.length > 8 ? `${address.slice(0, 4)}...${address.slice(-4)}` : address })
|
|
2612
2683
|
] }) });
|
|
2613
2684
|
};
|
|
2614
2685
|
|
|
2615
2686
|
// src/components/CreditCardTab/Points/Points.tsx
|
|
2616
|
-
var
|
|
2687
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2617
2688
|
var Points = () => {
|
|
2618
2689
|
const [usePoints, setUsePoints] = (0, import_react12.useState)(false);
|
|
2619
2690
|
const [selectedPointsType, setSelectedPointsType] = (0, import_react12.useState)(null);
|
|
@@ -2627,8 +2698,8 @@ var Points = () => {
|
|
|
2627
2698
|
setSelectedPaymentMethod({ ...selectedPaymentMethod, splitAmount: void 0 });
|
|
2628
2699
|
}
|
|
2629
2700
|
};
|
|
2630
|
-
return /* @__PURE__ */ (0,
|
|
2631
|
-
/* @__PURE__ */ (0,
|
|
2701
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(import_jsx_runtime27.Fragment, { children: [
|
|
2702
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2632
2703
|
PointsSwitch,
|
|
2633
2704
|
{
|
|
2634
2705
|
value: usePoints,
|
|
@@ -2637,7 +2708,7 @@ var Points = () => {
|
|
|
2637
2708
|
disabled: !spreePayConfig?.creditCard.enabled || !spreePayConfig?.creditCard.points || appProps.disabledPoints
|
|
2638
2709
|
}
|
|
2639
2710
|
),
|
|
2640
|
-
usePoints && /* @__PURE__ */ (0,
|
|
2711
|
+
usePoints && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(
|
|
2641
2712
|
SplitBlock,
|
|
2642
2713
|
{
|
|
2643
2714
|
onToggle: handleTogglePoints,
|
|
@@ -2649,7 +2720,7 @@ var Points = () => {
|
|
|
2649
2720
|
};
|
|
2650
2721
|
|
|
2651
2722
|
// src/components/CreditCardTab/CreditCardTab.tsx
|
|
2652
|
-
var
|
|
2723
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
2653
2724
|
var CreditCardTab = () => {
|
|
2654
2725
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
2655
2726
|
const { env } = useSpreePayEnv();
|
|
@@ -2704,23 +2775,157 @@ var CreditCardTab = () => {
|
|
|
2704
2775
|
(0, import_react13.useEffect)(() => {
|
|
2705
2776
|
register(handlePay);
|
|
2706
2777
|
}, [register, handlePay]);
|
|
2707
|
-
return /* @__PURE__ */ (0,
|
|
2708
|
-
/* @__PURE__ */ (0,
|
|
2709
|
-
/* @__PURE__ */ (0,
|
|
2778
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { children: [
|
|
2779
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "border-b border-b-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CreditCard, {}) }),
|
|
2780
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)("div", { className: "flex flex-col gap-4 border-b border-b-(--border-component-specific-card) px-5 pt-5 pb-5 md:px-7 md:pt-6 md:pb-7", children: /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(Points, {}) })
|
|
2781
|
+
] });
|
|
2782
|
+
};
|
|
2783
|
+
|
|
2784
|
+
// src/components/CryptoComTab/CryptoComTab.tsx
|
|
2785
|
+
var import_react14 = require("react");
|
|
2786
|
+
|
|
2787
|
+
// src/hooks/payments/useCryptoComPayment.ts
|
|
2788
|
+
var import_nice_modal_react5 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
2789
|
+
var useCryptoComPayment = () => {
|
|
2790
|
+
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
2791
|
+
const { env } = useSpreePayEnv();
|
|
2792
|
+
const cryptoComPayment = async (params) => {
|
|
2793
|
+
if (selectedPaymentMethod.type !== "CDC" /* CDC */) {
|
|
2794
|
+
throw new Error("Unsupported payment method");
|
|
2795
|
+
}
|
|
2796
|
+
const { hash, metadata } = params;
|
|
2797
|
+
const { data: paymentResData } = await SlapiPaymentService.createPayment({
|
|
2798
|
+
hash,
|
|
2799
|
+
metadata,
|
|
2800
|
+
type: "CDC" /* CDC */,
|
|
2801
|
+
cdc: {
|
|
2802
|
+
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${env.redirect3dsURI}?payment_intent=success`,
|
|
2803
|
+
cancelUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${env.redirect3dsURI}?payment_intent=canceled`
|
|
2804
|
+
}
|
|
2805
|
+
});
|
|
2806
|
+
let { status } = paymentResData;
|
|
2807
|
+
if (paymentResData.redirectUrl) {
|
|
2808
|
+
const paymentIntent = await import_nice_modal_react5.default.show(Iframe3ds, { url: paymentResData.redirectUrl });
|
|
2809
|
+
if (paymentIntent === "success") {
|
|
2810
|
+
const { data: validateData } = await SlapiPaymentService.validateCDC({ paymentId: paymentResData.id });
|
|
2811
|
+
({ status } = validateData);
|
|
2812
|
+
} else {
|
|
2813
|
+
status = "FAILED" /* FAILED */;
|
|
2814
|
+
}
|
|
2815
|
+
}
|
|
2816
|
+
return {
|
|
2817
|
+
status,
|
|
2818
|
+
paymentType: "CDC" /* CDC */,
|
|
2819
|
+
paymentId: paymentResData.id,
|
|
2820
|
+
txId: paymentResData.txId,
|
|
2821
|
+
txHash: null
|
|
2822
|
+
};
|
|
2823
|
+
};
|
|
2824
|
+
return { cryptoComPayment };
|
|
2825
|
+
};
|
|
2826
|
+
|
|
2827
|
+
// src/components/CryptoComTab/Checkout.tsx
|
|
2828
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
2829
|
+
var Checkout = () => {
|
|
2830
|
+
const { appProps } = useStaticConfig();
|
|
2831
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2832
|
+
"button",
|
|
2833
|
+
{
|
|
2834
|
+
onClick: appProps.onProcess,
|
|
2835
|
+
disabled: appProps.isProcessing,
|
|
2836
|
+
className: "flex flex-col items-center rounded-md bg-[#00307D] p-2 text-(--brand-primary) hover:bg-[#002655] disabled:cursor-not-allowed disabled:bg-[#002655] disabled:text-(--disabled)",
|
|
2837
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "76", height: "28", fill: "none", viewBox: "0 0 76 28", children: [
|
|
2838
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2839
|
+
"path",
|
|
2840
|
+
{
|
|
2841
|
+
fill: "currentColor",
|
|
2842
|
+
fillRule: "evenodd",
|
|
2843
|
+
d: "M47.42 9.06c0 4.02-3.25 6.09-7.1 6.09h-4.38v6.53h-2.03V3.16h6.75c4.08 0 6.76 2.22 6.76 5.9m-2.06.08c0-2.68-1.94-4.05-4.85-4.05h-4.57v8.15h4.47c2.99 0 4.95-1.64 4.95-4.1m9.28.47c-1.57 0-2.81.43-4.05 1.01L50 8.95a11 11 0 0 1 4.86-1.14c3.63 0 5.67 1.9 5.67 5.5v8.37h-1.9v-2.06a5.8 5.8 0 0 1-4.83 2.35c-2.48 0-4.98-1.43-4.98-4.28 0-2.92 2.32-4.45 5.7-4.45 1.7 0 2.92.24 4.1.58v-.47c0-2.47-1.47-3.74-3.97-3.74m.08 5.14c1.62 0 2.94.29 3.92.58v1.32c0 2.17-2.01 3.71-4.46 3.71-1.8 0-3.36-1-3.36-2.75s1.4-2.86 3.9-2.86m12.23 11.8 1.75-4.7-6.14-13.8h2.2l4.84 11.4 4.28-11.4H76l-7.32 18.5z",
|
|
2844
|
+
clipRule: "evenodd"
|
|
2845
|
+
}
|
|
2846
|
+
),
|
|
2847
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2848
|
+
"path",
|
|
2849
|
+
{
|
|
2850
|
+
fill: "currentColor",
|
|
2851
|
+
fillRule: "evenodd",
|
|
2852
|
+
d: "M0 6.77V20.3l11.66 6.77 11.66-6.77V6.77L11.66 0zM1.03 19.7V7.36L11.66 1.2 22.3 7.36v12.35l-10.64 6.17z",
|
|
2853
|
+
clipRule: "evenodd"
|
|
2854
|
+
}
|
|
2855
|
+
),
|
|
2856
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2857
|
+
"path",
|
|
2858
|
+
{
|
|
2859
|
+
fill: "currentColor",
|
|
2860
|
+
fillRule: "evenodd",
|
|
2861
|
+
d: "M16.23 5.84H7.07L6 10.54h11.33zM8.7 17v-3.12l-2.72-1.73-3.07 2.3 4.19 7.31h1.67l1.98-1.85v-.93z",
|
|
2862
|
+
clipRule: "evenodd"
|
|
2863
|
+
}
|
|
2864
|
+
),
|
|
2865
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2866
|
+
"path",
|
|
2867
|
+
{
|
|
2868
|
+
fill: "currentColor",
|
|
2869
|
+
fillRule: "evenodd",
|
|
2870
|
+
d: "M14.64 11.25H8.7l1 2.62-.3 2.94h4.54l-.28-2.94z",
|
|
2871
|
+
clipRule: "evenodd"
|
|
2872
|
+
}
|
|
2873
|
+
),
|
|
2874
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(
|
|
2875
|
+
"path",
|
|
2876
|
+
{
|
|
2877
|
+
fill: "currentColor",
|
|
2878
|
+
fillRule: "evenodd",
|
|
2879
|
+
d: "m17.35 12.13-2.68 1.75V17l-2.05 1.98v.93l1.98 1.83h1.65l4.16-7.3z",
|
|
2880
|
+
clipRule: "evenodd"
|
|
2881
|
+
}
|
|
2882
|
+
)
|
|
2883
|
+
] })
|
|
2884
|
+
}
|
|
2885
|
+
);
|
|
2886
|
+
};
|
|
2887
|
+
|
|
2888
|
+
// src/components/CryptoComTab/CryptoComTab.tsx
|
|
2889
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
2890
|
+
var CryptoComTab = () => {
|
|
2891
|
+
const { register } = useSpreePayRegister();
|
|
2892
|
+
const { cryptoComPayment } = useCryptoComPayment();
|
|
2893
|
+
const { spreePayConfig } = useSpreePayConfig();
|
|
2894
|
+
const handlePay = (0, import_react14.useCallback)(
|
|
2895
|
+
async (data) => {
|
|
2896
|
+
try {
|
|
2897
|
+
const res = await cryptoComPayment(data);
|
|
2898
|
+
if (["AUTHORIZED" /* AUTHORIZED */, "CAPTURED" /* CAPTURED */].includes(res.status)) {
|
|
2899
|
+
return Promise.resolve(res);
|
|
2900
|
+
}
|
|
2901
|
+
return Promise.reject(new PaymentError("Crypto payment failed", res.status));
|
|
2902
|
+
} catch (_) {
|
|
2903
|
+
return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
|
|
2904
|
+
}
|
|
2905
|
+
},
|
|
2906
|
+
[cryptoComPayment]
|
|
2907
|
+
);
|
|
2908
|
+
(0, import_react14.useEffect)(() => {
|
|
2909
|
+
register(handlePay);
|
|
2910
|
+
}, [register, handlePay]);
|
|
2911
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex w-full flex-col gap-4 border-b border-b-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: [
|
|
2912
|
+
spreePayConfig?.cryptoCom.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(InfoBanner, { message: spreePayConfig.cryptoCom.infoMessage }),
|
|
2913
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Legal, {}),
|
|
2914
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(Checkout, {})
|
|
2710
2915
|
] });
|
|
2711
2916
|
};
|
|
2712
2917
|
|
|
2713
2918
|
// src/components/CryptoTab/Crypto/CryptoWrapper.tsx
|
|
2714
|
-
var
|
|
2919
|
+
var import_react17 = require("react");
|
|
2715
2920
|
var import_react_query = require("@tanstack/react-query");
|
|
2716
|
-
var
|
|
2921
|
+
var import_nice_modal_react8 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
2717
2922
|
var import_rainbowkit2 = require("@rainbow-me/rainbowkit");
|
|
2718
2923
|
var import_styles = require("@rainbow-me/rainbowkit/styles.css");
|
|
2719
2924
|
var import_wagmi5 = require("wagmi");
|
|
2720
2925
|
var import_chains = require("wagmi/chains");
|
|
2721
2926
|
|
|
2722
2927
|
// src/components/CryptoTab/Crypto/Crypto.tsx
|
|
2723
|
-
var
|
|
2928
|
+
var import_react16 = require("react");
|
|
2724
2929
|
var import_wagmi4 = require("wagmi");
|
|
2725
2930
|
|
|
2726
2931
|
// ../../node_modules/@wagmi/core/dist/esm/utils/getAction.js
|
|
@@ -2895,70 +3100,50 @@ var useCryptoPayment = () => {
|
|
|
2895
3100
|
|
|
2896
3101
|
// src/components/CryptoTab/Crypto/ConnectButton.tsx
|
|
2897
3102
|
var import_rainbowkit = require("@rainbow-me/rainbowkit");
|
|
2898
|
-
var
|
|
3103
|
+
var import_jsx_runtime31 = require("react/jsx-runtime");
|
|
2899
3104
|
var ConnectButton = () => {
|
|
2900
|
-
|
|
3105
|
+
const buttonCN = "h-9 rounded-full border border-(--b-brand) px-4 text-sm font-medium text-(--brand-primary)";
|
|
3106
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_rainbowkit.ConnectButton.Custom, { children: ({ mounted, chain, account, openAccountModal, openChainModal, openConnectModal }) => {
|
|
2901
3107
|
if (!mounted) return null;
|
|
2902
|
-
return /* @__PURE__ */ (0,
|
|
3108
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children: (() => {
|
|
2903
3109
|
if (!mounted || !account || !chain) {
|
|
2904
|
-
return /* @__PURE__ */ (0,
|
|
2905
|
-
"button",
|
|
2906
|
-
{
|
|
2907
|
-
className: "h-[34px] rounded-md border border-(--b-strong) px-3 text-sm font-medium text-(--brand-primary)",
|
|
2908
|
-
onClick: openConnectModal,
|
|
2909
|
-
children: "Connect a Wallet"
|
|
2910
|
-
}
|
|
2911
|
-
);
|
|
3110
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { className: buttonCN, onClick: openConnectModal, children: "Connect wallet" });
|
|
2912
3111
|
}
|
|
2913
3112
|
if (chain.unsupported) {
|
|
2914
|
-
return /* @__PURE__ */ (0,
|
|
2915
|
-
"button",
|
|
2916
|
-
{
|
|
2917
|
-
className: "h-[34px] rounded-md border border-(--b-strong) px-3 text-sm font-medium text-(--brand-primary)",
|
|
2918
|
-
onClick: openChainModal,
|
|
2919
|
-
children: "Select a Network"
|
|
2920
|
-
}
|
|
2921
|
-
);
|
|
3113
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { className: buttonCN, onClick: openChainModal, children: "Select a Network" });
|
|
2922
3114
|
}
|
|
2923
|
-
return /* @__PURE__ */ (0,
|
|
2924
|
-
"
|
|
2925
|
-
|
|
2926
|
-
|
|
2927
|
-
onClick: openAccountModal,
|
|
2928
|
-
children: [
|
|
2929
|
-
chain.hasIcon && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "size-6 overflow-hidden rounded-full", style: { background: chain.iconBackground }, children: chain.iconUrl && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("img", { alt: chain.name ?? "Chain icon", src: chain.iconUrl }) }),
|
|
2930
|
-
account.displayName
|
|
2931
|
-
]
|
|
2932
|
-
}
|
|
2933
|
-
);
|
|
3115
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", { className: cn(buttonCN, "flex items-center gap-2 pl-1.5"), onClick: openAccountModal, children: [
|
|
3116
|
+
chain.hasIcon && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "size-6 overflow-hidden rounded-full", style: { background: chain.iconBackground }, children: chain.iconUrl && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("img", { alt: chain.name ?? "Chain icon", src: chain.iconUrl }) }),
|
|
3117
|
+
account.displayName
|
|
3118
|
+
] });
|
|
2934
3119
|
})() });
|
|
2935
3120
|
} });
|
|
2936
3121
|
};
|
|
2937
3122
|
|
|
2938
3123
|
// src/config/symbolLogos.tsx
|
|
2939
|
-
var
|
|
2940
|
-
var MOCA_SVG = /* @__PURE__ */ (0,
|
|
2941
|
-
/* @__PURE__ */ (0,
|
|
2942
|
-
/* @__PURE__ */ (0,
|
|
3124
|
+
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3125
|
+
var MOCA_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", fill: "none", children: [
|
|
3126
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("circle", { cx: "14", cy: "14", r: "13.5", fill: "#C15F97" }),
|
|
3127
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2943
3128
|
"path",
|
|
2944
3129
|
{
|
|
2945
3130
|
fill: "#fff",
|
|
2946
3131
|
d: "M16.06 6.65c.3 0 .59.16.74.43l6.06 10.5a.85.85 0 1 1-1.47.84L16.06 9.2l-1.51 2.62-.02.03-3.8 6.57a.85.85 0 0 1-1.47-.84l3.57-6.18-1.27-2.2-5.32 9.22a.85.85 0 0 1-1.48-.84l6.07-10.5.06-.1a.85.85 0 0 1 1.4.1l1.52 2.62 1.52-2.62.06-.1c.16-.2.4-.33.67-.33Z"
|
|
2947
3132
|
}
|
|
2948
3133
|
),
|
|
2949
|
-
/* @__PURE__ */ (0,
|
|
3134
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("circle", { cx: "16", cy: "14", r: "1.5", fill: "#fff" })
|
|
2950
3135
|
] });
|
|
2951
|
-
var USDC_SVG = /* @__PURE__ */ (0,
|
|
2952
|
-
/* @__PURE__ */ (0,
|
|
2953
|
-
/* @__PURE__ */ (0,
|
|
2954
|
-
/* @__PURE__ */ (0,
|
|
3136
|
+
var USDC_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", fill: "none", children: [
|
|
3137
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("g", { clipPath: "url(#clip0_528_9163)", children: [
|
|
3138
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#2775CA", d: "M14 28c7.76 0 14-6.24 14-14S21.76 0 14 0 0 6.24 0 14s6.24 14 14 14Z" }),
|
|
3139
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2955
3140
|
"path",
|
|
2956
3141
|
{
|
|
2957
3142
|
fill: "#fff",
|
|
2958
3143
|
d: "M17.85 16.22c0-2.04-1.23-2.74-3.68-3.04-1.75-.23-2.1-.7-2.1-1.51 0-.82.59-1.34 1.75-1.34 1.05 0 1.64.35 1.93 1.22.06.18.23.3.4.3h.94a.4.4 0 0 0 .41-.42v-.05a2.91 2.91 0 0 0-2.63-2.4v-1.4c0-.23-.17-.4-.46-.46h-.88c-.23 0-.4.17-.46.46v1.35c-1.75.23-2.86 1.4-2.86 2.85 0 1.93 1.16 2.69 3.61 2.98 1.64.29 2.16.64 2.16 1.57 0 .94-.81 1.58-1.92 1.58-1.52 0-2.04-.64-2.22-1.52-.06-.23-.23-.35-.4-.35h-1a.4.4 0 0 0-.4.41v.06c.23 1.46 1.16 2.5 3.08 2.8v1.4c0 .23.18.4.47.47h.88c.23 0 .4-.18.46-.47v-1.4c1.75-.3 2.92-1.52 2.92-3.1Z"
|
|
2959
3144
|
}
|
|
2960
3145
|
),
|
|
2961
|
-
/* @__PURE__ */ (0,
|
|
3146
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2962
3147
|
"path",
|
|
2963
3148
|
{
|
|
2964
3149
|
fill: "#fff",
|
|
@@ -2966,11 +3151,11 @@ var USDC_SVG = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("svg", { xmlns: "h
|
|
|
2966
3151
|
}
|
|
2967
3152
|
)
|
|
2968
3153
|
] }),
|
|
2969
|
-
/* @__PURE__ */ (0,
|
|
3154
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("clipPath", { id: "clip0_528_9163", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#fff", d: "M0 0h28v28H0z" }) }) })
|
|
2970
3155
|
] });
|
|
2971
|
-
var USDT_SVG = /* @__PURE__ */ (0,
|
|
2972
|
-
/* @__PURE__ */ (0,
|
|
2973
|
-
/* @__PURE__ */ (0,
|
|
3156
|
+
var USDT_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "28", height: "28", fill: "none", children: [
|
|
3157
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#26A17B", d: "M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28Z" }),
|
|
3158
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2974
3159
|
"path",
|
|
2975
3160
|
{
|
|
2976
3161
|
fill: "#fff",
|
|
@@ -2978,23 +3163,23 @@ var USDT_SVG = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("svg", { xmlns: "h
|
|
|
2978
3163
|
}
|
|
2979
3164
|
)
|
|
2980
3165
|
] });
|
|
2981
|
-
var WETH_SVG = /* @__PURE__ */ (0,
|
|
2982
|
-
/* @__PURE__ */ (0,
|
|
2983
|
-
/* @__PURE__ */ (0,
|
|
3166
|
+
var WETH_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", width: "28", height: "28", viewBox: "0 0 24 24", children: [
|
|
3167
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("g", { clipPath: "url(#clip0_528_9173)", children: [
|
|
3168
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2984
3169
|
"path",
|
|
2985
3170
|
{
|
|
2986
3171
|
fill: "#000",
|
|
2987
3172
|
d: "M17.14 20.57c0 .95-1.31 2.01-3.39 2.4h-2.59c-4.65 0-8.42-1.07-8.42-2.4 0-1.32 3.77-2.4 8.42-2.4s5.98 1.08 5.98 2.4Z"
|
|
2988
3173
|
}
|
|
2989
3174
|
),
|
|
2990
|
-
/* @__PURE__ */ (0,
|
|
3175
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2991
3176
|
"path",
|
|
2992
3177
|
{
|
|
2993
3178
|
fill: "#F61F7D",
|
|
2994
3179
|
d: "M23.31 11c0 5.86-5.18 11.63-11.07 11.63-5.9 0-11.9-6.17-11.9-12.03C.34 4.75 5.12 0 11.01 0s12.3 5.15 12.3 11Z"
|
|
2995
3180
|
}
|
|
2996
3181
|
),
|
|
2997
|
-
/* @__PURE__ */ (0,
|
|
3182
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
2998
3183
|
"path",
|
|
2999
3184
|
{
|
|
3000
3185
|
fill: "#000",
|
|
@@ -3003,8 +3188,8 @@ var WETH_SVG = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("svg", { xmlns: "h
|
|
|
3003
3188
|
clipRule: "evenodd"
|
|
3004
3189
|
}
|
|
3005
3190
|
),
|
|
3006
|
-
/* @__PURE__ */ (0,
|
|
3007
|
-
/* @__PURE__ */ (0,
|
|
3191
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#fff", d: "M24 12.17a10.8 10.8 0 1 1-21.6 0 10.8 10.8 0 0 1 21.6 0Z" }),
|
|
3192
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3008
3193
|
"path",
|
|
3009
3194
|
{
|
|
3010
3195
|
fill: "#000",
|
|
@@ -3013,8 +3198,8 @@ var WETH_SVG = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("svg", { xmlns: "h
|
|
|
3013
3198
|
clipRule: "evenodd"
|
|
3014
3199
|
}
|
|
3015
3200
|
),
|
|
3016
|
-
/* @__PURE__ */ (0,
|
|
3017
|
-
/* @__PURE__ */ (0,
|
|
3201
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#000", fillRule: "evenodd", d: "M3.02 10.63.7 8.75l.74-.86 2.34 1.87-.75.87Z", clipRule: "evenodd" }),
|
|
3202
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
3018
3203
|
"path",
|
|
3019
3204
|
{
|
|
3020
3205
|
fill: "#000",
|
|
@@ -3022,7 +3207,7 @@ var WETH_SVG = /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("svg", { xmlns: "h
|
|
|
3022
3207
|
}
|
|
3023
3208
|
)
|
|
3024
3209
|
] }),
|
|
3025
|
-
/* @__PURE__ */ (0,
|
|
3210
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("clipPath", { id: "clip0_528_9173", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#fff", d: "M0 0h24v24H0z" }) }) })
|
|
3026
3211
|
] });
|
|
3027
3212
|
var symbolLogos = {
|
|
3028
3213
|
MOCA: MOCA_SVG,
|
|
@@ -3035,27 +3220,27 @@ function getSymbolLogo(symbol) {
|
|
|
3035
3220
|
}
|
|
3036
3221
|
|
|
3037
3222
|
// src/components/CryptoTab/Crypto/Logos.tsx
|
|
3038
|
-
var
|
|
3223
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
3039
3224
|
var Logos = () => {
|
|
3040
|
-
return /* @__PURE__ */ (0,
|
|
3041
|
-
/* @__PURE__ */ (0,
|
|
3042
|
-
/* @__PURE__ */ (0,
|
|
3043
|
-
/* @__PURE__ */ (0,
|
|
3044
|
-
/* @__PURE__ */ (0,
|
|
3225
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex", children: [
|
|
3226
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "rounded-full border border-(--b-primary)", children: getSymbolLogo("MOCA") }),
|
|
3227
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary)", children: getSymbolLogo("USDC") }),
|
|
3228
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary)", children: getSymbolLogo("USDT") }),
|
|
3229
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary) bg-(--s-primary)", children: getSymbolLogo("WETH") })
|
|
3045
3230
|
] });
|
|
3046
3231
|
};
|
|
3047
3232
|
|
|
3048
3233
|
// src/components/CryptoTab/Crypto/SelectCoinButton.tsx
|
|
3049
|
-
var
|
|
3234
|
+
var import_nice_modal_react7 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
3050
3235
|
|
|
3051
3236
|
// src/modals/CryptoSelectModal.tsx
|
|
3052
|
-
var
|
|
3053
|
-
var
|
|
3237
|
+
var import_react15 = require("react");
|
|
3238
|
+
var import_nice_modal_react6 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
3054
3239
|
|
|
3055
3240
|
// ../ui/src/components/input.tsx
|
|
3056
|
-
var
|
|
3241
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
3057
3242
|
function Input2({ className, type, ...props }) {
|
|
3058
|
-
return /* @__PURE__ */ (0,
|
|
3243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
3059
3244
|
"input",
|
|
3060
3245
|
{
|
|
3061
3246
|
type,
|
|
@@ -3078,7 +3263,7 @@ var React14 = __toESM(require("react"), 1);
|
|
|
3078
3263
|
var React13 = __toESM(require("react"), 1);
|
|
3079
3264
|
var ReactDOM2 = __toESM(require("react-dom"), 1);
|
|
3080
3265
|
var import_react_slot5 = require("@radix-ui/react-slot");
|
|
3081
|
-
var
|
|
3266
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3082
3267
|
var NODES2 = [
|
|
3083
3268
|
"a",
|
|
3084
3269
|
"button",
|
|
@@ -3106,14 +3291,14 @@ var Primitive2 = NODES2.reduce((primitive, node) => {
|
|
|
3106
3291
|
if (typeof window !== "undefined") {
|
|
3107
3292
|
window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
|
|
3108
3293
|
}
|
|
3109
|
-
return /* @__PURE__ */ (0,
|
|
3294
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
3110
3295
|
});
|
|
3111
3296
|
Node2.displayName = `Primitive.${node}`;
|
|
3112
3297
|
return { ...primitive, [node]: Node2 };
|
|
3113
3298
|
}, {});
|
|
3114
3299
|
|
|
3115
3300
|
// ../../node_modules/@radix-ui/react-separator/dist/index.mjs
|
|
3116
|
-
var
|
|
3301
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3117
3302
|
var NAME = "Separator";
|
|
3118
3303
|
var DEFAULT_ORIENTATION = "horizontal";
|
|
3119
3304
|
var ORIENTATIONS = ["horizontal", "vertical"];
|
|
@@ -3122,7 +3307,7 @@ var Separator = React14.forwardRef((props, forwardedRef) => {
|
|
|
3122
3307
|
const orientation = isValidOrientation(orientationProp) ? orientationProp : DEFAULT_ORIENTATION;
|
|
3123
3308
|
const ariaOrientation = orientation === "vertical" ? orientation : void 0;
|
|
3124
3309
|
const semanticProps = decorative ? { role: "none" } : { "aria-orientation": ariaOrientation, role: "separator" };
|
|
3125
|
-
return /* @__PURE__ */ (0,
|
|
3310
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
3126
3311
|
Primitive2.div,
|
|
3127
3312
|
{
|
|
3128
3313
|
"data-orientation": orientation,
|
|
@@ -3139,14 +3324,14 @@ function isValidOrientation(orientation) {
|
|
|
3139
3324
|
var Root6 = Separator;
|
|
3140
3325
|
|
|
3141
3326
|
// ../ui/src/components/separator.tsx
|
|
3142
|
-
var
|
|
3327
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
3143
3328
|
function Separator2({
|
|
3144
3329
|
className,
|
|
3145
3330
|
orientation = "horizontal",
|
|
3146
3331
|
decorative = true,
|
|
3147
3332
|
...props
|
|
3148
3333
|
}) {
|
|
3149
|
-
return /* @__PURE__ */ (0,
|
|
3334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
3150
3335
|
Root6,
|
|
3151
3336
|
{
|
|
3152
3337
|
"data-slot": "separator",
|
|
@@ -3253,14 +3438,14 @@ var useBaseTokens = () => {
|
|
|
3253
3438
|
};
|
|
3254
3439
|
|
|
3255
3440
|
// src/modals/CryptoSelectModal.tsx
|
|
3256
|
-
var
|
|
3257
|
-
var CryptoSelectModal =
|
|
3258
|
-
const modal = (0,
|
|
3441
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
3442
|
+
var CryptoSelectModal = import_nice_modal_react6.default.create(() => {
|
|
3443
|
+
const modal = (0, import_nice_modal_react6.useModal)();
|
|
3259
3444
|
const { isLoading, error, erc20Balances } = useBaseERC20Token();
|
|
3260
3445
|
const { isLoadingNative, nativeError, nativeBalance } = useBaseNativeToken();
|
|
3261
3446
|
const { tokens, tokensIsLoading } = useBaseTokens();
|
|
3262
|
-
const [search, setSearch] = (0,
|
|
3263
|
-
const filteredCoins = (0,
|
|
3447
|
+
const [search, setSearch] = (0, import_react15.useState)("");
|
|
3448
|
+
const filteredCoins = (0, import_react15.useMemo)(() => {
|
|
3264
3449
|
return tokens.filter(
|
|
3265
3450
|
(coin) => coin.name.toLowerCase().includes(search.toLowerCase()) || coin.symbol.toLowerCase().includes(search.toLowerCase())
|
|
3266
3451
|
);
|
|
@@ -3271,14 +3456,14 @@ var CryptoSelectModal = import_nice_modal_react5.default.create(() => {
|
|
|
3271
3456
|
setSelectedPaymentMethod({ type: "CRYPTO" /* CRYPTO */, method: coin });
|
|
3272
3457
|
};
|
|
3273
3458
|
const userCoins = [nativeBalance, ...erc20Balances].filter(Boolean);
|
|
3274
|
-
return /* @__PURE__ */ (0,
|
|
3275
|
-
/* @__PURE__ */ (0,
|
|
3276
|
-
/* @__PURE__ */ (0,
|
|
3277
|
-
/* @__PURE__ */ (0,
|
|
3278
|
-
/* @__PURE__ */ (0,
|
|
3279
|
-
/* @__PURE__ */ (0,
|
|
3280
|
-
/* @__PURE__ */ (0,
|
|
3281
|
-
/* @__PURE__ */ (0,
|
|
3459
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(Dialog, { open: modal.visible, onOpenChange: modal.remove, children: [
|
|
3460
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DialogDescription, { className: "hidden", children: "Crypto Select Modal" }),
|
|
3461
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(DialogContent, { showCloseButton: false, className: "max-h-[90vh] gap-0 p-0", children: [
|
|
3462
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
|
|
3463
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
3464
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("button", { className: "rounded-md hover:bg-(--s-primary-hover)", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("path", { stroke: "currentColor", d: "m15 6.5-6 6 6 6" }) }) }),
|
|
3465
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DialogTitle, { className: "text-2xl font-medium text-(--brand-primary)", children: "Select a token" }),
|
|
3466
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("button", { className: "rounded-md p-1 hover:bg-(--s-primary-hover)", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "17", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
3282
3467
|
"path",
|
|
3283
3468
|
{
|
|
3284
3469
|
fill: "currentColor",
|
|
@@ -3286,71 +3471,71 @@ var CryptoSelectModal = import_nice_modal_react5.default.create(() => {
|
|
|
3286
3471
|
}
|
|
3287
3472
|
) }) })
|
|
3288
3473
|
] }),
|
|
3289
|
-
/* @__PURE__ */ (0,
|
|
3474
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Input2, { onChange: (e) => setSearch(e.target.value), placeholder: "Search by token name", value: search })
|
|
3290
3475
|
] }),
|
|
3291
|
-
/* @__PURE__ */ (0,
|
|
3292
|
-
/* @__PURE__ */ (0,
|
|
3293
|
-
/* @__PURE__ */ (0,
|
|
3294
|
-
(error || nativeError) && /* @__PURE__ */ (0,
|
|
3295
|
-
/* @__PURE__ */ (0,
|
|
3296
|
-
isLoadingNative && /* @__PURE__ */ (0,
|
|
3297
|
-
nativeBalance && /* @__PURE__ */ (0,
|
|
3476
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Separator2, { className: "hidden md:block" }),
|
|
3477
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
|
|
3478
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h3", { className: "text-md font-medium text-(--brand-primary)", children: "Tokens with wallet balance" }),
|
|
3479
|
+
(error || nativeError) && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-center text-sm text-(--negative)", children: "Something wrong" }),
|
|
3480
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex w-full flex-col gap-1", children: [
|
|
3481
|
+
isLoadingNative && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
|
|
3482
|
+
nativeBalance && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
3298
3483
|
"button",
|
|
3299
3484
|
{
|
|
3300
3485
|
className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-(--brand-primary) hover:bg-(--s-primary-hover)",
|
|
3301
3486
|
onClick: () => handleSelect(nativeBalance),
|
|
3302
3487
|
children: [
|
|
3303
|
-
/* @__PURE__ */ (0,
|
|
3304
|
-
nativeBalance.logoURI && /* @__PURE__ */ (0,
|
|
3305
|
-
/* @__PURE__ */ (0,
|
|
3488
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3489
|
+
nativeBalance.logoURI && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("img", { className: "size-8 shrink-0", src: nativeBalance.logoURI, alt: `${nativeBalance.symbol} logo` }),
|
|
3490
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.symbol })
|
|
3306
3491
|
] }),
|
|
3307
|
-
/* @__PURE__ */ (0,
|
|
3492
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.formatted })
|
|
3308
3493
|
]
|
|
3309
3494
|
},
|
|
3310
3495
|
nativeBalance.symbol
|
|
3311
3496
|
),
|
|
3312
|
-
isLoading && /* @__PURE__ */ (0,
|
|
3313
|
-
/* @__PURE__ */ (0,
|
|
3314
|
-
/* @__PURE__ */ (0,
|
|
3315
|
-
/* @__PURE__ */ (0,
|
|
3497
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
|
|
3498
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
|
|
3499
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
|
|
3500
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" })
|
|
3316
3501
|
] }),
|
|
3317
3502
|
erc20Balances.map((coin) => {
|
|
3318
3503
|
const Icon = getSymbolLogo(coin.symbol);
|
|
3319
|
-
return /* @__PURE__ */ (0,
|
|
3504
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
3320
3505
|
"button",
|
|
3321
3506
|
{
|
|
3322
3507
|
className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-(--brand-primary) hover:bg-(--s-primary-hover) disabled:cursor-not-allowed disabled:opacity-50",
|
|
3323
3508
|
onClick: () => handleSelect(coin),
|
|
3324
3509
|
children: [
|
|
3325
|
-
/* @__PURE__ */ (0,
|
|
3510
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3326
3511
|
Boolean(Icon) && Icon,
|
|
3327
|
-
/* @__PURE__ */ (0,
|
|
3512
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: coin.symbol })
|
|
3328
3513
|
] }),
|
|
3329
|
-
/* @__PURE__ */ (0,
|
|
3514
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: coin.formatted })
|
|
3330
3515
|
]
|
|
3331
3516
|
},
|
|
3332
3517
|
coin.symbol
|
|
3333
3518
|
);
|
|
3334
3519
|
})
|
|
3335
3520
|
] }),
|
|
3336
|
-
/* @__PURE__ */ (0,
|
|
3337
|
-
/* @__PURE__ */ (0,
|
|
3338
|
-
tokensIsLoading && /* @__PURE__ */ (0,
|
|
3339
|
-
/* @__PURE__ */ (0,
|
|
3340
|
-
/* @__PURE__ */ (0,
|
|
3341
|
-
/* @__PURE__ */ (0,
|
|
3521
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h3", { className: "text-md font-medium text-(--brand-primary)", children: "All Tokens" }),
|
|
3522
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex max-h-[40vh] w-full flex-col gap-1 overflow-y-auto", children: [
|
|
3523
|
+
tokensIsLoading && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
|
|
3524
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
|
|
3525
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
|
|
3526
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" })
|
|
3342
3527
|
] }),
|
|
3343
3528
|
filteredCoins.map((token) => {
|
|
3344
3529
|
const userCoin = userCoins.find((c) => c.symbol === token.symbol);
|
|
3345
|
-
return /* @__PURE__ */ (0,
|
|
3530
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
3346
3531
|
"button",
|
|
3347
3532
|
{
|
|
3348
3533
|
disabled: !userCoin,
|
|
3349
3534
|
onClick: () => userCoin && handleSelect(userCoin),
|
|
3350
3535
|
className: "flex min-h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-(--brand-primary) hover:bg-(--s-primary-hover) disabled:cursor-not-allowed disabled:opacity-50",
|
|
3351
|
-
children: /* @__PURE__ */ (0,
|
|
3352
|
-
token.logoURI ? /* @__PURE__ */ (0,
|
|
3353
|
-
/* @__PURE__ */ (0,
|
|
3536
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3537
|
+
token.logoURI ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("img", { className: "size-8 shrink-0", src: token.logoURI, alt: `${token.name} logo` }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "size-8 shrink-0 rounded-full bg-(--s-tertiary)" }),
|
|
3538
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: token.symbol })
|
|
3354
3539
|
] })
|
|
3355
3540
|
},
|
|
3356
3541
|
token.symbol
|
|
@@ -3364,55 +3549,56 @@ var CryptoSelectModal = import_nice_modal_react5.default.create(() => {
|
|
|
3364
3549
|
CryptoSelectModal.displayName = "CryptoSelectModal";
|
|
3365
3550
|
|
|
3366
3551
|
// src/components/CryptoTab/Crypto/SelectCoinButton.tsx
|
|
3367
|
-
var
|
|
3552
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
3368
3553
|
var SelectCoinButton = () => {
|
|
3369
3554
|
const openModal = () => {
|
|
3370
|
-
|
|
3555
|
+
import_nice_modal_react7.default.show(CryptoSelectModal);
|
|
3371
3556
|
};
|
|
3372
|
-
return /* @__PURE__ */ (0,
|
|
3557
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
3373
3558
|
"button",
|
|
3374
3559
|
{
|
|
3375
3560
|
onClick: openModal,
|
|
3376
3561
|
className: "flex h-11 w-full overflow-hidden rounded-md bg-(--s-primary) hover:bg-(--s-primary-hover)",
|
|
3377
|
-
children: /* @__PURE__ */ (0,
|
|
3378
|
-
/* @__PURE__ */ (0,
|
|
3379
|
-
/* @__PURE__ */ (0,
|
|
3562
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex h-full w-full items-center justify-between px-3", children: [
|
|
3563
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "font-medium text-(--secondary)", children: "Select a token" }) }),
|
|
3564
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("path", { stroke: "currentColor", strokeLinecap: "round", d: "m6 12.43 4-4-4-4" }) })
|
|
3380
3565
|
] })
|
|
3381
3566
|
}
|
|
3382
3567
|
);
|
|
3383
3568
|
};
|
|
3384
3569
|
|
|
3385
3570
|
// src/components/CryptoTab/Crypto/SelectedCoin.tsx
|
|
3386
|
-
var
|
|
3571
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
3387
3572
|
var SelectedCoin = (props) => {
|
|
3388
3573
|
const { coin, balance, logoURI } = props;
|
|
3389
3574
|
const Icon = getSymbolLogo(coin);
|
|
3390
|
-
return /* @__PURE__ */ (0,
|
|
3391
|
-
/* @__PURE__ */ (0,
|
|
3392
|
-
/* @__PURE__ */ (0,
|
|
3393
|
-
/* @__PURE__ */ (0,
|
|
3575
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex h-12 w-full overflow-hidden rounded-md border-2 border-(--b-brand) bg-(--s-primary)", children: [
|
|
3576
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "flex h-full w-11 shrink-0 items-center justify-center border-r border-(--b-brand) bg-(--s-primary)", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) }) }),
|
|
3577
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex h-full w-full items-center justify-between rounded-r-md px-3", children: [
|
|
3578
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3394
3579
|
Icon,
|
|
3395
|
-
!Icon && logoURI && /* @__PURE__ */ (0,
|
|
3396
|
-
/* @__PURE__ */ (0,
|
|
3397
|
-
/* @__PURE__ */ (0,
|
|
3580
|
+
!Icon && logoURI && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("img", { className: "mr-1 size-8 shrink-0", src: logoURI, alt: `${coin} logo` }),
|
|
3581
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "font-semibold text-(--brand-primary)", children: coin }),
|
|
3582
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("path", { d: "M6 12.4341L10 8.43408L6 4.43408", stroke: "currentColor", strokeLinecap: "round" }) })
|
|
3398
3583
|
] }),
|
|
3399
|
-
/* @__PURE__ */ (0,
|
|
3584
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "text-xs font-medium text-(--secondary)", children: [
|
|
3400
3585
|
"Wallet balance ",
|
|
3401
|
-
/* @__PURE__ */ (0,
|
|
3586
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "text-(--brand-primary)", children: balance })
|
|
3402
3587
|
] })
|
|
3403
3588
|
] })
|
|
3404
3589
|
] });
|
|
3405
3590
|
};
|
|
3406
3591
|
|
|
3407
3592
|
// src/components/CryptoTab/Crypto/Crypto.tsx
|
|
3408
|
-
var
|
|
3593
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
3409
3594
|
var Crypto = () => {
|
|
3410
3595
|
const { address } = (0, import_wagmi4.useAccount)();
|
|
3411
3596
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
3412
3597
|
const { cryptoPayment } = useCryptoPayment();
|
|
3598
|
+
const { spreePayConfig } = useSpreePayConfig();
|
|
3413
3599
|
const isWalletConnected = Boolean(address);
|
|
3414
3600
|
const { register } = useSpreePayRegister();
|
|
3415
|
-
const handlePay = (0,
|
|
3601
|
+
const handlePay = (0, import_react16.useCallback)(
|
|
3416
3602
|
async (data) => {
|
|
3417
3603
|
try {
|
|
3418
3604
|
const res = await cryptoPayment(data);
|
|
@@ -3426,17 +3612,17 @@ var Crypto = () => {
|
|
|
3426
3612
|
},
|
|
3427
3613
|
[cryptoPayment]
|
|
3428
3614
|
);
|
|
3429
|
-
(0,
|
|
3615
|
+
(0, import_react16.useEffect)(() => {
|
|
3430
3616
|
register(handlePay);
|
|
3431
3617
|
}, [register, handlePay]);
|
|
3432
|
-
return /* @__PURE__ */ (0,
|
|
3433
|
-
/* @__PURE__ */ (0,
|
|
3434
|
-
/* @__PURE__ */ (0,
|
|
3435
|
-
/* @__PURE__ */ (0,
|
|
3618
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
3619
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [
|
|
3620
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { className: "text-[22px] leading-7 font-medium text-(--brand-primary)", children: "Pay with Crypto" }),
|
|
3621
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ConnectButton, {})
|
|
3436
3622
|
] }),
|
|
3437
|
-
!isWalletConnected && /* @__PURE__ */ (0,
|
|
3438
|
-
isWalletConnected && /* @__PURE__ */ (0,
|
|
3439
|
-
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ (0,
|
|
3623
|
+
!isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Logos, {}),
|
|
3624
|
+
isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex w-full flex-col gap-4", children: [
|
|
3625
|
+
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3440
3626
|
SelectedCoin,
|
|
3441
3627
|
{
|
|
3442
3628
|
coin: selectedPaymentMethod.method.symbol,
|
|
@@ -3444,13 +3630,14 @@ var Crypto = () => {
|
|
|
3444
3630
|
logoURI: selectedPaymentMethod.method.logoURI
|
|
3445
3631
|
}
|
|
3446
3632
|
),
|
|
3447
|
-
/* @__PURE__ */ (0,
|
|
3448
|
-
] })
|
|
3633
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SelectCoinButton, {})
|
|
3634
|
+
] }),
|
|
3635
|
+
spreePayConfig?.crypto.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(InfoBanner, { message: spreePayConfig.crypto.infoMessage })
|
|
3449
3636
|
] });
|
|
3450
3637
|
};
|
|
3451
3638
|
|
|
3452
3639
|
// src/components/CryptoTab/Crypto/CryptoWrapper.tsx
|
|
3453
|
-
var
|
|
3640
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
3454
3641
|
var queryClient = new import_react_query.QueryClient();
|
|
3455
3642
|
var CHAINS = [import_chains.base];
|
|
3456
3643
|
var wagmiConfigCache = /* @__PURE__ */ new Map();
|
|
@@ -3465,37 +3652,36 @@ function getCachedWagmiConfig(projectId, appName) {
|
|
|
3465
3652
|
}
|
|
3466
3653
|
var CryptoWrapper = () => {
|
|
3467
3654
|
const { spreePayConfig, configIsLoading } = useSpreePayConfig();
|
|
3468
|
-
const wagmiConfig = (0,
|
|
3655
|
+
const wagmiConfig = (0, import_react17.useMemo)(() => {
|
|
3469
3656
|
if (!spreePayConfig) return null;
|
|
3470
3657
|
return getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
|
|
3471
3658
|
}, [spreePayConfig]);
|
|
3472
3659
|
if (configIsLoading || !wagmiConfig) return null;
|
|
3473
|
-
return /* @__PURE__ */ (0,
|
|
3660
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_wagmi5.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_rainbowkit2.RainbowKitProvider, { theme: (0, import_rainbowkit2.lightTheme)({ borderRadius: "large" }), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_nice_modal_react8.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Crypto, {}) }) }) }) });
|
|
3474
3661
|
};
|
|
3475
3662
|
|
|
3476
3663
|
// src/components/CryptoTab/CryptoTab.tsx
|
|
3477
|
-
var
|
|
3664
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
3478
3665
|
var CryptoTab = () => {
|
|
3479
3666
|
const { spreePayConfig } = useSpreePayConfig();
|
|
3480
|
-
return /* @__PURE__ */ (0,
|
|
3481
|
-
/* @__PURE__ */ (0,
|
|
3482
|
-
/* @__PURE__ */ (0,
|
|
3667
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
|
|
3668
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "border-b border-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CryptoWrapper, {}) }),
|
|
3669
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "border-b border-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PointsSwitch, { disabled: true, message: spreePayConfig?.crypto.pointsInfoMessage }) })
|
|
3483
3670
|
] });
|
|
3484
3671
|
};
|
|
3485
3672
|
|
|
3486
3673
|
// src/components/TabButtons.tsx
|
|
3487
|
-
var
|
|
3674
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
3488
3675
|
var TabButton = ({ isDisabled = false, isActive, children, onClick }) => {
|
|
3489
|
-
return /* @__PURE__ */ (0,
|
|
3676
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3490
3677
|
"button",
|
|
3491
3678
|
{
|
|
3492
3679
|
disabled: isDisabled,
|
|
3493
3680
|
onClick,
|
|
3494
3681
|
className: cn(
|
|
3495
|
-
"flex w-[180px] flex-col items-baseline gap-0.5 rounded-md border border-(--b-tertiary) px-3 py-1.5 text-(--tertiary) shadow-[0_6.25px_25px_0_rgba(0,0,0,0.05)] hover:bg-(--s-primary)",
|
|
3496
|
-
{ "cursor-not-allowed": isDisabled },
|
|
3682
|
+
"flex w-[180px] flex-col items-baseline justify-between gap-0.5 rounded-md border border-(--b-tertiary) px-3 py-1.5 text-(--tertiary) shadow-[0_6.25px_25px_0_rgba(0,0,0,0.05)] hover:bg-(--s-primary) disabled:cursor-not-allowed",
|
|
3497
3683
|
{
|
|
3498
|
-
"border-
|
|
3684
|
+
"border-(--b-brand) bg-(--s-primary) text-(--brand-primary) ring ring-(--b-brand)": isActive
|
|
3499
3685
|
}
|
|
3500
3686
|
),
|
|
3501
3687
|
children
|
|
@@ -3510,12 +3696,12 @@ var TabButtons = (props) => {
|
|
|
3510
3696
|
onChange({ type, method: null });
|
|
3511
3697
|
}
|
|
3512
3698
|
};
|
|
3513
|
-
return /* @__PURE__ */ (0,
|
|
3514
|
-
configIsLoading && /* @__PURE__ */ (0,
|
|
3515
|
-
spreePayConfig?.creditCard.enabled && /* @__PURE__ */ (0,
|
|
3516
|
-
/* @__PURE__ */ (0,
|
|
3517
|
-
/* @__PURE__ */ (0,
|
|
3518
|
-
/* @__PURE__ */ (0,
|
|
3699
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex gap-4", children: [
|
|
3700
|
+
configIsLoading && /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "h-[74px] w-[180px] animate-pulse rounded-md bg-(--s-primary)" }),
|
|
3701
|
+
spreePayConfig?.creditCard.enabled && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(TabButton, { onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */), isActive: value === "CREDIT_CARD" /* CREDIT_CARD */, children: [
|
|
3702
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "32", height: "32", fill: "none", viewBox: "0 0 32 32", children: [
|
|
3703
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("mask", { id: "a", width: "32", height: "32", x: "0", y: "0", maskUnits: "userSpaceOnUse", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)("path", { fill: "#d9d9d9", d: "M0 0h32v32H0z" }) }),
|
|
3704
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("g", { mask: "url(#a)", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3519
3705
|
"path",
|
|
3520
3706
|
{
|
|
3521
3707
|
fill: "currentColor",
|
|
@@ -3523,61 +3709,83 @@ var TabButtons = (props) => {
|
|
|
3523
3709
|
}
|
|
3524
3710
|
) })
|
|
3525
3711
|
] }),
|
|
3526
|
-
/* @__PURE__ */ (0,
|
|
3712
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "text-md font-medium", children: "Card" })
|
|
3527
3713
|
] }),
|
|
3528
|
-
spreePayConfig?.crypto.enabled && /* @__PURE__ */ (0,
|
|
3529
|
-
/* @__PURE__ */ (0,
|
|
3530
|
-
|
|
3714
|
+
spreePayConfig?.crypto.enabled && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(TabButton, { onClick: handleChange("CRYPTO" /* CRYPTO */), isActive: value === "CRYPTO" /* CRYPTO */, children: [
|
|
3715
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "32", height: "32", fill: "none", viewBox: "0 0 32 32", children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3716
|
+
"path",
|
|
3717
|
+
{
|
|
3718
|
+
fill: "currentColor",
|
|
3719
|
+
fillRule: "evenodd",
|
|
3720
|
+
d: "M21 9.86a8 8 0 0 1 3 5.43l-2.85-.71a5.4 5.4 0 0 0-3.86-3.67 5.3 5.3 0 0 0-6.46 3.8 5.3 5.3 0 0 0 3.91 6.4 5.4 5.4 0 0 0 5.14-1.43l2.85.7a8 8 0 0 1-5.2 3.39L16.72 27l-2.6-.65.64-2.57a8 8 0 0 1-1.3-.32l-.64 2.57-2.6-.65.82-3.24a7.9 7.9 0 0 1-2.8-8.08 7.9 7.9 0 0 1 6.27-5.82L15.32 5l2.6.64-.65 2.58q.67.1 1.3.32l.65-2.57 2.6.64z",
|
|
3721
|
+
clipRule: "evenodd"
|
|
3722
|
+
}
|
|
3723
|
+
) }),
|
|
3724
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "text-md font-medium", children: "Crypto" })
|
|
3725
|
+
] }),
|
|
3726
|
+
spreePayConfig?.cryptoCom.enabled && /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)(TabButton, { onClick: handleChange("CDC" /* CDC */), isActive: value === "CDC" /* CDC */, children: [
|
|
3727
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "44", height: "32", fill: "none", viewBox: "0 0 44 32", children: [
|
|
3728
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3531
3729
|
"path",
|
|
3532
3730
|
{
|
|
3533
3731
|
fill: "currentColor",
|
|
3534
|
-
|
|
3732
|
+
fillRule: "evenodd",
|
|
3733
|
+
d: "M17.6 11v10l-8.8 5L0 21V11l8.8-5zM2.2 16.69l3.15 5.42h1.26l1.5-1.37v-.7L6.56 18.6v-2.32L4.51 15zm8.87-.42v2.32l-1.55 1.46v.69l1.5 1.35h1.24l3.15-5.4-2.32-1.72zm-4.5-1.95.75 1.95-.23 2.17H8.8l1.72-.01-.21-2.17.74-1.94zm-1.25-4-.8 3.48h8.56l-.83-3.47z",
|
|
3734
|
+
clipRule: "evenodd"
|
|
3535
3735
|
}
|
|
3536
3736
|
),
|
|
3537
|
-
/* @__PURE__ */ (0,
|
|
3737
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("path", { fill: "#009fff", d: "m39.84 18.25 1.94-4.64h1.42l-4.05 9.17H37.7l1.4-3.1-2.64-6.07h1.5z" }),
|
|
3738
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3538
3739
|
"path",
|
|
3539
3740
|
{
|
|
3540
|
-
fill: "
|
|
3541
|
-
|
|
3741
|
+
fill: "#009fff",
|
|
3742
|
+
fillRule: "evenodd",
|
|
3743
|
+
d: "M32.91 13.46q.92 0 1.52.34.62.34.91.94t.31 1.37v1.94q0 .37.15.55.15.17.54.2v1.16q-.51 0-.9-.11-.37-.12-.61-.35a2 2 0 0 1-.38-.61 2.6 2.6 0 0 1-2.24 1.22q-.62 0-1.13-.21a2 2 0 0 1-.82-.67q-.3-.44-.3-1.05 0-.73.35-1.16.38-.45.99-.66.63-.21 1.37-.21h1.61q0-.56-.18-.89a1 1 0 0 0-.49-.5q-.3-.15-.71-.16-.54 0-.95.25a1.1 1.1 0 0 0-.5.78h-1.37q.06-.69.46-1.17.41-.5 1.04-.75t1.33-.25m-.14 3.63q-.37 0-.7.1-.33.07-.53.3a.8.8 0 0 0-.2.58q0 .48.35.71t.84.22a1.7 1.7 0 0 0 1.53-.95q.22-.44.22-.93v-.03zM26.34 11q.94 0 1.63.3.69.29 1.08.88.4.57.4 1.43t-.4 1.45-1.1.88q-.7.28-1.61.28h-1.78v3.74H23.2V11zm-1.78 4.07h1.75q.97 0 1.36-.38.4-.4.4-1.08 0-.7-.4-1.07-.4-.4-1.36-.4h-1.75z",
|
|
3744
|
+
clipRule: "evenodd"
|
|
3542
3745
|
}
|
|
3543
|
-
)
|
|
3544
|
-
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "2" })
|
|
3746
|
+
)
|
|
3545
3747
|
] }),
|
|
3546
|
-
/* @__PURE__ */ (0,
|
|
3748
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("p", { className: "text-md font-medium", children: "Crypto.com Pay" })
|
|
3547
3749
|
] })
|
|
3548
3750
|
] });
|
|
3549
3751
|
};
|
|
3550
3752
|
|
|
3551
3753
|
// src/SpreePayContent.tsx
|
|
3552
|
-
var
|
|
3754
|
+
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
3553
3755
|
var SpreePayContent = ({ isLoggedIn }) => {
|
|
3554
3756
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
3555
|
-
return /* @__PURE__ */ (0,
|
|
3556
|
-
/* @__PURE__ */ (0,
|
|
3557
|
-
/* @__PURE__ */ (0,
|
|
3558
|
-
/* @__PURE__ */ (0,
|
|
3757
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "w-full overflow-hidden rounded-3xl border border-(--border-component-specific-card) bg-(--surface-component-specific-card-default-card) shadow-[0_6.25px_25px_0_var(--shadow-component-specific-card)]", children: [
|
|
3758
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex w-full flex-col gap-4 border-b border-b-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: [
|
|
3759
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)("h2", { className: "text-[28px] leading-8 font-medium text-(--brand-primary)", children: "Choose a Payment Method" }),
|
|
3760
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
|
|
3761
|
+
] }),
|
|
3762
|
+
selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
|
|
3763
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CreditCardTab, {}),
|
|
3764
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CheckoutButton, { isLoggedIn })
|
|
3765
|
+
] }),
|
|
3766
|
+
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_jsx_runtime45.Fragment, { children: [
|
|
3767
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CryptoTab, {}),
|
|
3768
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CheckoutButton, { isLoggedIn })
|
|
3559
3769
|
] }),
|
|
3560
|
-
selectedPaymentMethod.type === "
|
|
3561
|
-
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CryptoTab, {}),
|
|
3562
|
-
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(CheckoutButton, { isLoggedIn })
|
|
3770
|
+
selectedPaymentMethod.type === "CDC" /* CDC */ && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CryptoComTab, {})
|
|
3563
3771
|
] });
|
|
3564
3772
|
};
|
|
3565
3773
|
|
|
3566
3774
|
// src/hooks/useKeycloakSSO.ts
|
|
3567
|
-
var
|
|
3775
|
+
var import_react18 = require("react");
|
|
3568
3776
|
var import_keycloak_js = __toESM(require("keycloak-js"), 1);
|
|
3569
3777
|
var refreshAheadSeconds = 60;
|
|
3570
3778
|
function useKeycloakSSO(config2) {
|
|
3571
3779
|
const { url, realm, clientId, ssoPageURI, enabled } = config2;
|
|
3572
|
-
const initRef = (0,
|
|
3573
|
-
const kcRef = (0,
|
|
3574
|
-
const refreshTimerRef = (0,
|
|
3575
|
-
const scheduleRefreshRef = (0,
|
|
3780
|
+
const initRef = (0, import_react18.useRef)(false);
|
|
3781
|
+
const kcRef = (0, import_react18.useRef)(null);
|
|
3782
|
+
const refreshTimerRef = (0, import_react18.useRef)(null);
|
|
3783
|
+
const scheduleRefreshRef = (0, import_react18.useRef)(() => {
|
|
3576
3784
|
});
|
|
3577
|
-
const [error, setError] = (0,
|
|
3578
|
-
const [isChecking, setIsChecking] = (0,
|
|
3579
|
-
const [accessToken, setAccessToken] = (0,
|
|
3580
|
-
const scheduleRefresh = (0,
|
|
3785
|
+
const [error, setError] = (0, import_react18.useState)(null);
|
|
3786
|
+
const [isChecking, setIsChecking] = (0, import_react18.useState)(enabled);
|
|
3787
|
+
const [accessToken, setAccessToken] = (0, import_react18.useState)(null);
|
|
3788
|
+
const scheduleRefresh = (0, import_react18.useCallback)(() => {
|
|
3581
3789
|
const kc = kcRef.current;
|
|
3582
3790
|
if (!kc || !kc.tokenParsed || !kc.tokenParsed.exp) {
|
|
3583
3791
|
return;
|
|
@@ -3598,10 +3806,10 @@ function useKeycloakSSO(config2) {
|
|
|
3598
3806
|
});
|
|
3599
3807
|
}, delayMs);
|
|
3600
3808
|
}, []);
|
|
3601
|
-
(0,
|
|
3809
|
+
(0, import_react18.useEffect)(() => {
|
|
3602
3810
|
scheduleRefreshRef.current = scheduleRefresh;
|
|
3603
3811
|
}, [scheduleRefresh]);
|
|
3604
|
-
(0,
|
|
3812
|
+
(0, import_react18.useEffect)(() => {
|
|
3605
3813
|
if (initRef.current || !enabled) return;
|
|
3606
3814
|
initRef.current = true;
|
|
3607
3815
|
const kc = new import_keycloak_js.default({ url, realm, clientId });
|
|
@@ -3635,15 +3843,15 @@ function useKeycloakSSO(config2) {
|
|
|
3635
3843
|
}
|
|
3636
3844
|
|
|
3637
3845
|
// src/SpreePay.tsx
|
|
3638
|
-
var
|
|
3846
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
3639
3847
|
var SpreePayInner = () => {
|
|
3640
|
-
const [portalEl, setPortalEl] = (0,
|
|
3641
|
-
const rootRef = (0,
|
|
3848
|
+
const [portalEl, setPortalEl] = (0, import_react19.useState)(null);
|
|
3849
|
+
const rootRef = (0, import_react19.useCallback)((node) => {
|
|
3642
3850
|
if (!node) return;
|
|
3643
3851
|
const el = node.querySelector(":scope > .sl-spreepay__portal");
|
|
3644
3852
|
setPortalEl(el ?? null);
|
|
3645
3853
|
}, []);
|
|
3646
|
-
(0,
|
|
3854
|
+
(0, import_react19.useEffect)(() => {
|
|
3647
3855
|
console.log(`[spree-pay] v${version}`);
|
|
3648
3856
|
}, []);
|
|
3649
3857
|
const { env } = useSpreePayEnv();
|
|
@@ -3657,8 +3865,8 @@ var SpreePayInner = () => {
|
|
|
3657
3865
|
enabled: !env?.accessToken
|
|
3658
3866
|
});
|
|
3659
3867
|
const _accessToken = env.accessToken ?? accessToken;
|
|
3660
|
-
const unauthenticatedFetcher = (0,
|
|
3661
|
-
const slapiFetcher = (0,
|
|
3868
|
+
const unauthenticatedFetcher = (0, import_react19.useCallback)(() => Promise.resolve(null), []);
|
|
3869
|
+
const slapiFetcher = (0, import_react19.useMemo)(() => {
|
|
3662
3870
|
if (_accessToken) {
|
|
3663
3871
|
return registerApi({
|
|
3664
3872
|
accessToken: _accessToken,
|
|
@@ -3670,12 +3878,12 @@ var SpreePayInner = () => {
|
|
|
3670
3878
|
}, [_accessToken, staticConfig, tenantId, unauthenticatedFetcher]);
|
|
3671
3879
|
const getContent = () => {
|
|
3672
3880
|
if (isChecking) {
|
|
3673
|
-
return /* @__PURE__ */ (0,
|
|
3674
|
-
/* @__PURE__ */ (0,
|
|
3675
|
-
/* @__PURE__ */ (0,
|
|
3881
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex w-full flex-col", children: [
|
|
3882
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "mb-4 h-[315px] animate-pulse rounded-3xl bg-(--s-primary)" }),
|
|
3883
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "h-[135px] animate-pulse rounded-3xl bg-(--s-primary)" })
|
|
3676
3884
|
] });
|
|
3677
3885
|
}
|
|
3678
|
-
return /* @__PURE__ */ (0,
|
|
3886
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(
|
|
3679
3887
|
import_swr5.SWRConfig,
|
|
3680
3888
|
{
|
|
3681
3889
|
value: {
|
|
@@ -3684,23 +3892,23 @@ var SpreePayInner = () => {
|
|
|
3684
3892
|
revalidateOnFocus: false,
|
|
3685
3893
|
revalidateIfStale: false
|
|
3686
3894
|
},
|
|
3687
|
-
children: /* @__PURE__ */ (0,
|
|
3895
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(import_nice_modal_react9.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SpreePayContent, { isLoggedIn: Boolean(_accessToken) }) }) })
|
|
3688
3896
|
}
|
|
3689
3897
|
);
|
|
3690
3898
|
};
|
|
3691
|
-
return /* @__PURE__ */ (0,
|
|
3692
|
-
/* @__PURE__ */ (0,
|
|
3899
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { ref: rootRef, className: cn("sl-spreepay", appProps.className), children: [
|
|
3900
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "sl-spreepay__portal" }),
|
|
3693
3901
|
getContent()
|
|
3694
3902
|
] });
|
|
3695
3903
|
};
|
|
3696
3904
|
var SpreePay = (props) => {
|
|
3697
|
-
return /* @__PURE__ */ (0,
|
|
3905
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(StaticConfigProvider, { props, children: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(SpreePayInner, {}) });
|
|
3698
3906
|
};
|
|
3699
3907
|
|
|
3700
3908
|
// src/hooks/useCapture3DS.ts
|
|
3701
|
-
var
|
|
3909
|
+
var import_react20 = require("react");
|
|
3702
3910
|
var useCapture3DS = (searchParams) => {
|
|
3703
|
-
(0,
|
|
3911
|
+
(0, import_react20.useEffect)(() => {
|
|
3704
3912
|
if (typeof window !== "undefined" && window.parent && searchParams?.paymentIntent) {
|
|
3705
3913
|
window.parent.SP_EVENT_BUS?.emit("paymentIntent", { paymentIntent: searchParams.paymentIntent });
|
|
3706
3914
|
}
|