@superlogic/spree-pay 0.4.2 → 0.4.8
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/{CryptoComTab-GNJ4XACU.js → CryptoComTab-3SEGMLPB.js} +2 -2
- package/build/{CryptoTab-RY2NTNZJ.js → CryptoTab-DQCQF6BG.js} +4 -4
- package/build/{chunk-4ELDS4N4.js → chunk-EXKCBGNL.js} +1 -1
- package/build/{chunk-I35SE3K2.js → chunk-SKM7ZAUY.js} +3 -1
- package/build/{chunk-LXX5P2LL.js → chunk-W43VOUYP.js} +51 -2
- package/build/index.cjs +200 -110
- package/build/index.css +5 -14
- package/build/index.js +85 -49
- package/package.json +5 -3
- package/src/styles/bridge.css +53 -0
package/build/index.cjs
CHANGED
|
@@ -49,10 +49,11 @@ var init_errors = __esm({
|
|
|
49
49
|
});
|
|
50
50
|
|
|
51
51
|
// src/types/payments.ts
|
|
52
|
-
var PaymentType;
|
|
52
|
+
var isNewCard, PaymentType;
|
|
53
53
|
var init_payments = __esm({
|
|
54
54
|
"src/types/payments.ts"() {
|
|
55
55
|
"use strict";
|
|
56
|
+
isNewCard = (card) => !("cardId" in card);
|
|
56
57
|
PaymentType = /* @__PURE__ */ ((PaymentType2) => {
|
|
57
58
|
PaymentType2["CREDIT_CARD"] = "CREDIT_CARD";
|
|
58
59
|
PaymentType2["CRYPTO"] = "CRYPTO";
|
|
@@ -68,7 +69,7 @@ var init_payments = __esm({
|
|
|
68
69
|
var version;
|
|
69
70
|
var init_package = __esm({
|
|
70
71
|
"package.json"() {
|
|
71
|
-
version = "0.4.
|
|
72
|
+
version = "0.4.8";
|
|
72
73
|
}
|
|
73
74
|
});
|
|
74
75
|
|
|
@@ -1128,11 +1129,11 @@ var init_InfoBanner = __esm({
|
|
|
1128
1129
|
});
|
|
1129
1130
|
|
|
1130
1131
|
// src/components/common/PointsSwitch.tsx
|
|
1131
|
-
var
|
|
1132
|
+
var import_react6, import_jsx_runtime9, PointsSwitch;
|
|
1132
1133
|
var init_PointsSwitch = __esm({
|
|
1133
1134
|
"src/components/common/PointsSwitch.tsx"() {
|
|
1134
1135
|
"use strict";
|
|
1135
|
-
|
|
1136
|
+
import_react6 = require("react");
|
|
1136
1137
|
init_StaticConfigContext();
|
|
1137
1138
|
init_useSlapiBalance();
|
|
1138
1139
|
init_useSpreePayConfig();
|
|
@@ -1149,7 +1150,7 @@ var init_PointsSwitch = __esm({
|
|
|
1149
1150
|
const { balance } = useSlapiBalance();
|
|
1150
1151
|
const hasForeignCurrency = !!(currencyCode && exchangeRate && foreignCurrencyAmount);
|
|
1151
1152
|
const formatPointsValue = (usd) => hasForeignCurrency ? formatCurrency(usd / exchangeRate, currencyCode) : formatCurrency(usd);
|
|
1152
|
-
const id = (0,
|
|
1153
|
+
const id = (0, import_react6.useId)();
|
|
1153
1154
|
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex flex-col gap-6", children: [
|
|
1154
1155
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1155
1156
|
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
@@ -1321,14 +1322,63 @@ var init_CheckoutButton = __esm({
|
|
|
1321
1322
|
|
|
1322
1323
|
// ../ui/src/lib/utils.ts
|
|
1323
1324
|
function cn2(...inputs) {
|
|
1324
|
-
return (
|
|
1325
|
+
return twMerge2((0, import_clsx2.clsx)(inputs));
|
|
1325
1326
|
}
|
|
1326
|
-
var import_clsx2, import_tailwind_merge2;
|
|
1327
|
+
var import_clsx2, import_tailwind_merge2, isUniversalSpacing, isLayoutToken, isUniversalRadius, isTypography, twMerge2;
|
|
1327
1328
|
var init_utils2 = __esm({
|
|
1328
1329
|
"../ui/src/lib/utils.ts"() {
|
|
1329
1330
|
"use strict";
|
|
1330
1331
|
import_clsx2 = require("clsx");
|
|
1331
1332
|
import_tailwind_merge2 = require("tailwind-merge");
|
|
1333
|
+
isUniversalSpacing = (value) => value.startsWith("universal-");
|
|
1334
|
+
isLayoutToken = (value) => value.startsWith("universal-") || value.startsWith("layout-");
|
|
1335
|
+
isUniversalRadius = (value) => value.startsWith("radius-universal-");
|
|
1336
|
+
isTypography = (value) => value.startsWith("heading-") || value.startsWith("body-") || value.startsWith("label-") || value.startsWith("menu-");
|
|
1337
|
+
twMerge2 = (0, import_tailwind_merge2.extendTailwindMerge)({
|
|
1338
|
+
extend: {
|
|
1339
|
+
classGroups: {
|
|
1340
|
+
"font-size": [{ text: [isTypography] }],
|
|
1341
|
+
leading: [{ leading: [isTypography] }],
|
|
1342
|
+
"font-weight": [{ font: [isTypography] }],
|
|
1343
|
+
p: [{ p: [isUniversalSpacing] }],
|
|
1344
|
+
px: [{ px: [isUniversalSpacing] }],
|
|
1345
|
+
py: [{ py: [isUniversalSpacing] }],
|
|
1346
|
+
pt: [{ pt: [isUniversalSpacing] }],
|
|
1347
|
+
pb: [{ pb: [isUniversalSpacing] }],
|
|
1348
|
+
pl: [{ pl: [isUniversalSpacing] }],
|
|
1349
|
+
pr: [{ pr: [isUniversalSpacing] }],
|
|
1350
|
+
m: [{ m: [isUniversalSpacing] }],
|
|
1351
|
+
mx: [{ mx: [isUniversalSpacing] }],
|
|
1352
|
+
my: [{ my: [isUniversalSpacing] }],
|
|
1353
|
+
mt: [{ mt: [isUniversalSpacing] }],
|
|
1354
|
+
mb: [{ mb: [isUniversalSpacing] }],
|
|
1355
|
+
ml: [{ ml: [isUniversalSpacing] }],
|
|
1356
|
+
mr: [{ mr: [isUniversalSpacing] }],
|
|
1357
|
+
gap: [{ gap: [isUniversalSpacing] }],
|
|
1358
|
+
"gap-x": [{ "gap-x": [isUniversalSpacing] }],
|
|
1359
|
+
"gap-y": [{ "gap-y": [isUniversalSpacing] }],
|
|
1360
|
+
"space-x": [{ "space-x": [isUniversalSpacing] }],
|
|
1361
|
+
"space-y": [{ "space-y": [isUniversalSpacing] }],
|
|
1362
|
+
w: [{ w: [isLayoutToken] }],
|
|
1363
|
+
"min-w": [{ "min-w": [isLayoutToken] }],
|
|
1364
|
+
"max-w": [{ "max-w": [isLayoutToken] }],
|
|
1365
|
+
h: [{ h: [isLayoutToken] }],
|
|
1366
|
+
"min-h": [{ "min-h": [isLayoutToken] }],
|
|
1367
|
+
"max-h": [{ "max-h": [isLayoutToken] }],
|
|
1368
|
+
rounded: [{ rounded: [isUniversalRadius] }],
|
|
1369
|
+
"rounded-s": [{ "rounded-s": [isUniversalRadius] }],
|
|
1370
|
+
"rounded-e": [{ "rounded-e": [isUniversalRadius] }],
|
|
1371
|
+
"rounded-t": [{ "rounded-t": [isUniversalRadius] }],
|
|
1372
|
+
"rounded-r": [{ "rounded-r": [isUniversalRadius] }],
|
|
1373
|
+
"rounded-b": [{ "rounded-b": [isUniversalRadius] }],
|
|
1374
|
+
"rounded-l": [{ "rounded-l": [isUniversalRadius] }],
|
|
1375
|
+
"rounded-tl": [{ "rounded-tl": [isUniversalRadius] }],
|
|
1376
|
+
"rounded-tr": [{ "rounded-tr": [isUniversalRadius] }],
|
|
1377
|
+
"rounded-br": [{ "rounded-br": [isUniversalRadius] }],
|
|
1378
|
+
"rounded-bl": [{ "rounded-bl": [isUniversalRadius] }]
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
});
|
|
1332
1382
|
}
|
|
1333
1383
|
});
|
|
1334
1384
|
|
|
@@ -1764,7 +1814,7 @@ function Input2({ className, type, ...props }) {
|
|
|
1764
1814
|
type,
|
|
1765
1815
|
"data-slot": "input",
|
|
1766
1816
|
className: cn2(
|
|
1767
|
-
"file:text-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input flex h-9 w-full min-w-0
|
|
1817
|
+
"file:text-foreground selection:bg-primary selection:text-primary-foreground dark:bg-input/30 border-input px-universal-2xs py-universal-6xs rounded-radius-universal-xs text-body-m file:text-label-s file:font-label-primary flex h-9 w-full min-w-0 border bg-transparent text-(--color-text-icons-primary-default) shadow-xs transition-[color,box-shadow] outline-none file:inline-flex file:h-7 file:border-0 file:bg-transparent placeholder:text-(--color-text-icons-tertiary-default) disabled:pointer-events-none disabled:cursor-not-allowed disabled:opacity-50",
|
|
1768
1818
|
"focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px]",
|
|
1769
1819
|
"aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
1770
1820
|
className
|
|
@@ -1874,7 +1924,7 @@ function Separator2({
|
|
|
1874
1924
|
decorative,
|
|
1875
1925
|
orientation,
|
|
1876
1926
|
className: cn2(
|
|
1877
|
-
"shrink-0 bg-(--
|
|
1927
|
+
"shrink-0 bg-(--color-border-default) data-[orientation=horizontal]:h-px data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-px",
|
|
1878
1928
|
className
|
|
1879
1929
|
),
|
|
1880
1930
|
...props
|
|
@@ -2004,11 +2054,11 @@ var init_useBaseTokens = __esm({
|
|
|
2004
2054
|
});
|
|
2005
2055
|
|
|
2006
2056
|
// src/modals/CryptoSelectModal.tsx
|
|
2007
|
-
var
|
|
2057
|
+
var import_react16, import_nice_modal_react5, import_jsx_runtime37, CryptoSelectModal;
|
|
2008
2058
|
var init_CryptoSelectModal = __esm({
|
|
2009
2059
|
"src/modals/CryptoSelectModal.tsx"() {
|
|
2010
2060
|
"use strict";
|
|
2011
|
-
|
|
2061
|
+
import_react16 = require("react");
|
|
2012
2062
|
import_nice_modal_react5 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
2013
2063
|
init_input();
|
|
2014
2064
|
init_separator();
|
|
@@ -2024,8 +2074,8 @@ var init_CryptoSelectModal = __esm({
|
|
|
2024
2074
|
const { isLoading, error, erc20Balances } = useBaseERC20Token();
|
|
2025
2075
|
const { isLoadingNative, nativeError, nativeBalance } = useBaseNativeToken();
|
|
2026
2076
|
const { tokens, tokensIsLoading } = useBaseTokens();
|
|
2027
|
-
const [search, setSearch] = (0,
|
|
2028
|
-
const filteredCoins = (0,
|
|
2077
|
+
const [search, setSearch] = (0, import_react16.useState)("");
|
|
2078
|
+
const filteredCoins = (0, import_react16.useMemo)(() => {
|
|
2029
2079
|
return tokens.filter(
|
|
2030
2080
|
(coin) => coin.name.toLowerCase().includes(search.toLowerCase()) || coin.symbol.toLowerCase().includes(search.toLowerCase())
|
|
2031
2081
|
);
|
|
@@ -2187,11 +2237,11 @@ var init_SelectedCoin = __esm({
|
|
|
2187
2237
|
});
|
|
2188
2238
|
|
|
2189
2239
|
// src/components/CryptoTab/Crypto/Crypto.tsx
|
|
2190
|
-
var
|
|
2240
|
+
var import_react17, import_wagmi4, import_jsx_runtime40, Crypto;
|
|
2191
2241
|
var init_Crypto = __esm({
|
|
2192
2242
|
"src/components/CryptoTab/Crypto/Crypto.tsx"() {
|
|
2193
2243
|
"use strict";
|
|
2194
|
-
|
|
2244
|
+
import_react17 = require("react");
|
|
2195
2245
|
import_wagmi4 = require("wagmi");
|
|
2196
2246
|
init_SpreePayActionsContext();
|
|
2197
2247
|
init_useCryptoPayment();
|
|
@@ -2210,7 +2260,7 @@ var init_Crypto = __esm({
|
|
|
2210
2260
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2211
2261
|
const isWalletConnected = Boolean(address);
|
|
2212
2262
|
const { register } = useSpreePayRegister();
|
|
2213
|
-
const handlePay = (0,
|
|
2263
|
+
const handlePay = (0, import_react17.useCallback)(
|
|
2214
2264
|
async (data) => {
|
|
2215
2265
|
try {
|
|
2216
2266
|
const res = await cryptoPayment(data);
|
|
@@ -2224,7 +2274,7 @@ var init_Crypto = __esm({
|
|
|
2224
2274
|
},
|
|
2225
2275
|
[cryptoPayment]
|
|
2226
2276
|
);
|
|
2227
|
-
(0,
|
|
2277
|
+
(0, import_react17.useEffect)(() => {
|
|
2228
2278
|
register(handlePay);
|
|
2229
2279
|
}, [register, handlePay]);
|
|
2230
2280
|
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
@@ -2260,11 +2310,11 @@ function getCachedWagmiConfig(projectId, appName) {
|
|
|
2260
2310
|
}
|
|
2261
2311
|
return cfg2;
|
|
2262
2312
|
}
|
|
2263
|
-
var
|
|
2313
|
+
var import_react18, import_react_query, import_nice_modal_react7, import_rainbowkit2, import_styles, import_wagmi5, import_chains, import_jsx_runtime41, queryClient, CHAINS, wagmiConfigCache, CryptoWrapper;
|
|
2264
2314
|
var init_CryptoWrapper = __esm({
|
|
2265
2315
|
"src/components/CryptoTab/Crypto/CryptoWrapper.tsx"() {
|
|
2266
2316
|
"use strict";
|
|
2267
|
-
|
|
2317
|
+
import_react18 = require("react");
|
|
2268
2318
|
import_react_query = require("@tanstack/react-query");
|
|
2269
2319
|
import_nice_modal_react7 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
2270
2320
|
import_rainbowkit2 = require("@rainbow-me/rainbowkit");
|
|
@@ -2279,7 +2329,7 @@ var init_CryptoWrapper = __esm({
|
|
|
2279
2329
|
wagmiConfigCache = /* @__PURE__ */ new Map();
|
|
2280
2330
|
CryptoWrapper = () => {
|
|
2281
2331
|
const { spreePayConfig, configIsLoading } = useSpreePayConfig();
|
|
2282
|
-
const wagmiConfig = (0,
|
|
2332
|
+
const wagmiConfig = (0, import_react18.useMemo)(() => {
|
|
2283
2333
|
if (!spreePayConfig) return null;
|
|
2284
2334
|
return getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
|
|
2285
2335
|
}, [spreePayConfig]);
|
|
@@ -2466,11 +2516,11 @@ var init_Checkout = __esm({
|
|
|
2466
2516
|
});
|
|
2467
2517
|
|
|
2468
2518
|
// src/components/CryptoComTab/CryptoComTab.tsx
|
|
2469
|
-
var
|
|
2519
|
+
var import_react19, import_jsx_runtime44, CryptoComTab;
|
|
2470
2520
|
var init_CryptoComTab = __esm({
|
|
2471
2521
|
"src/components/CryptoComTab/CryptoComTab.tsx"() {
|
|
2472
2522
|
"use strict";
|
|
2473
|
-
|
|
2523
|
+
import_react19 = require("react");
|
|
2474
2524
|
init_SpreePayActionsContext();
|
|
2475
2525
|
init_useCryptoComPayment();
|
|
2476
2526
|
init_useSpreePayConfig();
|
|
@@ -2482,7 +2532,7 @@ var init_CryptoComTab = __esm({
|
|
|
2482
2532
|
const { register } = useSpreePayRegister();
|
|
2483
2533
|
const { cryptoComPayment } = useCryptoComPayment();
|
|
2484
2534
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2485
|
-
const handlePay = (0,
|
|
2535
|
+
const handlePay = (0, import_react19.useCallback)(
|
|
2486
2536
|
async (data) => {
|
|
2487
2537
|
try {
|
|
2488
2538
|
const res = await cryptoComPayment(data);
|
|
@@ -2496,7 +2546,7 @@ var init_CryptoComTab = __esm({
|
|
|
2496
2546
|
},
|
|
2497
2547
|
[cryptoComPayment]
|
|
2498
2548
|
);
|
|
2499
|
-
(0,
|
|
2549
|
+
(0, import_react19.useEffect)(() => {
|
|
2500
2550
|
register(handlePay);
|
|
2501
2551
|
}, [register, handlePay]);
|
|
2502
2552
|
return /* @__PURE__ */ (0, import_jsx_runtime44.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: [
|
|
@@ -2535,15 +2585,15 @@ __export(index_exports, {
|
|
|
2535
2585
|
module.exports = __toCommonJS(index_exports);
|
|
2536
2586
|
|
|
2537
2587
|
// src/SpreePay.tsx
|
|
2538
|
-
var
|
|
2588
|
+
var import_react23 = require("react");
|
|
2539
2589
|
var import_nice_modal_react9 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
2540
2590
|
var import_swr5 = require("swr");
|
|
2541
2591
|
|
|
2542
2592
|
// src/SpreePayContent.tsx
|
|
2543
|
-
var
|
|
2593
|
+
var import_react20 = require("react");
|
|
2544
2594
|
|
|
2545
2595
|
// src/components/CreditCardTab/CreditCardTab.tsx
|
|
2546
|
-
var
|
|
2596
|
+
var import_react15 = require("react");
|
|
2547
2597
|
init_SpreePayActionsContext();
|
|
2548
2598
|
init_StaticConfigContext();
|
|
2549
2599
|
|
|
@@ -3068,14 +3118,16 @@ var useSplitCardPayments = (mode = "web2") => {
|
|
|
3068
3118
|
};
|
|
3069
3119
|
|
|
3070
3120
|
// src/hooks/useCards.ts
|
|
3121
|
+
var import_react5 = require("react");
|
|
3071
3122
|
var import_swr2 = __toESM(require("swr"), 1);
|
|
3072
3123
|
init_SpreePayActionsContext();
|
|
3073
3124
|
var URL2 = "/v1/payments/cards";
|
|
3074
3125
|
var useCards = () => {
|
|
3075
3126
|
const { origin } = useSpreePayEnv();
|
|
3076
3127
|
const { data, isLoading, mutate } = (0, import_swr2.default)(origin ? `${URL2}?origin=${origin}` : URL2);
|
|
3128
|
+
const cards = (0, import_react5.useMemo)(() => data?.data.filter((c) => c.active) ?? [], [data]);
|
|
3077
3129
|
return {
|
|
3078
|
-
cards
|
|
3130
|
+
cards,
|
|
3079
3131
|
cardsIsLoading: isLoading,
|
|
3080
3132
|
mutateCards: mutate
|
|
3081
3133
|
};
|
|
@@ -3085,11 +3137,12 @@ var useCards = () => {
|
|
|
3085
3137
|
init_useSlapiBalance();
|
|
3086
3138
|
init_useSpreePayConfig();
|
|
3087
3139
|
init_errors();
|
|
3140
|
+
init_payments();
|
|
3088
3141
|
init_split();
|
|
3089
3142
|
init_CheckoutButton();
|
|
3090
3143
|
|
|
3091
3144
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
3092
|
-
var
|
|
3145
|
+
var import_react9 = require("react");
|
|
3093
3146
|
var import_react_stripe_js2 = require("@stripe/react-stripe-js");
|
|
3094
3147
|
var import_stripe_js = require("@stripe/stripe-js");
|
|
3095
3148
|
init_SpreePayActionsContext();
|
|
@@ -3097,12 +3150,13 @@ init_useSpreePayConfig();
|
|
|
3097
3150
|
init_InfoBanner();
|
|
3098
3151
|
|
|
3099
3152
|
// src/components/CreditCardTab/CreditCard/CardsList.tsx
|
|
3100
|
-
var
|
|
3153
|
+
var import_react7 = require("react");
|
|
3101
3154
|
init_utils();
|
|
3102
3155
|
init_slapi();
|
|
3156
|
+
init_payments();
|
|
3103
3157
|
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
3104
3158
|
var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
|
|
3105
|
-
const [isRemoving, setIsRemoving] = (0,
|
|
3159
|
+
const [isRemoving, setIsRemoving] = (0, import_react7.useState)(false);
|
|
3106
3160
|
const removeDisabled = isSelected || isRemoving;
|
|
3107
3161
|
const handleRemove = async (e) => {
|
|
3108
3162
|
e.stopPropagation();
|
|
@@ -3165,19 +3219,22 @@ var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
|
|
|
3165
3219
|
}
|
|
3166
3220
|
);
|
|
3167
3221
|
};
|
|
3168
|
-
var CardsList = ({ selectedCard, setCard }) => {
|
|
3222
|
+
var CardsList = ({ selectedCard, setCard, newCards, onRemoveNewCard }) => {
|
|
3169
3223
|
const { cards, cardsIsLoading, mutateCards } = useCards();
|
|
3224
|
+
const allCards = (0, import_react7.useMemo)(() => [...cards, ...newCards], [cards, newCards]);
|
|
3170
3225
|
const handleRemove = async (card) => {
|
|
3171
|
-
if (
|
|
3226
|
+
if (isNewCard(card)) {
|
|
3227
|
+
onRemoveNewCard(card);
|
|
3228
|
+
} else {
|
|
3172
3229
|
await SlapiPaymentService.removeCard({ cardId: card.id });
|
|
3230
|
+
mutateCards((data) => ({ ...data, data: (data?.data ?? []).filter((c) => c.id !== card.id) }));
|
|
3173
3231
|
}
|
|
3174
|
-
mutateCards((data) => ({ ...data, data: (data?.data ?? []).filter((c) => c.id !== card.id) }));
|
|
3175
3232
|
};
|
|
3176
3233
|
if (cardsIsLoading) {
|
|
3177
3234
|
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)" }) });
|
|
3178
3235
|
}
|
|
3179
|
-
if (
|
|
3180
|
-
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex w-full flex-col gap-4", children:
|
|
3236
|
+
if (allCards.length === 0) return null;
|
|
3237
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("div", { className: "flex w-full flex-col gap-4", children: allCards.map((card) => /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
3181
3238
|
CardListItem,
|
|
3182
3239
|
{
|
|
3183
3240
|
isSelected: selectedCard?.id === card.id,
|
|
@@ -3190,7 +3247,7 @@ var CardsList = ({ selectedCard, setCard }) => {
|
|
|
3190
3247
|
};
|
|
3191
3248
|
|
|
3192
3249
|
// src/components/CreditCardTab/CreditCard/CreditCardForm.tsx
|
|
3193
|
-
var
|
|
3250
|
+
var import_react8 = require("react");
|
|
3194
3251
|
var import_react_stripe_js = require("@stripe/react-stripe-js");
|
|
3195
3252
|
|
|
3196
3253
|
// src/ui/button.tsx
|
|
@@ -3246,7 +3303,7 @@ function Checkbox({ className, ...props }) {
|
|
|
3246
3303
|
{
|
|
3247
3304
|
"data-slot": "checkbox",
|
|
3248
3305
|
className: cn(
|
|
3249
|
-
"peer border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-sm border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-(--
|
|
3306
|
+
"peer border-input dark:bg-input/30 focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-sm border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:border-(--s-brand) data-[state=checked]:bg-(--s-brand) data-[state=checked]:text-(--inverse)",
|
|
3250
3307
|
className
|
|
3251
3308
|
),
|
|
3252
3309
|
...props,
|
|
@@ -3273,14 +3330,14 @@ var stripeElementClasses = {
|
|
|
3273
3330
|
focus: "border-ring ring-ring/50 ring-2"
|
|
3274
3331
|
};
|
|
3275
3332
|
var CreditCardForm = ({ cancel, saveCard }) => {
|
|
3276
|
-
const [cardError, setCardError] = (0,
|
|
3277
|
-
const [stripeStyles, setStripeStyles] = (0,
|
|
3278
|
-
const [shouldSaveCard, setShouldSaveCard] = (0,
|
|
3279
|
-
const formRef = (0,
|
|
3333
|
+
const [cardError, setCardError] = (0, import_react8.useState)(void 0);
|
|
3334
|
+
const [stripeStyles, setStripeStyles] = (0, import_react8.useState)({});
|
|
3335
|
+
const [shouldSaveCard, setShouldSaveCard] = (0, import_react8.useState)(true);
|
|
3336
|
+
const formRef = (0, import_react8.useRef)(null);
|
|
3280
3337
|
const elements = (0, import_react_stripe_js.useElements)();
|
|
3281
3338
|
const stripe = (0, import_react_stripe_js.useStripe)();
|
|
3282
|
-
const id = (0,
|
|
3283
|
-
const computeStripeStyles = (0,
|
|
3339
|
+
const [id] = (0, import_react8.useState)(() => crypto.randomUUID());
|
|
3340
|
+
const computeStripeStyles = (0, import_react8.useCallback)(() => {
|
|
3284
3341
|
const formRefCurrent = formRef.current;
|
|
3285
3342
|
if (typeof window === "undefined" || !formRefCurrent) return {};
|
|
3286
3343
|
const container = formRefCurrent.closest(".sl-spreepay");
|
|
@@ -3301,7 +3358,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
3301
3358
|
}
|
|
3302
3359
|
};
|
|
3303
3360
|
}, []);
|
|
3304
|
-
(0,
|
|
3361
|
+
(0, import_react8.useEffect)(() => {
|
|
3305
3362
|
setStripeStyles(computeStripeStyles());
|
|
3306
3363
|
}, [computeStripeStyles]);
|
|
3307
3364
|
const handleSaveCard = async () => {
|
|
@@ -3404,13 +3461,12 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
3404
3461
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
3405
3462
|
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3406
3463
|
var StripeWrapper = ({ onCancel, saveNewCard, publicKey }) => {
|
|
3407
|
-
const stripePromise = (0,
|
|
3464
|
+
const stripePromise = (0, import_react9.useMemo)(() => (0, import_stripe_js.loadStripe)(publicKey), [publicKey]);
|
|
3408
3465
|
return /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(import_react_stripe_js2.Elements, { stripe: stripePromise, children: /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(CreditCardForm, { cancel: onCancel, saveCard: saveNewCard }) });
|
|
3409
3466
|
};
|
|
3410
|
-
var CreditCard = () => {
|
|
3411
|
-
const [showForm, setShowForm] = (0,
|
|
3467
|
+
var CreditCard = ({ newCards, setNewCards }) => {
|
|
3468
|
+
const [showForm, setShowForm] = (0, import_react9.useState)(false);
|
|
3412
3469
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
3413
|
-
const { mutateCards } = useCards();
|
|
3414
3470
|
const { spreePayConfig } = useSpreePayConfig();
|
|
3415
3471
|
const setCard = (card) => {
|
|
3416
3472
|
const isAlreadySelected = selectedPaymentMethod?.type === "CREDIT_CARD" /* CREDIT_CARD */ && selectedPaymentMethod.method?.id === card.id;
|
|
@@ -3421,10 +3477,16 @@ var CreditCard = () => {
|
|
|
3421
3477
|
});
|
|
3422
3478
|
};
|
|
3423
3479
|
const saveNewCard = (newCard) => {
|
|
3424
|
-
|
|
3480
|
+
setNewCards((prev) => [...prev, newCard]);
|
|
3425
3481
|
setCard(newCard);
|
|
3426
3482
|
setShowForm(false);
|
|
3427
3483
|
};
|
|
3484
|
+
const removeNewCard = (0, import_react9.useCallback)(
|
|
3485
|
+
(card) => {
|
|
3486
|
+
setNewCards((prev) => prev.filter((c) => c.id !== card.id));
|
|
3487
|
+
},
|
|
3488
|
+
[setNewCards]
|
|
3489
|
+
);
|
|
3428
3490
|
const handleCancel = () => {
|
|
3429
3491
|
setShowForm(false);
|
|
3430
3492
|
};
|
|
@@ -3435,7 +3497,9 @@ var CreditCard = () => {
|
|
|
3435
3497
|
CardsList,
|
|
3436
3498
|
{
|
|
3437
3499
|
selectedCard: selectedPaymentMethod?.type === "CREDIT_CARD" /* CREDIT_CARD */ ? selectedPaymentMethod.method : null,
|
|
3438
|
-
setCard
|
|
3500
|
+
setCard,
|
|
3501
|
+
newCards,
|
|
3502
|
+
onRemoveNewCard: removeNewCard
|
|
3439
3503
|
}
|
|
3440
3504
|
),
|
|
3441
3505
|
spreePayConfig?.creditCard.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)(InfoBanner, { message: spreePayConfig.creditCard.infoMessage }),
|
|
@@ -3454,14 +3518,14 @@ var CreditCard = () => {
|
|
|
3454
3518
|
};
|
|
3455
3519
|
|
|
3456
3520
|
// src/components/CreditCardTab/Points/Points.tsx
|
|
3457
|
-
var
|
|
3521
|
+
var import_react14 = require("react");
|
|
3458
3522
|
init_SpreePayActionsContext();
|
|
3459
3523
|
init_StaticConfigContext();
|
|
3460
3524
|
init_useSpreePayConfig();
|
|
3461
3525
|
init_common();
|
|
3462
3526
|
|
|
3463
3527
|
// src/components/CreditCardTab/Points/SplitBlock.tsx
|
|
3464
|
-
var
|
|
3528
|
+
var import_react13 = require("react");
|
|
3465
3529
|
var import_airkit2 = require("@mocanetwork/airkit");
|
|
3466
3530
|
init_SpreePayActionsContext();
|
|
3467
3531
|
init_StaticConfigContext();
|
|
@@ -3471,7 +3535,7 @@ init_format();
|
|
|
3471
3535
|
init_logger();
|
|
3472
3536
|
|
|
3473
3537
|
// src/components/CreditCardTab/Points/PointsSelector.tsx
|
|
3474
|
-
var
|
|
3538
|
+
var import_react12 = require("react");
|
|
3475
3539
|
init_SpreePayActionsContext();
|
|
3476
3540
|
init_StaticConfigContext();
|
|
3477
3541
|
init_useSlapiBalance();
|
|
@@ -3791,10 +3855,10 @@ var Primitive = NODES.reduce((primitive, node) => {
|
|
|
3791
3855
|
}, {});
|
|
3792
3856
|
|
|
3793
3857
|
// ../../node_modules/@radix-ui/react-collection/dist/index.mjs
|
|
3794
|
-
var
|
|
3858
|
+
var import_react10 = __toESM(require("react"), 1);
|
|
3795
3859
|
var import_react_slot3 = require("@radix-ui/react-slot");
|
|
3796
3860
|
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3797
|
-
var
|
|
3861
|
+
var import_react11 = __toESM(require("react"), 1);
|
|
3798
3862
|
var import_react_slot4 = require("@radix-ui/react-slot");
|
|
3799
3863
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3800
3864
|
function createCollection(name) {
|
|
@@ -3806,14 +3870,14 @@ function createCollection(name) {
|
|
|
3806
3870
|
);
|
|
3807
3871
|
const CollectionProvider = (props) => {
|
|
3808
3872
|
const { scope, children } = props;
|
|
3809
|
-
const ref =
|
|
3810
|
-
const itemMap =
|
|
3873
|
+
const ref = import_react10.default.useRef(null);
|
|
3874
|
+
const itemMap = import_react10.default.useRef(/* @__PURE__ */ new Map()).current;
|
|
3811
3875
|
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
3812
3876
|
};
|
|
3813
3877
|
CollectionProvider.displayName = PROVIDER_NAME;
|
|
3814
3878
|
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
3815
3879
|
const CollectionSlotImpl = (0, import_react_slot3.createSlot)(COLLECTION_SLOT_NAME);
|
|
3816
|
-
const CollectionSlot =
|
|
3880
|
+
const CollectionSlot = import_react10.default.forwardRef(
|
|
3817
3881
|
(props, forwardedRef) => {
|
|
3818
3882
|
const { scope, children } = props;
|
|
3819
3883
|
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
@@ -3825,13 +3889,13 @@ function createCollection(name) {
|
|
|
3825
3889
|
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
3826
3890
|
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
3827
3891
|
const CollectionItemSlotImpl = (0, import_react_slot3.createSlot)(ITEM_SLOT_NAME);
|
|
3828
|
-
const CollectionItemSlot =
|
|
3892
|
+
const CollectionItemSlot = import_react10.default.forwardRef(
|
|
3829
3893
|
(props, forwardedRef) => {
|
|
3830
3894
|
const { scope, children, ...itemData } = props;
|
|
3831
|
-
const ref =
|
|
3895
|
+
const ref = import_react10.default.useRef(null);
|
|
3832
3896
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
3833
3897
|
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
3834
|
-
|
|
3898
|
+
import_react10.default.useEffect(() => {
|
|
3835
3899
|
context.itemMap.set(ref, { ref, ...itemData });
|
|
3836
3900
|
return () => void context.itemMap.delete(ref);
|
|
3837
3901
|
});
|
|
@@ -3841,7 +3905,7 @@ function createCollection(name) {
|
|
|
3841
3905
|
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
3842
3906
|
function useCollection2(scope) {
|
|
3843
3907
|
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
3844
|
-
const getItems =
|
|
3908
|
+
const getItems = import_react10.default.useCallback(() => {
|
|
3845
3909
|
const collectionNode = context.collectionRef.current;
|
|
3846
3910
|
if (!collectionNode) return [];
|
|
3847
3911
|
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
@@ -4474,7 +4538,7 @@ var PointsSelector = (props) => {
|
|
|
4474
4538
|
const maxByAmount = pointsConversionRatio && pointsConversionRatio > 0 ? (amount ?? 0) / pointsConversionRatio : 0;
|
|
4475
4539
|
const max = Math.min(maxByAmount, balance?.availablePoints ?? 0);
|
|
4476
4540
|
const step = 10;
|
|
4477
|
-
const [splitTokens, setSplitTokens] = (0,
|
|
4541
|
+
const [splitTokens, setSplitTokens] = (0, import_react12.useState)(0);
|
|
4478
4542
|
const usdAmount = getSplitAmount(amount ?? 0, splitTokens, pointsConversionRatio);
|
|
4479
4543
|
const pointsValue = String(Math.round(splitTokens));
|
|
4480
4544
|
const usdWithFee = usdAmount + getTransactionFee(usdAmount, transactionFeePercentage);
|
|
@@ -4572,14 +4636,14 @@ var SplitBlock = (props) => {
|
|
|
4572
4636
|
const { spreePayConfig } = useSpreePayConfig();
|
|
4573
4637
|
const { appProps } = useStaticConfig();
|
|
4574
4638
|
const { currencyCode, exchangeRate, foreignCurrencyAmount } = appProps;
|
|
4575
|
-
const [address, setAddress] = (0,
|
|
4576
|
-
const [walletReady, setWalletReady] = (0,
|
|
4639
|
+
const [address, setAddress] = (0, import_react13.useState)(null);
|
|
4640
|
+
const [walletReady, setWalletReady] = (0, import_react13.useState)(false);
|
|
4577
4641
|
const { pointsConversionRatio, pointsTitle } = spreePayConfig || {};
|
|
4578
4642
|
const { useWeb3Points, environment } = useSpreePayEnv();
|
|
4579
4643
|
const hasForeignCurrency = !!(currencyCode && exchangeRate && foreignCurrencyAmount);
|
|
4580
4644
|
const formatPointsValue = (usd) => hasForeignCurrency ? formatCurrency(usd / exchangeRate, currencyCode) : formatCurrency(usd);
|
|
4581
|
-
const prevPointsChainRef = (0,
|
|
4582
|
-
const initWallet = (0,
|
|
4645
|
+
const prevPointsChainRef = (0, import_react13.useRef)(spreePayConfig?.pointsChain);
|
|
4646
|
+
const initWallet = (0, import_react13.useCallback)(
|
|
4583
4647
|
async (pointsChain) => {
|
|
4584
4648
|
if (!pointsChain) return;
|
|
4585
4649
|
try {
|
|
@@ -4602,7 +4666,7 @@ var SplitBlock = (props) => {
|
|
|
4602
4666
|
},
|
|
4603
4667
|
[onToggle, environment]
|
|
4604
4668
|
);
|
|
4605
|
-
(0,
|
|
4669
|
+
(0, import_react13.useEffect)(() => {
|
|
4606
4670
|
if (!useWeb3Points) return;
|
|
4607
4671
|
const pointsChainChanged = prevPointsChainRef.current !== spreePayConfig?.pointsChain;
|
|
4608
4672
|
prevPointsChainRef.current = spreePayConfig?.pointsChain;
|
|
@@ -4632,8 +4696,8 @@ var SplitBlock = (props) => {
|
|
|
4632
4696
|
// src/components/CreditCardTab/Points/Points.tsx
|
|
4633
4697
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
4634
4698
|
var Points = () => {
|
|
4635
|
-
const [usePoints, setUsePoints] = (0,
|
|
4636
|
-
const [selectedPointsType, setSelectedPointsType] = (0,
|
|
4699
|
+
const [usePoints, setUsePoints] = (0, import_react14.useState)(false);
|
|
4700
|
+
const [selectedPointsType, setSelectedPointsType] = (0, import_react14.useState)(null);
|
|
4637
4701
|
const { setSelectedPaymentMethod, selectedPaymentMethod } = useSpreePaymentMethod();
|
|
4638
4702
|
const { spreePayConfig } = useSpreePayConfig();
|
|
4639
4703
|
const { appProps } = useStaticConfig();
|
|
@@ -4673,13 +4737,14 @@ var CreditCardTab = ({ isLoggedIn }) => {
|
|
|
4673
4737
|
const { appProps } = useStaticConfig();
|
|
4674
4738
|
const { spreePayConfig } = useSpreePayConfig();
|
|
4675
4739
|
const { register } = useSpreePayRegister();
|
|
4676
|
-
const { mutateCards } = useCards();
|
|
4740
|
+
const { cards, mutateCards } = useCards();
|
|
4677
4741
|
const { mutateBalance } = useSlapiBalance();
|
|
4742
|
+
const [newCards, setNewCards] = (0, import_react15.useState)([]);
|
|
4678
4743
|
const isWeb3Enabled = Boolean(useWeb3Points);
|
|
4679
4744
|
const { cardPayment } = useCardPayment();
|
|
4680
4745
|
const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
|
|
4681
4746
|
const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
|
|
4682
|
-
const handlePay = (0,
|
|
4747
|
+
const handlePay = (0, import_react15.useCallback)(
|
|
4683
4748
|
async (data) => {
|
|
4684
4749
|
try {
|
|
4685
4750
|
let res = null;
|
|
@@ -4699,14 +4764,24 @@ var CreditCardTab = ({ isLoggedIn }) => {
|
|
|
4699
4764
|
} catch (_) {
|
|
4700
4765
|
return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
|
|
4701
4766
|
} finally {
|
|
4702
|
-
if ("token" in (selectedPaymentMethod.method || {})) {
|
|
4703
|
-
setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
|
|
4704
|
-
}
|
|
4705
|
-
mutateCards();
|
|
4706
4767
|
mutateBalance();
|
|
4768
|
+
if (selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && selectedPaymentMethod.method && isNewCard(selectedPaymentMethod.method)) {
|
|
4769
|
+
const knownIds = new Set(cards.map((c) => c.id));
|
|
4770
|
+
const updated = await mutateCards();
|
|
4771
|
+
const newSavedCard = (updated?.data ?? []).find((c) => c.active && !knownIds.has(c.id));
|
|
4772
|
+
setSelectedPaymentMethod({
|
|
4773
|
+
...selectedPaymentMethod,
|
|
4774
|
+
type: "CREDIT_CARD" /* CREDIT_CARD */,
|
|
4775
|
+
method: newSavedCard ?? null
|
|
4776
|
+
});
|
|
4777
|
+
setNewCards([]);
|
|
4778
|
+
} else {
|
|
4779
|
+
mutateCards();
|
|
4780
|
+
}
|
|
4707
4781
|
}
|
|
4708
4782
|
},
|
|
4709
4783
|
[
|
|
4784
|
+
cards,
|
|
4710
4785
|
mutateCards,
|
|
4711
4786
|
selectedPaymentMethod,
|
|
4712
4787
|
pointsPayment,
|
|
@@ -4718,11 +4793,11 @@ var CreditCardTab = ({ isLoggedIn }) => {
|
|
|
4718
4793
|
mutateBalance
|
|
4719
4794
|
]
|
|
4720
4795
|
);
|
|
4721
|
-
(0,
|
|
4796
|
+
(0, import_react15.useEffect)(() => {
|
|
4722
4797
|
register(handlePay);
|
|
4723
4798
|
}, [register, handlePay]);
|
|
4724
4799
|
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)("div", { children: [
|
|
4725
|
-
/* @__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, {}) }),
|
|
4800
|
+
/* @__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, { newCards, setNewCards }) }),
|
|
4726
4801
|
!spreePayConfig?.creditCard.hidePoints && /* @__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, {}) }),
|
|
4727
4802
|
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(CheckoutButton, { isLoggedIn })
|
|
4728
4803
|
] });
|
|
@@ -4803,8 +4878,8 @@ var TabButtons = (props) => {
|
|
|
4803
4878
|
// src/SpreePayContent.tsx
|
|
4804
4879
|
init_SpreePayActionsContext();
|
|
4805
4880
|
var import_jsx_runtime45 = require("react/jsx-runtime");
|
|
4806
|
-
var CryptoTab2 = (0,
|
|
4807
|
-
var CryptoComTab2 = (0,
|
|
4881
|
+
var CryptoTab2 = (0, import_react20.lazy)(() => Promise.resolve().then(() => (init_CryptoTab2(), CryptoTab_exports)).then((module2) => ({ default: module2.CryptoTab })));
|
|
4882
|
+
var CryptoComTab2 = (0, import_react20.lazy)(
|
|
4808
4883
|
() => Promise.resolve().then(() => (init_CryptoComTab2(), CryptoComTab_exports)).then((module2) => ({ default: module2.CryptoComTab }))
|
|
4809
4884
|
);
|
|
4810
4885
|
var TabLoadingFallback = () => /* @__PURE__ */ (0, import_jsx_runtime45.jsx)("div", { className: "flex items-center justify-center px-5 py-8 md:px-7", children: /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
|
|
@@ -4819,7 +4894,7 @@ var SpreePayContent = ({ isLoggedIn }) => {
|
|
|
4819
4894
|
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
|
|
4820
4895
|
] }),
|
|
4821
4896
|
selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CreditCardTab, { isLoggedIn }),
|
|
4822
|
-
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(
|
|
4897
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsxs)(import_react20.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(TabLoadingFallback, {}), children: [
|
|
4823
4898
|
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CryptoTab2, { isLoggedIn }),
|
|
4824
4899
|
selectedPaymentMethod.type === "CDC" /* CDC */ && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(CryptoComTab2, {})
|
|
4825
4900
|
] })
|
|
@@ -4827,10 +4902,11 @@ var SpreePayContent = ({ isLoggedIn }) => {
|
|
|
4827
4902
|
};
|
|
4828
4903
|
|
|
4829
4904
|
// src/components/ErrorBoundary.tsx
|
|
4830
|
-
var
|
|
4905
|
+
var import_react21 = require("react");
|
|
4906
|
+
init_utils();
|
|
4831
4907
|
init_logger();
|
|
4832
4908
|
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
4833
|
-
var ErrorBoundary = class extends
|
|
4909
|
+
var ErrorBoundary = class extends import_react21.Component {
|
|
4834
4910
|
constructor(props) {
|
|
4835
4911
|
super(props);
|
|
4836
4912
|
this.state = { hasError: false, error: null };
|
|
@@ -4848,8 +4924,8 @@ var ErrorBoundary = class extends import_react20.Component {
|
|
|
4848
4924
|
if (this.props.fallback) {
|
|
4849
4925
|
return this.props.fallback;
|
|
4850
4926
|
}
|
|
4851
|
-
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex w-full flex-col items-center justify-center rounded-3xl border border-(--
|
|
4852
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "mb-4 flex size-12 items-center justify-center rounded-full bg-(--s-
|
|
4927
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: cn("sl-spreepay", this.props.className), children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex w-full flex-col items-center justify-center rounded-3xl border border-(--border-component-specific-card) bg-(--surface-component-specific-card-default-card) p-8 shadow-[0_6.25px_25px_0_var(--shadow-component-specific-card)]", children: [
|
|
4928
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "mb-4 flex size-12 items-center justify-center rounded-full bg-(--s-warning-subtle)", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(
|
|
4853
4929
|
"svg",
|
|
4854
4930
|
{
|
|
4855
4931
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -4867,9 +4943,9 @@ var ErrorBoundary = class extends import_react20.Component {
|
|
|
4867
4943
|
]
|
|
4868
4944
|
}
|
|
4869
4945
|
) }),
|
|
4870
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("h3", { className: "mb-2 text-lg font-semibold text-(--primary)", children: "Payment Widget Error" }),
|
|
4871
|
-
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-center text-sm text-(--
|
|
4872
|
-
] });
|
|
4946
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("h3", { className: "mb-2 text-lg font-semibold text-(--brand-primary)", children: "Payment Widget Error" }),
|
|
4947
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-center text-sm text-(--text-tertiary)", children: "Something went wrong loading the payment widget. Please refresh the page and try again." })
|
|
4948
|
+
] }) });
|
|
4873
4949
|
}
|
|
4874
4950
|
return this.props.children;
|
|
4875
4951
|
}
|
|
@@ -4881,22 +4957,22 @@ init_StaticConfigContext();
|
|
|
4881
4957
|
init_client();
|
|
4882
4958
|
|
|
4883
4959
|
// src/hooks/useKeycloakSSO.ts
|
|
4884
|
-
var
|
|
4960
|
+
var import_react22 = require("react");
|
|
4885
4961
|
var import_keycloak_js = __toESM(require("keycloak-js"), 1);
|
|
4886
4962
|
init_logger();
|
|
4887
4963
|
var refreshAheadSeconds = 60;
|
|
4888
4964
|
var keycloakLogger = logger.child("keycloak");
|
|
4889
4965
|
function useKeycloakSSO(config2) {
|
|
4890
4966
|
const { url, realm, clientId, ssoPageURI, enabled } = config2;
|
|
4891
|
-
const initRef = (0,
|
|
4892
|
-
const kcRef = (0,
|
|
4893
|
-
const refreshTimerRef = (0,
|
|
4894
|
-
const scheduleRefreshRef = (0,
|
|
4967
|
+
const initRef = (0, import_react22.useRef)(false);
|
|
4968
|
+
const kcRef = (0, import_react22.useRef)(null);
|
|
4969
|
+
const refreshTimerRef = (0, import_react22.useRef)(null);
|
|
4970
|
+
const scheduleRefreshRef = (0, import_react22.useRef)(() => {
|
|
4895
4971
|
});
|
|
4896
|
-
const [error, setError] = (0,
|
|
4897
|
-
const [isChecking, setIsChecking] = (0,
|
|
4898
|
-
const [accessToken, setAccessToken] = (0,
|
|
4899
|
-
const scheduleRefresh = (0,
|
|
4972
|
+
const [error, setError] = (0, import_react22.useState)(null);
|
|
4973
|
+
const [isChecking, setIsChecking] = (0, import_react22.useState)(enabled);
|
|
4974
|
+
const [accessToken, setAccessToken] = (0, import_react22.useState)(null);
|
|
4975
|
+
const scheduleRefresh = (0, import_react22.useCallback)(() => {
|
|
4900
4976
|
const kc = kcRef.current;
|
|
4901
4977
|
if (!kc || !kc.tokenParsed || !kc.tokenParsed.exp) {
|
|
4902
4978
|
return;
|
|
@@ -4920,10 +4996,10 @@ function useKeycloakSSO(config2) {
|
|
|
4920
4996
|
});
|
|
4921
4997
|
}, delayMs);
|
|
4922
4998
|
}, []);
|
|
4923
|
-
(0,
|
|
4999
|
+
(0, import_react22.useEffect)(() => {
|
|
4924
5000
|
scheduleRefreshRef.current = scheduleRefresh;
|
|
4925
5001
|
}, [scheduleRefresh]);
|
|
4926
|
-
(0,
|
|
5002
|
+
(0, import_react22.useEffect)(() => {
|
|
4927
5003
|
if (initRef.current || !enabled) return;
|
|
4928
5004
|
initRef.current = true;
|
|
4929
5005
|
const kc = new import_keycloak_js.default({ url, realm, clientId });
|
|
@@ -4960,30 +5036,44 @@ function useKeycloakSSO(config2) {
|
|
|
4960
5036
|
init_utils();
|
|
4961
5037
|
init_portal();
|
|
4962
5038
|
init_logger();
|
|
5039
|
+
|
|
5040
|
+
// src/utils/token.ts
|
|
5041
|
+
var import_jwt_decode = require("jwt-decode");
|
|
5042
|
+
var isTokenExpired = (token) => {
|
|
5043
|
+
try {
|
|
5044
|
+
const { exp } = (0, import_jwt_decode.jwtDecode)(token);
|
|
5045
|
+
return typeof exp === "number" && exp < Math.floor(Date.now() / 1e3);
|
|
5046
|
+
} catch {
|
|
5047
|
+
return true;
|
|
5048
|
+
}
|
|
5049
|
+
};
|
|
5050
|
+
|
|
5051
|
+
// src/SpreePay.tsx
|
|
4963
5052
|
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
4964
5053
|
var SpreePayInner = () => {
|
|
4965
|
-
const [portalEl, setPortalEl] = (0,
|
|
4966
|
-
const rootRef = (0,
|
|
5054
|
+
const [portalEl, setPortalEl] = (0, import_react23.useState)(null);
|
|
5055
|
+
const rootRef = (0, import_react23.useCallback)((node) => {
|
|
4967
5056
|
if (!node) return;
|
|
4968
5057
|
const el = node.querySelector(":scope > .sl-spreepay__portal");
|
|
4969
5058
|
setPortalEl(el ?? null);
|
|
4970
5059
|
}, []);
|
|
4971
5060
|
const { environment, tenantId, keycloakClientId, accessToken: envAccessToken, ssoPageURI } = useSpreePayEnv();
|
|
4972
|
-
(0,
|
|
5061
|
+
(0, import_react23.useEffect)(() => {
|
|
4973
5062
|
configureLogger({ environment });
|
|
4974
5063
|
logger.logVersion();
|
|
4975
5064
|
}, [environment]);
|
|
4976
5065
|
const { staticConfig, appProps } = useStaticConfig();
|
|
5066
|
+
const envTokenValid = Boolean(envAccessToken && !isTokenExpired(envAccessToken));
|
|
4977
5067
|
const { isChecking, accessToken } = useKeycloakSSO({
|
|
4978
5068
|
realm: tenantId,
|
|
4979
5069
|
url: staticConfig.keycloakUrl,
|
|
4980
5070
|
clientId: keycloakClientId ?? "oneof-next",
|
|
4981
5071
|
ssoPageURI,
|
|
4982
|
-
enabled: !
|
|
5072
|
+
enabled: !envTokenValid
|
|
4983
5073
|
});
|
|
4984
|
-
const _accessToken = envAccessToken
|
|
4985
|
-
const unauthenticatedFetcher = (0,
|
|
4986
|
-
const slapiFetcher = (0,
|
|
5074
|
+
const _accessToken = envTokenValid ? envAccessToken : accessToken;
|
|
5075
|
+
const unauthenticatedFetcher = (0, import_react23.useCallback)(() => Promise.resolve(null), []);
|
|
5076
|
+
const slapiFetcher = (0, import_react23.useMemo)(() => {
|
|
4987
5077
|
if (_accessToken) {
|
|
4988
5078
|
return registerApi({
|
|
4989
5079
|
accessToken: _accessToken,
|
|
@@ -5019,13 +5109,13 @@ var SpreePayInner = () => {
|
|
|
5019
5109
|
] });
|
|
5020
5110
|
};
|
|
5021
5111
|
var SpreePay = (props) => {
|
|
5022
|
-
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ErrorBoundary, { children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(StaticConfigProvider, { props, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SpreePayInner, {}) }) });
|
|
5112
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(ErrorBoundary, { className: props.className, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(StaticConfigProvider, { props, children: /* @__PURE__ */ (0, import_jsx_runtime47.jsx)(SpreePayInner, {}) }) });
|
|
5023
5113
|
};
|
|
5024
5114
|
|
|
5025
5115
|
// src/hooks/useCapture3DS.ts
|
|
5026
|
-
var
|
|
5116
|
+
var import_react24 = require("react");
|
|
5027
5117
|
var useCapture3DS = (searchParams) => {
|
|
5028
|
-
(0,
|
|
5118
|
+
(0, import_react24.useEffect)(() => {
|
|
5029
5119
|
if (typeof window !== "undefined" && window.parent && searchParams?.paymentIntent) {
|
|
5030
5120
|
window.parent.SP_EVENT_BUS?.emit("paymentIntent", { paymentIntent: searchParams.paymentIntent });
|
|
5031
5121
|
}
|