@superlogic/spree-pay 0.1.27 → 0.1.29
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 +54 -23
- package/build/index.css +43 -9
- package/build/index.d.cts +2 -0
- package/build/index.d.ts +2 -0
- package/build/index.js +66 -35
- package/package.json +1 -1
package/build/index.cjs
CHANGED
|
@@ -44,7 +44,7 @@ var import_nice_modal_react7 = __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.29";
|
|
48
48
|
|
|
49
49
|
// src/context/SpreePayActionsContext.tsx
|
|
50
50
|
var import_react = require("react");
|
|
@@ -323,9 +323,10 @@ var getTransactionFee = (amount = 0, transactionFeePercentage) => {
|
|
|
323
323
|
// src/components/CheckoutButton.tsx
|
|
324
324
|
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
325
325
|
var CheckoutButton = ({ isLoggedIn }) => {
|
|
326
|
-
const { appProps } = useStaticConfig();
|
|
326
|
+
const { appProps, staticConfig } = useStaticConfig();
|
|
327
327
|
const { amount, onProcess, isProcessing, transactionFeePercentage } = appProps;
|
|
328
328
|
const { spreePayConfig } = useSpreePayConfig();
|
|
329
|
+
const { env } = useSpreePayEnv();
|
|
329
330
|
const { selectedPaymentMethod, isInternalProcessing } = useSpreePaymentMethod();
|
|
330
331
|
const { splitAmount, type, method } = selectedPaymentMethod;
|
|
331
332
|
const usdAmount = getSplitAmount(amount ?? 0, splitAmount ?? 0, spreePayConfig?.pointsConversionRatio);
|
|
@@ -360,7 +361,7 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
360
361
|
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("a", { className: "underline", href: spreePayConfig?.termsConditionsUrl, target: "_blank", rel: "noreferrer", children: "Terms and Conditions" }),
|
|
361
362
|
"."
|
|
362
363
|
] }) }),
|
|
363
|
-
onProcess && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
364
|
+
isLoggedIn ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: onProcess && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
364
365
|
"button",
|
|
365
366
|
{
|
|
366
367
|
disabled: isDisabled,
|
|
@@ -368,6 +369,13 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
368
369
|
className: "bg-primary h-[60px] w-full cursor-pointer text-xl font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50",
|
|
369
370
|
children: getCheckoutContent()
|
|
370
371
|
}
|
|
372
|
+
) }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
373
|
+
"a",
|
|
374
|
+
{
|
|
375
|
+
href: `${staticConfig.keycloakUrl}/realms/${env.tenantId}/protocol/openid-connect/logout?client_id=${staticConfig.keycloakClientId}&post_logout_redirect_uri=${window.location.origin}${window.location.pathname}`,
|
|
376
|
+
className: "bg-primary h-[60px] w-full cursor-pointer text-center text-xl leading-[60px] font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50",
|
|
377
|
+
children: "Login"
|
|
378
|
+
}
|
|
371
379
|
)
|
|
372
380
|
] });
|
|
373
381
|
};
|
|
@@ -1308,24 +1316,43 @@ var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
|
1308
1316
|
var PointsSwitch = (props) => {
|
|
1309
1317
|
const { disabled = false, value, onChange, message } = props;
|
|
1310
1318
|
const { spreePayConfig } = useSpreePayConfig();
|
|
1319
|
+
const { appProps } = useStaticConfig();
|
|
1311
1320
|
const { balance } = useSlapiBalance();
|
|
1312
1321
|
const id = (0, import_react7.useId)();
|
|
1313
1322
|
return /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex flex-col gap-6", children: [
|
|
1314
1323
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1315
1324
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
1316
1325
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)(Switch, { checked: value, onCheckedChange: onChange, disabled, id }),
|
|
1317
|
-
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1326
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)(
|
|
1327
|
+
Label,
|
|
1328
|
+
{
|
|
1329
|
+
htmlFor: id,
|
|
1330
|
+
className: "text-md flex-col items-baseline gap-0 leading-[1.3] font-semibold text-black sm:flex-row sm:gap-2 md:text-lg",
|
|
1331
|
+
children: [
|
|
1332
|
+
"Use Points ",
|
|
1333
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-xs font-medium", children: "Optional" })
|
|
1334
|
+
]
|
|
1335
|
+
}
|
|
1336
|
+
)
|
|
1321
1337
|
] }),
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1338
|
+
/* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-2.5", children: [
|
|
1339
|
+
balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("p", { className: "flex-1 text-right text-sm font-medium text-black", children: [
|
|
1340
|
+
formatPoints(balance.availablePoints, spreePayConfig?.pointsTitle),
|
|
1341
|
+
!!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)("span", { className: "text-black/50", children: ` ${formatUSD(balance.availablePoints * spreePayConfig.pointsConversionRatio)}` })
|
|
1342
|
+
] }) : null,
|
|
1343
|
+
Boolean(appProps.topUpLink) && /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1344
|
+
"a",
|
|
1345
|
+
{
|
|
1346
|
+
className: "bg-primary cursor-pointer rounded-full px-2 py-1.5 text-xs font-medium text-white",
|
|
1347
|
+
rel: "noreferrer",
|
|
1348
|
+
target: "_blank",
|
|
1349
|
+
href: appProps.topUpLink,
|
|
1350
|
+
children: "Top Up"
|
|
1351
|
+
}
|
|
1352
|
+
)
|
|
1353
|
+
] })
|
|
1327
1354
|
] }),
|
|
1328
|
-
message && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-
|
|
1355
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime15.jsxs)("div", { className: "flex items-center gap-1 rounded-sm border-1 border-[#006FD533] bg-[#006FD50D] p-1.5", children: [
|
|
1329
1356
|
/* @__PURE__ */ (0, import_jsx_runtime15.jsx)("svg", { className: "size-5 shrink-0", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
1330
1357
|
"path",
|
|
1331
1358
|
{
|
|
@@ -2371,16 +2398,17 @@ var PointsSelector = (props) => {
|
|
|
2371
2398
|
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white", children: isSelected && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "bg-primary h-2.5 w-2.5 rounded-full" }) })
|
|
2372
2399
|
}
|
|
2373
2400
|
),
|
|
2374
|
-
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "flex h-full w-full items-center justify-between gap-3 px-3", children })
|
|
2401
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "flex h-full w-full items-center justify-between gap-2 px-2 sm:gap-3 sm:px-3", children })
|
|
2375
2402
|
] }),
|
|
2376
|
-
isSelected && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "px-
|
|
2403
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)("div", { className: "px-2 pt-6 pb-2 sm:px-3 md:px-4", children: /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex justify-between gap-2 sm:gap-3", children: [
|
|
2377
2404
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsxs)("div", { className: "flex max-w-[100px] flex-col gap-1", children: [
|
|
2378
2405
|
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
2379
2406
|
Input,
|
|
2380
2407
|
{
|
|
2381
2408
|
readOnly: true,
|
|
2409
|
+
name: "points amount",
|
|
2382
2410
|
value: Math.round(splitTokens),
|
|
2383
|
-
className: "bg-white text-center font-medium",
|
|
2411
|
+
className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
|
|
2384
2412
|
onClick: (e) => e.stopPropagation()
|
|
2385
2413
|
}
|
|
2386
2414
|
),
|
|
@@ -2403,8 +2431,9 @@ var PointsSelector = (props) => {
|
|
|
2403
2431
|
Input,
|
|
2404
2432
|
{
|
|
2405
2433
|
readOnly: true,
|
|
2434
|
+
name: "usd amount",
|
|
2406
2435
|
value: formatUSD(usdAmount + getTransactionFee(usdAmount, appProps.transactionFeePercentage)),
|
|
2407
|
-
className: "bg-white text-center font-medium",
|
|
2436
|
+
className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
|
|
2408
2437
|
onClick: (e) => e.stopPropagation()
|
|
2409
2438
|
}
|
|
2410
2439
|
),
|
|
@@ -2452,7 +2481,7 @@ var SplitBlock = (props) => {
|
|
|
2452
2481
|
initWallet(spreePayConfig?.pointsChain);
|
|
2453
2482
|
}, [spreePayConfig?.pointsChain, initWallet]);
|
|
2454
2483
|
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(PointsSelector, { isDisabled: !walletReady, onSelect: () => onSelect("air"), isSelected, children: [
|
|
2455
|
-
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { className: "text-
|
|
2484
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)("p", { className: "text-left text-xs font-medium text-black sm:text-sm", children: [
|
|
2456
2485
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-black/50", children: "Available" }),
|
|
2457
2486
|
" ",
|
|
2458
2487
|
formatPoints(balance.availablePoints, pointsTitle),
|
|
@@ -2471,6 +2500,7 @@ var Points = () => {
|
|
|
2471
2500
|
const [selectedPointsType, setSelectedPointsType] = (0, import_react12.useState)(null);
|
|
2472
2501
|
const { setSelectedPaymentMethod, selectedPaymentMethod } = useSpreePaymentMethod();
|
|
2473
2502
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2503
|
+
const { appProps } = useStaticConfig();
|
|
2474
2504
|
const handleTogglePoints = (enabled) => {
|
|
2475
2505
|
setUsePoints(enabled);
|
|
2476
2506
|
if (!enabled) {
|
|
@@ -2485,7 +2515,7 @@ var Points = () => {
|
|
|
2485
2515
|
value: usePoints,
|
|
2486
2516
|
onChange: handleTogglePoints,
|
|
2487
2517
|
message: spreePayConfig?.creditCard.pointsInfoMessage,
|
|
2488
|
-
disabled: !spreePayConfig?.creditCard.enabled || !spreePayConfig?.creditCard.points
|
|
2518
|
+
disabled: !spreePayConfig?.creditCard.enabled || !spreePayConfig?.creditCard.points || appProps.disabledPoints
|
|
2489
2519
|
}
|
|
2490
2520
|
),
|
|
2491
2521
|
usePoints && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
@@ -3477,15 +3507,16 @@ var SpreePayInner = () => {
|
|
|
3477
3507
|
ssoPageURI: env?.ssoPageURI,
|
|
3478
3508
|
enabled: !env?.accessToken
|
|
3479
3509
|
});
|
|
3510
|
+
const _accessToken = env.accessToken ?? accessToken;
|
|
3480
3511
|
const slapiFetcher = (0, import_react18.useMemo)(() => {
|
|
3481
|
-
if (
|
|
3512
|
+
if (_accessToken) {
|
|
3482
3513
|
return registerApi({
|
|
3483
|
-
accessToken:
|
|
3514
|
+
accessToken: _accessToken,
|
|
3484
3515
|
tenantId,
|
|
3485
3516
|
baseUrl: staticConfig.slapiUrl
|
|
3486
3517
|
});
|
|
3487
3518
|
}
|
|
3488
|
-
}, [
|
|
3519
|
+
}, [_accessToken, staticConfig, tenantId]);
|
|
3489
3520
|
const getContent = () => {
|
|
3490
3521
|
if (isChecking) {
|
|
3491
3522
|
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "flex w-full flex-col", children: [
|
|
@@ -3503,7 +3534,7 @@ var SpreePayInner = () => {
|
|
|
3503
3534
|
revalidateOnFocus: false,
|
|
3504
3535
|
revalidateIfStale: false
|
|
3505
3536
|
},
|
|
3506
|
-
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_nice_modal_react7.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SpreePayContent, { isLoggedIn: Boolean(
|
|
3537
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(import_nice_modal_react7.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SpreePayContent, { isLoggedIn: Boolean(_accessToken) }) }) })
|
|
3507
3538
|
}
|
|
3508
3539
|
);
|
|
3509
3540
|
};
|
package/build/index.css
CHANGED
|
@@ -464,6 +464,9 @@
|
|
|
464
464
|
.sl-spreepay .min-w-0 {
|
|
465
465
|
min-width: calc(var(--spacing) * 0);
|
|
466
466
|
}
|
|
467
|
+
.sl-spreepay .min-w-\[80px\] {
|
|
468
|
+
min-width: 80px;
|
|
469
|
+
}
|
|
467
470
|
.sl-spreepay .flex-1 {
|
|
468
471
|
flex: 1;
|
|
469
472
|
}
|
|
@@ -511,9 +514,6 @@
|
|
|
511
514
|
.sl-spreepay .items-center {
|
|
512
515
|
align-items: center;
|
|
513
516
|
}
|
|
514
|
-
.sl-spreepay .items-start {
|
|
515
|
-
align-items: flex-start;
|
|
516
|
-
}
|
|
517
517
|
.sl-spreepay .justify-between {
|
|
518
518
|
justify-content: space-between;
|
|
519
519
|
}
|
|
@@ -535,6 +535,9 @@
|
|
|
535
535
|
.sl-spreepay .gap-2 {
|
|
536
536
|
gap: calc(var(--spacing) * 2);
|
|
537
537
|
}
|
|
538
|
+
.sl-spreepay .gap-2\.5 {
|
|
539
|
+
gap: calc(var(--spacing) * 2.5);
|
|
540
|
+
}
|
|
538
541
|
.sl-spreepay .gap-3 {
|
|
539
542
|
gap: calc(var(--spacing) * 3);
|
|
540
543
|
}
|
|
@@ -718,9 +721,15 @@
|
|
|
718
721
|
.sl-spreepay .p-6 {
|
|
719
722
|
padding: calc(var(--spacing) * 6);
|
|
720
723
|
}
|
|
724
|
+
.sl-spreepay .px-1 {
|
|
725
|
+
padding-inline: calc(var(--spacing) * 1);
|
|
726
|
+
}
|
|
721
727
|
.sl-spreepay .px-1\.5 {
|
|
722
728
|
padding-inline: calc(var(--spacing) * 1.5);
|
|
723
729
|
}
|
|
730
|
+
.sl-spreepay .px-2 {
|
|
731
|
+
padding-inline: calc(var(--spacing) * 2);
|
|
732
|
+
}
|
|
724
733
|
.sl-spreepay .px-2\.5 {
|
|
725
734
|
padding-inline: calc(var(--spacing) * 2.5);
|
|
726
735
|
}
|
|
@@ -818,6 +827,10 @@
|
|
|
818
827
|
--tw-leading: 34px;
|
|
819
828
|
line-height: 34px;
|
|
820
829
|
}
|
|
830
|
+
.sl-spreepay .leading-\[60px\] {
|
|
831
|
+
--tw-leading: 60px;
|
|
832
|
+
line-height: 60px;
|
|
833
|
+
}
|
|
821
834
|
.sl-spreepay .leading-none {
|
|
822
835
|
--tw-leading: 1;
|
|
823
836
|
line-height: 1;
|
|
@@ -1463,11 +1476,32 @@
|
|
|
1463
1476
|
justify-content: flex-end;
|
|
1464
1477
|
}
|
|
1465
1478
|
}
|
|
1479
|
+
.sl-spreepay .sm\:gap-2 {
|
|
1480
|
+
@media (width >= 40rem) {
|
|
1481
|
+
gap: calc(var(--spacing) * 2);
|
|
1482
|
+
}
|
|
1483
|
+
}
|
|
1484
|
+
.sl-spreepay .sm\:gap-3 {
|
|
1485
|
+
@media (width >= 40rem) {
|
|
1486
|
+
gap: calc(var(--spacing) * 3);
|
|
1487
|
+
}
|
|
1488
|
+
}
|
|
1489
|
+
.sl-spreepay .sm\:px-3 {
|
|
1490
|
+
@media (width >= 40rem) {
|
|
1491
|
+
padding-inline: calc(var(--spacing) * 3);
|
|
1492
|
+
}
|
|
1493
|
+
}
|
|
1466
1494
|
.sl-spreepay .sm\:text-left {
|
|
1467
1495
|
@media (width >= 40rem) {
|
|
1468
1496
|
text-align: left;
|
|
1469
1497
|
}
|
|
1470
1498
|
}
|
|
1499
|
+
.sl-spreepay .sm\:text-sm {
|
|
1500
|
+
@media (width >= 40rem) {
|
|
1501
|
+
font-size: var(--text-sm);
|
|
1502
|
+
line-height: var(--tw-leading, var(--text-sm--line-height));
|
|
1503
|
+
}
|
|
1504
|
+
}
|
|
1471
1505
|
.sl-spreepay .md\:block {
|
|
1472
1506
|
@media (width >= 48rem) {
|
|
1473
1507
|
display: block;
|
|
@@ -1498,16 +1532,16 @@
|
|
|
1498
1532
|
padding-bottom: calc(var(--spacing) * 7);
|
|
1499
1533
|
}
|
|
1500
1534
|
}
|
|
1501
|
-
.sl-spreepay .md\:text-
|
|
1535
|
+
.sl-spreepay .md\:text-lg {
|
|
1502
1536
|
@media (width >= 48rem) {
|
|
1503
|
-
font-size: var(--text-
|
|
1504
|
-
line-height: var(--tw-leading, var(--text-
|
|
1537
|
+
font-size: var(--text-lg);
|
|
1538
|
+
line-height: var(--tw-leading, var(--text-lg--line-height));
|
|
1505
1539
|
}
|
|
1506
1540
|
}
|
|
1507
|
-
.sl-spreepay .md\:text-
|
|
1541
|
+
.sl-spreepay .md\:text-sm {
|
|
1508
1542
|
@media (width >= 48rem) {
|
|
1509
|
-
font-size: var(--text-
|
|
1510
|
-
line-height: var(--tw-leading, var(--text-
|
|
1543
|
+
font-size: var(--text-sm);
|
|
1544
|
+
line-height: var(--tw-leading, var(--text-sm--line-height));
|
|
1511
1545
|
}
|
|
1512
1546
|
}
|
|
1513
1547
|
.sl-spreepay .dark\:border-input {
|
package/build/index.d.cts
CHANGED
package/build/index.d.ts
CHANGED
package/build/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import NiceModal7 from "@ebay/nice-modal-react";
|
|
|
4
4
|
import { SWRConfig } from "swr";
|
|
5
5
|
|
|
6
6
|
// package.json
|
|
7
|
-
var version = "0.1.
|
|
7
|
+
var version = "0.1.29";
|
|
8
8
|
|
|
9
9
|
// src/context/SpreePayActionsContext.tsx
|
|
10
10
|
import { createContext, useCallback, useContext, useRef, useState } from "react";
|
|
@@ -281,11 +281,12 @@ var getTransactionFee = (amount = 0, transactionFeePercentage) => {
|
|
|
281
281
|
};
|
|
282
282
|
|
|
283
283
|
// src/components/CheckoutButton.tsx
|
|
284
|
-
import { jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
284
|
+
import { Fragment, jsx as jsx4, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
285
285
|
var CheckoutButton = ({ isLoggedIn }) => {
|
|
286
|
-
const { appProps } = useStaticConfig();
|
|
286
|
+
const { appProps, staticConfig } = useStaticConfig();
|
|
287
287
|
const { amount, onProcess, isProcessing, transactionFeePercentage } = appProps;
|
|
288
288
|
const { spreePayConfig } = useSpreePayConfig();
|
|
289
|
+
const { env } = useSpreePayEnv();
|
|
289
290
|
const { selectedPaymentMethod, isInternalProcessing } = useSpreePaymentMethod();
|
|
290
291
|
const { splitAmount, type, method } = selectedPaymentMethod;
|
|
291
292
|
const usdAmount = getSplitAmount(amount ?? 0, splitAmount ?? 0, spreePayConfig?.pointsConversionRatio);
|
|
@@ -320,7 +321,7 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
320
321
|
/* @__PURE__ */ jsx4("a", { className: "underline", href: spreePayConfig?.termsConditionsUrl, target: "_blank", rel: "noreferrer", children: "Terms and Conditions" }),
|
|
321
322
|
"."
|
|
322
323
|
] }) }),
|
|
323
|
-
onProcess && /* @__PURE__ */ jsx4(
|
|
324
|
+
isLoggedIn ? /* @__PURE__ */ jsx4(Fragment, { children: onProcess && /* @__PURE__ */ jsx4(
|
|
324
325
|
"button",
|
|
325
326
|
{
|
|
326
327
|
disabled: isDisabled,
|
|
@@ -328,6 +329,13 @@ var CheckoutButton = ({ isLoggedIn }) => {
|
|
|
328
329
|
className: "bg-primary h-[60px] w-full cursor-pointer text-xl font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50",
|
|
329
330
|
children: getCheckoutContent()
|
|
330
331
|
}
|
|
332
|
+
) }) : /* @__PURE__ */ jsx4(
|
|
333
|
+
"a",
|
|
334
|
+
{
|
|
335
|
+
href: `${staticConfig.keycloakUrl}/realms/${env.tenantId}/protocol/openid-connect/logout?client_id=${staticConfig.keycloakClientId}&post_logout_redirect_uri=${window.location.origin}${window.location.pathname}`,
|
|
336
|
+
className: "bg-primary h-[60px] w-full cursor-pointer text-center text-xl leading-[60px] font-semibold text-white disabled:cursor-not-allowed disabled:opacity-50",
|
|
337
|
+
children: "Login"
|
|
338
|
+
}
|
|
331
339
|
)
|
|
332
340
|
] });
|
|
333
341
|
};
|
|
@@ -1083,7 +1091,7 @@ function Label({ className, ...props }) {
|
|
|
1083
1091
|
}
|
|
1084
1092
|
|
|
1085
1093
|
// src/components/CreditCardTab/CreditCard/CreditCardForm.tsx
|
|
1086
|
-
import { Fragment, jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1094
|
+
import { Fragment as Fragment2, jsx as jsx12, jsxs as jsxs7 } from "react/jsx-runtime";
|
|
1087
1095
|
var style = {
|
|
1088
1096
|
base: {
|
|
1089
1097
|
fontSize: "16px",
|
|
@@ -1141,7 +1149,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
1141
1149
|
setCardError("An error occurred while processing your card. Please try again.");
|
|
1142
1150
|
}
|
|
1143
1151
|
};
|
|
1144
|
-
return /* @__PURE__ */ jsxs7(
|
|
1152
|
+
return /* @__PURE__ */ jsxs7(Fragment2, { children: [
|
|
1145
1153
|
/* @__PURE__ */ jsxs7("div", { className: "flex w-full flex-col gap-1", children: [
|
|
1146
1154
|
/* @__PURE__ */ jsx12(
|
|
1147
1155
|
CardNumberElement,
|
|
@@ -1189,7 +1197,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
1189
1197
|
};
|
|
1190
1198
|
|
|
1191
1199
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
1192
|
-
import { Fragment as
|
|
1200
|
+
import { Fragment as Fragment3, jsx as jsx13, jsxs as jsxs8 } from "react/jsx-runtime";
|
|
1193
1201
|
var StripeWrapper = (props) => {
|
|
1194
1202
|
const stripePromise = useMemo2(() => loadStripe(props.publicKey), [props.publicKey]);
|
|
1195
1203
|
return /* @__PURE__ */ jsx13(Elements, { stripe: stripePromise, children: /* @__PURE__ */ jsx13(CreditCardForm, { cancel: props.onCancel, saveCard: props.saveNewCard }) });
|
|
@@ -1212,7 +1220,7 @@ var CreditCard = () => {
|
|
|
1212
1220
|
};
|
|
1213
1221
|
return /* @__PURE__ */ jsxs8("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
1214
1222
|
/* @__PURE__ */ jsx13("h3", { className: "text-primary text-xl leading-[34px] font-semibold", children: "Your Credit Cards" }),
|
|
1215
|
-
!showForm && /* @__PURE__ */ jsxs8(
|
|
1223
|
+
!showForm && /* @__PURE__ */ jsxs8(Fragment3, { children: [
|
|
1216
1224
|
/* @__PURE__ */ jsx13(
|
|
1217
1225
|
CardsList,
|
|
1218
1226
|
{
|
|
@@ -1268,24 +1276,43 @@ import { jsx as jsx15, jsxs as jsxs9 } from "react/jsx-runtime";
|
|
|
1268
1276
|
var PointsSwitch = (props) => {
|
|
1269
1277
|
const { disabled = false, value, onChange, message } = props;
|
|
1270
1278
|
const { spreePayConfig } = useSpreePayConfig();
|
|
1279
|
+
const { appProps } = useStaticConfig();
|
|
1271
1280
|
const { balance } = useSlapiBalance();
|
|
1272
1281
|
const id = useId2();
|
|
1273
1282
|
return /* @__PURE__ */ jsxs9("div", { className: "flex flex-col gap-6", children: [
|
|
1274
1283
|
/* @__PURE__ */ jsxs9("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1275
1284
|
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-3", children: [
|
|
1276
1285
|
/* @__PURE__ */ jsx15(Switch, { checked: value, onCheckedChange: onChange, disabled, id }),
|
|
1277
|
-
/* @__PURE__ */ jsxs9(
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1286
|
+
/* @__PURE__ */ jsxs9(
|
|
1287
|
+
Label,
|
|
1288
|
+
{
|
|
1289
|
+
htmlFor: id,
|
|
1290
|
+
className: "text-md flex-col items-baseline gap-0 leading-[1.3] font-semibold text-black sm:flex-row sm:gap-2 md:text-lg",
|
|
1291
|
+
children: [
|
|
1292
|
+
"Use Points ",
|
|
1293
|
+
/* @__PURE__ */ jsx15("span", { className: "text-xs font-medium", children: "Optional" })
|
|
1294
|
+
]
|
|
1295
|
+
}
|
|
1296
|
+
)
|
|
1281
1297
|
] }),
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1298
|
+
/* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-2.5", children: [
|
|
1299
|
+
balance?.availablePoints ? /* @__PURE__ */ jsxs9("p", { className: "flex-1 text-right text-sm font-medium text-black", children: [
|
|
1300
|
+
formatPoints(balance.availablePoints, spreePayConfig?.pointsTitle),
|
|
1301
|
+
!!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ jsx15("span", { className: "text-black/50", children: ` ${formatUSD(balance.availablePoints * spreePayConfig.pointsConversionRatio)}` })
|
|
1302
|
+
] }) : null,
|
|
1303
|
+
Boolean(appProps.topUpLink) && /* @__PURE__ */ jsx15(
|
|
1304
|
+
"a",
|
|
1305
|
+
{
|
|
1306
|
+
className: "bg-primary cursor-pointer rounded-full px-2 py-1.5 text-xs font-medium text-white",
|
|
1307
|
+
rel: "noreferrer",
|
|
1308
|
+
target: "_blank",
|
|
1309
|
+
href: appProps.topUpLink,
|
|
1310
|
+
children: "Top Up"
|
|
1311
|
+
}
|
|
1312
|
+
)
|
|
1313
|
+
] })
|
|
1287
1314
|
] }),
|
|
1288
|
-
message && /* @__PURE__ */ jsxs9("div", { className: "flex items-
|
|
1315
|
+
message && /* @__PURE__ */ jsxs9("div", { className: "flex items-center gap-1 rounded-sm border-1 border-[#006FD533] bg-[#006FD50D] p-1.5", children: [
|
|
1289
1316
|
/* @__PURE__ */ jsx15("svg", { className: "size-5 shrink-0", xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 20 20", children: /* @__PURE__ */ jsx15(
|
|
1290
1317
|
"path",
|
|
1291
1318
|
{
|
|
@@ -2331,16 +2358,17 @@ var PointsSelector = (props) => {
|
|
|
2331
2358
|
children: /* @__PURE__ */ jsx24("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white", children: isSelected && /* @__PURE__ */ jsx24("div", { className: "bg-primary h-2.5 w-2.5 rounded-full" }) })
|
|
2332
2359
|
}
|
|
2333
2360
|
),
|
|
2334
|
-
/* @__PURE__ */ jsx24("div", { className: "flex h-full w-full items-center justify-between gap-3 px-3", children })
|
|
2361
|
+
/* @__PURE__ */ jsx24("div", { className: "flex h-full w-full items-center justify-between gap-2 px-2 sm:gap-3 sm:px-3", children })
|
|
2335
2362
|
] }),
|
|
2336
|
-
isSelected && /* @__PURE__ */ jsx24("div", { className: "px-
|
|
2363
|
+
isSelected && /* @__PURE__ */ jsx24("div", { className: "px-2 pt-6 pb-2 sm:px-3 md:px-4", children: /* @__PURE__ */ jsxs12("div", { className: "flex justify-between gap-2 sm:gap-3", children: [
|
|
2337
2364
|
/* @__PURE__ */ jsxs12("div", { className: "flex max-w-[100px] flex-col gap-1", children: [
|
|
2338
2365
|
/* @__PURE__ */ jsx24(
|
|
2339
2366
|
Input,
|
|
2340
2367
|
{
|
|
2341
2368
|
readOnly: true,
|
|
2369
|
+
name: "points amount",
|
|
2342
2370
|
value: Math.round(splitTokens),
|
|
2343
|
-
className: "bg-white text-center font-medium",
|
|
2371
|
+
className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
|
|
2344
2372
|
onClick: (e) => e.stopPropagation()
|
|
2345
2373
|
}
|
|
2346
2374
|
),
|
|
@@ -2363,8 +2391,9 @@ var PointsSelector = (props) => {
|
|
|
2363
2391
|
Input,
|
|
2364
2392
|
{
|
|
2365
2393
|
readOnly: true,
|
|
2394
|
+
name: "usd amount",
|
|
2366
2395
|
value: formatUSD(usdAmount + getTransactionFee(usdAmount, appProps.transactionFeePercentage)),
|
|
2367
|
-
className: "bg-white text-center font-medium",
|
|
2396
|
+
className: "sm:text-md min-w-[80px] bg-white px-1 text-center text-xs font-medium sm:px-3",
|
|
2368
2397
|
onClick: (e) => e.stopPropagation()
|
|
2369
2398
|
}
|
|
2370
2399
|
),
|
|
@@ -2412,7 +2441,7 @@ var SplitBlock = (props) => {
|
|
|
2412
2441
|
initWallet(spreePayConfig?.pointsChain);
|
|
2413
2442
|
}, [spreePayConfig?.pointsChain, initWallet]);
|
|
2414
2443
|
return /* @__PURE__ */ jsx25("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ jsxs13(PointsSelector, { isDisabled: !walletReady, onSelect: () => onSelect("air"), isSelected, children: [
|
|
2415
|
-
/* @__PURE__ */ jsx25("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ jsxs13("p", { className: "text-
|
|
2444
|
+
/* @__PURE__ */ jsx25("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ jsxs13("p", { className: "text-left text-xs font-medium text-black sm:text-sm", children: [
|
|
2416
2445
|
/* @__PURE__ */ jsx25("span", { className: "text-black/50", children: "Available" }),
|
|
2417
2446
|
" ",
|
|
2418
2447
|
formatPoints(balance.availablePoints, pointsTitle),
|
|
@@ -2425,12 +2454,13 @@ var SplitBlock = (props) => {
|
|
|
2425
2454
|
};
|
|
2426
2455
|
|
|
2427
2456
|
// src/components/CreditCardTab/Points/Points.tsx
|
|
2428
|
-
import { Fragment as
|
|
2457
|
+
import { Fragment as Fragment4, jsx as jsx26, jsxs as jsxs14 } from "react/jsx-runtime";
|
|
2429
2458
|
var Points = () => {
|
|
2430
2459
|
const [usePoints, setUsePoints] = useState10(false);
|
|
2431
2460
|
const [selectedPointsType, setSelectedPointsType] = useState10(null);
|
|
2432
2461
|
const { setSelectedPaymentMethod, selectedPaymentMethod } = useSpreePaymentMethod();
|
|
2433
2462
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2463
|
+
const { appProps } = useStaticConfig();
|
|
2434
2464
|
const handleTogglePoints = (enabled) => {
|
|
2435
2465
|
setUsePoints(enabled);
|
|
2436
2466
|
if (!enabled) {
|
|
@@ -2438,14 +2468,14 @@ var Points = () => {
|
|
|
2438
2468
|
setSelectedPaymentMethod({ ...selectedPaymentMethod, splitAmount: void 0 });
|
|
2439
2469
|
}
|
|
2440
2470
|
};
|
|
2441
|
-
return /* @__PURE__ */ jsxs14(
|
|
2471
|
+
return /* @__PURE__ */ jsxs14(Fragment4, { children: [
|
|
2442
2472
|
/* @__PURE__ */ jsx26(
|
|
2443
2473
|
PointsSwitch,
|
|
2444
2474
|
{
|
|
2445
2475
|
value: usePoints,
|
|
2446
2476
|
onChange: handleTogglePoints,
|
|
2447
2477
|
message: spreePayConfig?.creditCard.pointsInfoMessage,
|
|
2448
|
-
disabled: !spreePayConfig?.creditCard.enabled || !spreePayConfig?.creditCard.points
|
|
2478
|
+
disabled: !spreePayConfig?.creditCard.enabled || !spreePayConfig?.creditCard.points || appProps.disabledPoints
|
|
2449
2479
|
}
|
|
2450
2480
|
),
|
|
2451
2481
|
usePoints && /* @__PURE__ */ jsx26(
|
|
@@ -2696,11 +2726,11 @@ var useCryptoPayment = () => {
|
|
|
2696
2726
|
|
|
2697
2727
|
// src/components/CryptoTab/Crypto/ConnectButton.tsx
|
|
2698
2728
|
import { ConnectButton as RainbowButton } from "@rainbow-me/rainbowkit";
|
|
2699
|
-
import { Fragment as
|
|
2729
|
+
import { Fragment as Fragment5, jsx as jsx28, jsxs as jsxs16 } from "react/jsx-runtime";
|
|
2700
2730
|
var ConnectButton = () => {
|
|
2701
2731
|
return /* @__PURE__ */ jsx28(RainbowButton.Custom, { children: ({ mounted, chain, account, openAccountModal, openChainModal, openConnectModal }) => {
|
|
2702
2732
|
if (!mounted) return null;
|
|
2703
|
-
return /* @__PURE__ */ jsx28(
|
|
2733
|
+
return /* @__PURE__ */ jsx28(Fragment5, { children: (() => {
|
|
2704
2734
|
if (!mounted || !account || !chain) {
|
|
2705
2735
|
return /* @__PURE__ */ jsx28(
|
|
2706
2736
|
"button",
|
|
@@ -3014,7 +3044,7 @@ var useBaseTokens = () => {
|
|
|
3014
3044
|
};
|
|
3015
3045
|
|
|
3016
3046
|
// src/modals/CryptoSelectModal.tsx
|
|
3017
|
-
import { Fragment as
|
|
3047
|
+
import { Fragment as Fragment6, jsx as jsx34, jsxs as jsxs19 } from "react/jsx-runtime";
|
|
3018
3048
|
var CryptoSelectModal = NiceModal4.create(() => {
|
|
3019
3049
|
const modal = useModal2();
|
|
3020
3050
|
const { isLoading, error, erc20Balances } = useBaseERC20Token();
|
|
@@ -3078,7 +3108,7 @@ var CryptoSelectModal = NiceModal4.create(() => {
|
|
|
3078
3108
|
},
|
|
3079
3109
|
nativeBalance.symbol
|
|
3080
3110
|
),
|
|
3081
|
-
isLoading && /* @__PURE__ */ jsxs19(
|
|
3111
|
+
isLoading && /* @__PURE__ */ jsxs19(Fragment6, { children: [
|
|
3082
3112
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3083
3113
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3084
3114
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
|
|
@@ -3104,7 +3134,7 @@ var CryptoSelectModal = NiceModal4.create(() => {
|
|
|
3104
3134
|
] }),
|
|
3105
3135
|
/* @__PURE__ */ jsx34("h3", { className: "text-primary text-xl font-semibold", children: "All Tokens" }),
|
|
3106
3136
|
/* @__PURE__ */ jsxs19("div", { className: "flex max-h-[40vh] w-full flex-col gap-1 overflow-y-auto", children: [
|
|
3107
|
-
tokensIsLoading && /* @__PURE__ */ jsxs19(
|
|
3137
|
+
tokensIsLoading && /* @__PURE__ */ jsxs19(Fragment6, { children: [
|
|
3108
3138
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3109
3139
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3110
3140
|
/* @__PURE__ */ jsx34("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
|
|
@@ -3437,15 +3467,16 @@ var SpreePayInner = () => {
|
|
|
3437
3467
|
ssoPageURI: env?.ssoPageURI,
|
|
3438
3468
|
enabled: !env?.accessToken
|
|
3439
3469
|
});
|
|
3470
|
+
const _accessToken = env.accessToken ?? accessToken;
|
|
3440
3471
|
const slapiFetcher = useMemo9(() => {
|
|
3441
|
-
if (
|
|
3472
|
+
if (_accessToken) {
|
|
3442
3473
|
return registerApi({
|
|
3443
|
-
accessToken:
|
|
3474
|
+
accessToken: _accessToken,
|
|
3444
3475
|
tenantId,
|
|
3445
3476
|
baseUrl: staticConfig.slapiUrl
|
|
3446
3477
|
});
|
|
3447
3478
|
}
|
|
3448
|
-
}, [
|
|
3479
|
+
}, [_accessToken, staticConfig, tenantId]);
|
|
3449
3480
|
const getContent = () => {
|
|
3450
3481
|
if (isChecking) {
|
|
3451
3482
|
return /* @__PURE__ */ jsxs27("div", { className: "flex w-full flex-col", children: [
|
|
@@ -3463,7 +3494,7 @@ var SpreePayInner = () => {
|
|
|
3463
3494
|
revalidateOnFocus: false,
|
|
3464
3495
|
revalidateIfStale: false
|
|
3465
3496
|
},
|
|
3466
|
-
children: /* @__PURE__ */ jsx43(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ jsx43(NiceModal7.Provider, { children: /* @__PURE__ */ jsx43(SpreePayContent, { isLoggedIn: Boolean(
|
|
3497
|
+
children: /* @__PURE__ */ jsx43(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ jsx43(NiceModal7.Provider, { children: /* @__PURE__ */ jsx43(SpreePayContent, { isLoggedIn: Boolean(_accessToken) }) }) })
|
|
3467
3498
|
}
|
|
3468
3499
|
);
|
|
3469
3500
|
};
|