@superlogic/spree-pay 0.1.31 → 0.1.35
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/README.md +1 -1
- package/build/index.cjs +331 -237
- package/build/index.css +44 -5
- package/build/index.d.cts +6 -2
- package/build/index.d.ts +6 -2
- package/build/index.js +317 -223
- package/package.json +19 -19
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.35";
|
|
48
48
|
|
|
49
49
|
// src/context/SpreePayActionsContext.tsx
|
|
50
50
|
var import_react = require("react");
|
|
@@ -96,7 +96,8 @@ var SpreePayProvider = ({ children, env }) => {
|
|
|
96
96
|
}
|
|
97
97
|
}, []);
|
|
98
98
|
const value = {
|
|
99
|
-
|
|
99
|
+
// Set default to true for web3 points to backward compatibility
|
|
100
|
+
env: { ...env, useWeb3Points: env.useWeb3Points ?? true },
|
|
100
101
|
enabled: Boolean(selectedPaymentMethod.method),
|
|
101
102
|
isInternalProcessing,
|
|
102
103
|
process,
|
|
@@ -150,6 +151,16 @@ var CONFIG = {
|
|
|
150
151
|
slapiUrl: "https://slapi.dev.air.shop",
|
|
151
152
|
keycloakUrl: "https://login.dev.air.shop",
|
|
152
153
|
keycloakClientId: "oneof-next"
|
|
154
|
+
},
|
|
155
|
+
qiibee: {
|
|
156
|
+
slapiUrl: "https://slapi.dev.superlogic.com",
|
|
157
|
+
keycloakUrl: "https://sso.dev.tickets.qiibeefoundation.org",
|
|
158
|
+
keycloakClientId: "oneof-next"
|
|
159
|
+
},
|
|
160
|
+
umhp: {
|
|
161
|
+
slapiUrl: "https://slapi.dev.umusicpassport.com",
|
|
162
|
+
keycloakUrl: "https://auth.dev.umusicpassport.com",
|
|
163
|
+
keycloakClientId: "oneof-next"
|
|
153
164
|
}
|
|
154
165
|
},
|
|
155
166
|
stg: {
|
|
@@ -162,6 +173,16 @@ var CONFIG = {
|
|
|
162
173
|
slapiUrl: "https://slapi.stg.air.shop",
|
|
163
174
|
keycloakUrl: "https://login.stg.air.shop",
|
|
164
175
|
keycloakClientId: "oneof-next"
|
|
176
|
+
},
|
|
177
|
+
qiibee: {
|
|
178
|
+
slapiUrl: "https://slapi.stg.tickets.qiibeefoundation.org",
|
|
179
|
+
keycloakUrl: "https://sso.stg.tickets.qiibeefoundation.org",
|
|
180
|
+
keycloakClientId: "oneof-next"
|
|
181
|
+
},
|
|
182
|
+
umhp: {
|
|
183
|
+
slapiUrl: "https://slapi.stg.umusicpassport.com",
|
|
184
|
+
keycloakUrl: "https://auth.stg.umusicpassport.com",
|
|
185
|
+
keycloakClientId: "oneof-next"
|
|
165
186
|
}
|
|
166
187
|
},
|
|
167
188
|
prod: {
|
|
@@ -174,6 +195,16 @@ var CONFIG = {
|
|
|
174
195
|
slapiUrl: "https://slapi.air.shop",
|
|
175
196
|
keycloakUrl: "https://login.air.shop",
|
|
176
197
|
keycloakClientId: "oneof-next"
|
|
198
|
+
},
|
|
199
|
+
qiibee: {
|
|
200
|
+
slapiUrl: "https://slapi.tickets.qiibeefoundation.org",
|
|
201
|
+
keycloakUrl: "https://sso.tickets.qiibeefoundation.org",
|
|
202
|
+
keycloakClientId: "oneof-next"
|
|
203
|
+
},
|
|
204
|
+
umhp: {
|
|
205
|
+
slapiUrl: "https://slapi.umusicpassport.com",
|
|
206
|
+
keycloakUrl: "https://auth.umusicpassport.com",
|
|
207
|
+
keycloakClientId: "oneof-next"
|
|
177
208
|
}
|
|
178
209
|
}
|
|
179
210
|
};
|
|
@@ -827,7 +858,11 @@ async function longPollCardStatus(paymentId) {
|
|
|
827
858
|
if (detail.status === "FAILED" /* FAILED */) {
|
|
828
859
|
throw new Error(`Something went wrong with the ${detail.validationType} payment`);
|
|
829
860
|
}
|
|
830
|
-
if (
|
|
861
|
+
if (
|
|
862
|
+
// Process to points payment
|
|
863
|
+
detail.validationType === "POINTS" || // early card payment completion
|
|
864
|
+
["AUTHORIZED" /* AUTHORIZED */, "CAPTURED" /* CAPTURED */].includes(detail.status)
|
|
865
|
+
) {
|
|
831
866
|
return detail.status;
|
|
832
867
|
}
|
|
833
868
|
if (!shown3ds && detail.card?.redirectUrl) {
|
|
@@ -844,7 +879,7 @@ async function longPollCardStatus(paymentId) {
|
|
|
844
879
|
}
|
|
845
880
|
|
|
846
881
|
// src/hooks/payments/usePointsPayment.ts
|
|
847
|
-
var usePointsPayment = () => {
|
|
882
|
+
var usePointsPayment = (mode = "web2") => {
|
|
848
883
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
849
884
|
const { spreePayConfig } = useSpreePayConfig();
|
|
850
885
|
const pointsPayment = async (params) => {
|
|
@@ -854,31 +889,42 @@ var usePointsPayment = () => {
|
|
|
854
889
|
const { hash, capture, metadata } = params;
|
|
855
890
|
const { data: paymentResData } = await SlapiPaymentService.createPayment({
|
|
856
891
|
hash,
|
|
857
|
-
capture
|
|
892
|
+
// capture should be always true for web2 points payments
|
|
893
|
+
capture: mode === "web2" ? true : capture,
|
|
858
894
|
metadata,
|
|
859
895
|
type: "POINTS" /* POINTS */
|
|
860
896
|
});
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
897
|
+
if (mode === "web3") {
|
|
898
|
+
const wallet = peekAirWallet();
|
|
899
|
+
if (!wallet || !spreePayConfig?.pointsChain) {
|
|
900
|
+
throw new Error("AirWallet not found");
|
|
901
|
+
}
|
|
902
|
+
const transaction = await handleSendErc20({
|
|
903
|
+
amount: params.points,
|
|
904
|
+
token: spreePayConfig.pointsChain.pointsCoin,
|
|
905
|
+
recipient: spreePayConfig.pointsChain.recipientAddress
|
|
906
|
+
});
|
|
907
|
+
if (!transaction) {
|
|
908
|
+
throw new Error("Points transaction failed");
|
|
909
|
+
}
|
|
910
|
+
await SlapiPaymentService.validatePoints({
|
|
911
|
+
paymentId: paymentResData.id,
|
|
912
|
+
txHash: transaction.txHash
|
|
913
|
+
});
|
|
914
|
+
const pointsStatus2 = await longPollPoints(paymentResData.id);
|
|
915
|
+
return {
|
|
916
|
+
status: pointsStatus2,
|
|
917
|
+
txId: paymentResData.txId,
|
|
918
|
+
txHash: transaction.txHash,
|
|
919
|
+
paymentId: paymentResData.id,
|
|
920
|
+
paymentType: "POINTS" /* POINTS */
|
|
921
|
+
};
|
|
872
922
|
}
|
|
873
|
-
await SlapiPaymentService.validatePoints({
|
|
874
|
-
paymentId: paymentResData.id,
|
|
875
|
-
txHash: transaction.txHash
|
|
876
|
-
});
|
|
877
923
|
const pointsStatus = await longPollPoints(paymentResData.id);
|
|
878
924
|
return {
|
|
879
925
|
status: pointsStatus,
|
|
880
926
|
txId: paymentResData.txId,
|
|
881
|
-
txHash:
|
|
927
|
+
txHash: null,
|
|
882
928
|
paymentId: paymentResData.id,
|
|
883
929
|
paymentType: "POINTS" /* POINTS */
|
|
884
930
|
};
|
|
@@ -887,7 +933,7 @@ var usePointsPayment = () => {
|
|
|
887
933
|
};
|
|
888
934
|
|
|
889
935
|
// src/hooks/payments/useSplitCardPayments.ts
|
|
890
|
-
var useSplitCardPayments = () => {
|
|
936
|
+
var useSplitCardPayments = (mode = "web2") => {
|
|
891
937
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
892
938
|
const { env } = useSpreePayEnv();
|
|
893
939
|
const { appProps } = useStaticConfig();
|
|
@@ -921,30 +967,39 @@ var useSplitCardPayments = () => {
|
|
|
921
967
|
amount: points
|
|
922
968
|
}
|
|
923
969
|
});
|
|
924
|
-
await longPollCardStatus(paymentResData.id);
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
970
|
+
const cardStatus = await longPollCardStatus(paymentResData.id);
|
|
971
|
+
if (mode === "web3") {
|
|
972
|
+
const wallet = peekAirWallet();
|
|
973
|
+
if (!wallet || !spreePayConfig?.pointsChain) {
|
|
974
|
+
throw new Error("AirWallet not found");
|
|
975
|
+
}
|
|
976
|
+
const transaction = await handleSendErc20({
|
|
977
|
+
amount: params.points,
|
|
978
|
+
token: spreePayConfig.pointsChain.pointsCoin,
|
|
979
|
+
recipient: spreePayConfig.pointsChain.recipientAddress
|
|
980
|
+
});
|
|
981
|
+
if (!transaction) {
|
|
982
|
+
throw new Error("Points transaction failed");
|
|
983
|
+
}
|
|
984
|
+
await SlapiPaymentService.validatePoints({
|
|
985
|
+
paymentId: paymentResData.id,
|
|
986
|
+
txHash: transaction.txHash
|
|
987
|
+
});
|
|
988
|
+
const pointsStatus = await longPollPoints(paymentResData.id);
|
|
989
|
+
return {
|
|
990
|
+
paymentType: "SPLIT" /* CREDIT_CARD_SPLIT */,
|
|
991
|
+
status: pointsStatus,
|
|
992
|
+
paymentId: paymentResData.id,
|
|
993
|
+
txId: paymentResData.txId,
|
|
994
|
+
txHash: transaction.txHash
|
|
995
|
+
};
|
|
936
996
|
}
|
|
937
|
-
await SlapiPaymentService.validatePoints({
|
|
938
|
-
paymentId: paymentResData.id,
|
|
939
|
-
txHash: transaction.txHash
|
|
940
|
-
});
|
|
941
|
-
const pointsStatus = await longPollPoints(paymentResData.id);
|
|
942
997
|
return {
|
|
943
998
|
paymentType: "SPLIT" /* CREDIT_CARD_SPLIT */,
|
|
944
|
-
status:
|
|
999
|
+
status: cardStatus,
|
|
945
1000
|
paymentId: paymentResData.id,
|
|
946
1001
|
txId: paymentResData.txId,
|
|
947
|
-
txHash:
|
|
1002
|
+
txHash: null
|
|
948
1003
|
};
|
|
949
1004
|
};
|
|
950
1005
|
return { splitPayment };
|
|
@@ -984,7 +1039,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
984
1039
|
e.stopPropagation();
|
|
985
1040
|
if (isSelected || isRemoveDisabled) return;
|
|
986
1041
|
};
|
|
987
|
-
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", onClick: handleSelect, className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-
|
|
1042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("button", { type: "button", onClick: handleSelect, className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-sm", children: [
|
|
988
1043
|
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
989
1044
|
"div",
|
|
990
1045
|
{
|
|
@@ -998,7 +1053,7 @@ var CardListItem = ({ card, isSelected, onSelect }) => {
|
|
|
998
1053
|
"div",
|
|
999
1054
|
{
|
|
1000
1055
|
className: cn(
|
|
1001
|
-
"flex h-full w-full items-center justify-between rounded-r-
|
|
1056
|
+
"flex h-full w-full items-center justify-between rounded-r-sm border border-l-0! border-transparent px-3",
|
|
1002
1057
|
{
|
|
1003
1058
|
"border-primary": isSelected
|
|
1004
1059
|
}
|
|
@@ -1041,8 +1096,8 @@ var CardsList = ({ selectedCard, setCard }) => {
|
|
|
1041
1096
|
const { cards, cardsIsLoading } = useCards();
|
|
1042
1097
|
if (cardsIsLoading) {
|
|
1043
1098
|
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { className: "flex w-full flex-col gap-1", children: [
|
|
1044
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "bg-primary/8 h-11 animate-pulse rounded-
|
|
1045
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "bg-primary/8 h-11 animate-pulse rounded-
|
|
1099
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "bg-primary/8 h-11 animate-pulse rounded-sm" }),
|
|
1100
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { className: "bg-primary/8 h-11 animate-pulse rounded-sm" })
|
|
1046
1101
|
] });
|
|
1047
1102
|
}
|
|
1048
1103
|
if (cards.length === 0) return null;
|
|
@@ -1402,7 +1457,7 @@ function clamp(value, [min, max]) {
|
|
|
1402
1457
|
return Math.min(max, Math.max(min, value));
|
|
1403
1458
|
}
|
|
1404
1459
|
|
|
1405
|
-
// ../../node_modules/@radix-ui/
|
|
1460
|
+
// ../../node_modules/@radix-ui/primitive/dist/index.mjs
|
|
1406
1461
|
var canUseDOM = !!(typeof window !== "undefined" && window.document && window.document.createElement);
|
|
1407
1462
|
function composeEventHandlers(originalEventHandler, ourEventHandler, { checkForDefaultPrevented = true } = {}) {
|
|
1408
1463
|
return function handleEvent(event) {
|
|
@@ -1585,7 +1640,6 @@ function useUncontrolledState({
|
|
|
1585
1640
|
function isFunction(value) {
|
|
1586
1641
|
return typeof value === "function";
|
|
1587
1642
|
}
|
|
1588
|
-
var SYNC_STATE = Symbol("RADIX:SYNC_STATE");
|
|
1589
1643
|
|
|
1590
1644
|
// ../../node_modules/@radix-ui/react-direction/dist/index.mjs
|
|
1591
1645
|
var React6 = __toESM(require("react"), 1);
|
|
@@ -1676,7 +1730,7 @@ var Primitive = NODES.reduce((primitive, node) => {
|
|
|
1676
1730
|
const { asChild, ...primitiveProps } = props;
|
|
1677
1731
|
const Comp = asChild ? Slot2 : node;
|
|
1678
1732
|
if (typeof window !== "undefined") {
|
|
1679
|
-
window[Symbol.for("radix-ui")] = true;
|
|
1733
|
+
window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
|
|
1680
1734
|
}
|
|
1681
1735
|
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
1682
1736
|
});
|
|
@@ -2305,14 +2359,8 @@ function cn2(...inputs) {
|
|
|
2305
2359
|
|
|
2306
2360
|
// src/ui/slider.tsx
|
|
2307
2361
|
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
2308
|
-
function Slider2({
|
|
2309
|
-
className,
|
|
2310
|
-
defaultValue,
|
|
2311
|
-
value,
|
|
2312
|
-
min = 0,
|
|
2313
|
-
max = 100,
|
|
2314
|
-
...props
|
|
2315
|
-
}) {
|
|
2362
|
+
function Slider2(props) {
|
|
2363
|
+
const { className, defaultValue, value, min = 0, max = 100, ...rest } = props;
|
|
2316
2364
|
const _values = React12.useMemo(
|
|
2317
2365
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
2318
2366
|
[value, defaultValue, min, max]
|
|
@@ -2329,20 +2377,20 @@ function Slider2({
|
|
|
2329
2377
|
"relative flex w-full touch-none items-center select-none data-[disabled]:opacity-50 data-[orientation=vertical]:h-full data-[orientation=vertical]:min-h-44 data-[orientation=vertical]:w-auto data-[orientation=vertical]:flex-col",
|
|
2330
2378
|
className
|
|
2331
2379
|
),
|
|
2332
|
-
...
|
|
2380
|
+
...rest,
|
|
2333
2381
|
children: [
|
|
2334
2382
|
/* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2335
2383
|
Track,
|
|
2336
2384
|
{
|
|
2337
2385
|
"data-slot": "slider-track",
|
|
2338
2386
|
className: cn2(
|
|
2339
|
-
"
|
|
2387
|
+
"relative grow overflow-hidden rounded-full bg-black/15 data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
|
|
2340
2388
|
),
|
|
2341
2389
|
children: /* @__PURE__ */ (0, import_jsx_runtime23.jsx)(
|
|
2342
2390
|
Range,
|
|
2343
2391
|
{
|
|
2344
2392
|
"data-slot": "slider-range",
|
|
2345
|
-
className: cn2("bg-
|
|
2393
|
+
className: cn2("absolute bg-black data-[orientation=horizontal]:h-full data-[orientation=vertical]:w-full")
|
|
2346
2394
|
}
|
|
2347
2395
|
)
|
|
2348
2396
|
}
|
|
@@ -2351,7 +2399,7 @@ function Slider2({
|
|
|
2351
2399
|
Thumb2,
|
|
2352
2400
|
{
|
|
2353
2401
|
"data-slot": "slider-thumb",
|
|
2354
|
-
className: "
|
|
2402
|
+
className: "ring-ring/50 block size-5 shrink-0 rounded-full border-1 border-white bg-black shadow-sm shadow-[#00000033] transition-[color,box-shadow] hover:ring-4 focus-visible:ring-4 focus-visible:outline-hidden disabled:pointer-events-none disabled:opacity-50"
|
|
2355
2403
|
},
|
|
2356
2404
|
index
|
|
2357
2405
|
))
|
|
@@ -2385,7 +2433,7 @@ var PointsSelector = (props) => {
|
|
|
2385
2433
|
{
|
|
2386
2434
|
disabled: isDisabled,
|
|
2387
2435
|
onClick: onSelect,
|
|
2388
|
-
className: cn("bg-primary/8 cursor-pointer overflow-hidden rounded-
|
|
2436
|
+
className: cn("bg-primary/8 cursor-pointer overflow-hidden rounded-sm border-1 border-transparent", {
|
|
2389
2437
|
"border-primary": isSelected,
|
|
2390
2438
|
"cursor-not-allowed opacity-50": isDisabled
|
|
2391
2439
|
}),
|
|
@@ -2459,6 +2507,7 @@ var SplitBlock = (props) => {
|
|
|
2459
2507
|
const [walletReady, setWalletReady] = (0, import_react11.useState)(false);
|
|
2460
2508
|
const { pointsConversionRatio, pointsTitle } = spreePayConfig || {};
|
|
2461
2509
|
const { env } = useSpreePayEnv();
|
|
2510
|
+
const prevPointsChainRef = (0, import_react11.useRef)(spreePayConfig?.pointsChain);
|
|
2462
2511
|
const initWallet = (0, import_react11.useCallback)(
|
|
2463
2512
|
async (pointsChain) => {
|
|
2464
2513
|
if (!pointsChain) return;
|
|
@@ -2480,11 +2529,20 @@ var SplitBlock = (props) => {
|
|
|
2480
2529
|
[onToggle, env.environment]
|
|
2481
2530
|
);
|
|
2482
2531
|
(0, import_react11.useEffect)(() => {
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
|
|
2486
|
-
|
|
2487
|
-
|
|
2532
|
+
if (!env.useWeb3Points) return;
|
|
2533
|
+
const pointsChainChanged = prevPointsChainRef.current !== spreePayConfig?.pointsChain;
|
|
2534
|
+
prevPointsChainRef.current = spreePayConfig?.pointsChain;
|
|
2535
|
+
const doInit = async () => {
|
|
2536
|
+
if (pointsChainChanged) {
|
|
2537
|
+
setAddress(null);
|
|
2538
|
+
setWalletReady(false);
|
|
2539
|
+
}
|
|
2540
|
+
await initWallet(spreePayConfig?.pointsChain);
|
|
2541
|
+
};
|
|
2542
|
+
doInit();
|
|
2543
|
+
}, [spreePayConfig?.pointsChain, initWallet, env.useWeb3Points]);
|
|
2544
|
+
const isPointsSelectorDisabled = env.useWeb3Points ? !walletReady : false;
|
|
2545
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(PointsSelector, { isDisabled: isPointsSelectorDisabled, onSelect: () => onSelect("air"), isSelected, children: [
|
|
2488
2546
|
/* @__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: [
|
|
2489
2547
|
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)("span", { className: "text-black/50", children: "Available" }),
|
|
2490
2548
|
" ",
|
|
@@ -2537,14 +2595,16 @@ var Points = () => {
|
|
|
2537
2595
|
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
2538
2596
|
var CreditCardTab = () => {
|
|
2539
2597
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
2598
|
+
const { env } = useSpreePayEnv();
|
|
2540
2599
|
const { appProps } = useStaticConfig();
|
|
2541
2600
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2542
2601
|
const { register } = useSpreePayRegister();
|
|
2543
2602
|
const { mutateCards } = useCards();
|
|
2544
2603
|
const { mutateBalance } = useSlapiBalance();
|
|
2604
|
+
const isWeb3Enabled = Boolean(env.useWeb3Points);
|
|
2545
2605
|
const { cardPayment } = useCardPayment();
|
|
2546
|
-
const { splitPayment } = useSplitCardPayments();
|
|
2547
|
-
const { pointsPayment } = usePointsPayment();
|
|
2606
|
+
const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
|
|
2607
|
+
const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
|
|
2548
2608
|
const handlePay = (0, import_react13.useCallback)(
|
|
2549
2609
|
async (data) => {
|
|
2550
2610
|
try {
|
|
@@ -2565,7 +2625,9 @@ var CreditCardTab = () => {
|
|
|
2565
2625
|
} catch (_) {
|
|
2566
2626
|
return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
|
|
2567
2627
|
} finally {
|
|
2568
|
-
|
|
2628
|
+
if ("token" in (selectedPaymentMethod.method || {})) {
|
|
2629
|
+
setSelectedPaymentMethod({ ...selectedPaymentMethod, type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
|
|
2630
|
+
}
|
|
2569
2631
|
mutateCards();
|
|
2570
2632
|
mutateBalance();
|
|
2571
2633
|
}
|
|
@@ -2586,7 +2648,7 @@ var CreditCardTab = () => {
|
|
|
2586
2648
|
register(handlePay);
|
|
2587
2649
|
}, [register, handlePay]);
|
|
2588
2650
|
return /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("div", { children: [
|
|
2589
|
-
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "border-b
|
|
2651
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "border-b border-black/7 px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(CreditCard, {}) }),
|
|
2590
2652
|
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex flex-col gap-6 px-5 pt-5 pb-5 md:px-7 md:pt-6 md:pb-7", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsx)(Points, {}) })
|
|
2591
2653
|
] });
|
|
2592
2654
|
};
|
|
@@ -2634,10 +2696,13 @@ async function waitForTransactionReceipt(config, parameters) {
|
|
|
2634
2696
|
const receipt = await action({ ...rest, timeout });
|
|
2635
2697
|
if (receipt.status === "reverted") {
|
|
2636
2698
|
const action_getTransaction = getAction(client, import_actions2.getTransaction, "getTransaction");
|
|
2637
|
-
const txn = await action_getTransaction({
|
|
2699
|
+
const { from: account, ...txn } = await action_getTransaction({
|
|
2700
|
+
hash: receipt.transactionHash
|
|
2701
|
+
});
|
|
2638
2702
|
const action_call = getAction(client, import_actions2.call, "call");
|
|
2639
2703
|
const code = await action_call({
|
|
2640
2704
|
...txn,
|
|
2705
|
+
account,
|
|
2641
2706
|
data: txn.input,
|
|
2642
2707
|
gasPrice: txn.type !== "eip1559" ? txn.gasPrice : void 0,
|
|
2643
2708
|
maxFeePerGas: txn.type === "eip1559" ? txn.maxFeePerGas : void 0,
|
|
@@ -2950,18 +3015,58 @@ function Input2({ className, type, ...props }) {
|
|
|
2950
3015
|
}
|
|
2951
3016
|
|
|
2952
3017
|
// ../../node_modules/@radix-ui/react-separator/dist/index.mjs
|
|
3018
|
+
var React14 = __toESM(require("react"), 1);
|
|
3019
|
+
|
|
3020
|
+
// ../../node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
2953
3021
|
var React13 = __toESM(require("react"), 1);
|
|
3022
|
+
var ReactDOM2 = __toESM(require("react-dom"), 1);
|
|
3023
|
+
var import_react_slot5 = require("@radix-ui/react-slot");
|
|
2954
3024
|
var import_jsx_runtime32 = require("react/jsx-runtime");
|
|
3025
|
+
var NODES2 = [
|
|
3026
|
+
"a",
|
|
3027
|
+
"button",
|
|
3028
|
+
"div",
|
|
3029
|
+
"form",
|
|
3030
|
+
"h2",
|
|
3031
|
+
"h3",
|
|
3032
|
+
"img",
|
|
3033
|
+
"input",
|
|
3034
|
+
"label",
|
|
3035
|
+
"li",
|
|
3036
|
+
"nav",
|
|
3037
|
+
"ol",
|
|
3038
|
+
"p",
|
|
3039
|
+
"select",
|
|
3040
|
+
"span",
|
|
3041
|
+
"svg",
|
|
3042
|
+
"ul"
|
|
3043
|
+
];
|
|
3044
|
+
var Primitive2 = NODES2.reduce((primitive, node) => {
|
|
3045
|
+
const Slot2 = (0, import_react_slot5.createSlot)(`Primitive.${node}`);
|
|
3046
|
+
const Node2 = React13.forwardRef((props, forwardedRef) => {
|
|
3047
|
+
const { asChild, ...primitiveProps } = props;
|
|
3048
|
+
const Comp = asChild ? Slot2 : node;
|
|
3049
|
+
if (typeof window !== "undefined") {
|
|
3050
|
+
window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
|
|
3051
|
+
}
|
|
3052
|
+
return /* @__PURE__ */ (0, import_jsx_runtime32.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
3053
|
+
});
|
|
3054
|
+
Node2.displayName = `Primitive.${node}`;
|
|
3055
|
+
return { ...primitive, [node]: Node2 };
|
|
3056
|
+
}, {});
|
|
3057
|
+
|
|
3058
|
+
// ../../node_modules/@radix-ui/react-separator/dist/index.mjs
|
|
3059
|
+
var import_jsx_runtime33 = require("react/jsx-runtime");
|
|
2955
3060
|
var NAME = "Separator";
|
|
2956
3061
|
var DEFAULT_ORIENTATION = "horizontal";
|
|
2957
3062
|
var ORIENTATIONS = ["horizontal", "vertical"];
|
|
2958
|
-
var Separator =
|
|
3063
|
+
var Separator = React14.forwardRef((props, forwardedRef) => {
|
|
2959
3064
|
const { decorative, orientation: orientationProp = DEFAULT_ORIENTATION, ...domProps } = props;
|
|
2960
3065
|
const orientation = isValidOrientation(orientationProp) ? orientationProp : DEFAULT_ORIENTATION;
|
|
2961
3066
|
const ariaOrientation = orientation === "vertical" ? orientation : void 0;
|
|
2962
3067
|
const semanticProps = decorative ? { role: "none" } : { "aria-orientation": ariaOrientation, role: "separator" };
|
|
2963
|
-
return /* @__PURE__ */ (0,
|
|
2964
|
-
|
|
3068
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsx)(
|
|
3069
|
+
Primitive2.div,
|
|
2965
3070
|
{
|
|
2966
3071
|
"data-orientation": orientation,
|
|
2967
3072
|
...semanticProps,
|
|
@@ -2977,14 +3082,14 @@ function isValidOrientation(orientation) {
|
|
|
2977
3082
|
var Root6 = Separator;
|
|
2978
3083
|
|
|
2979
3084
|
// ../ui/src/components/separator.tsx
|
|
2980
|
-
var
|
|
3085
|
+
var import_jsx_runtime34 = require("react/jsx-runtime");
|
|
2981
3086
|
function Separator2({
|
|
2982
3087
|
className,
|
|
2983
3088
|
orientation = "horizontal",
|
|
2984
3089
|
decorative = true,
|
|
2985
3090
|
...props
|
|
2986
3091
|
}) {
|
|
2987
|
-
return /* @__PURE__ */ (0,
|
|
3092
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
2988
3093
|
Root6,
|
|
2989
3094
|
{
|
|
2990
3095
|
"data-slot": "separator",
|
|
@@ -3000,17 +3105,17 @@ function Separator2({
|
|
|
3000
3105
|
}
|
|
3001
3106
|
|
|
3002
3107
|
// src/hooks/useBaseERC20Token.ts
|
|
3003
|
-
var
|
|
3108
|
+
var React15 = __toESM(require("react"), 1);
|
|
3004
3109
|
var import_viem5 = require("viem");
|
|
3005
3110
|
var import_wagmi2 = require("wagmi");
|
|
3006
3111
|
function useBaseERC20Token() {
|
|
3007
3112
|
const { address } = (0, import_wagmi2.useAccount)();
|
|
3008
3113
|
const baseClient = (0, import_wagmi2.usePublicClient)({ chainId: BASE_CHAIN_ID });
|
|
3009
3114
|
const defaultClient = (0, import_wagmi2.usePublicClient)();
|
|
3010
|
-
const [rows, setRows] =
|
|
3011
|
-
const [isLoading, setLoading] =
|
|
3012
|
-
const [error, setError] =
|
|
3013
|
-
|
|
3115
|
+
const [rows, setRows] = React15.useState([]);
|
|
3116
|
+
const [isLoading, setLoading] = React15.useState(false);
|
|
3117
|
+
const [error, setError] = React15.useState(null);
|
|
3118
|
+
React15.useEffect(() => {
|
|
3014
3119
|
let cancelled = false;
|
|
3015
3120
|
async function run() {
|
|
3016
3121
|
const client = baseClient ?? defaultClient;
|
|
@@ -3091,7 +3196,7 @@ var useBaseTokens = () => {
|
|
|
3091
3196
|
};
|
|
3092
3197
|
|
|
3093
3198
|
// src/modals/CryptoSelectModal.tsx
|
|
3094
|
-
var
|
|
3199
|
+
var import_jsx_runtime35 = require("react/jsx-runtime");
|
|
3095
3200
|
var CryptoSelectModal = import_nice_modal_react4.default.create(() => {
|
|
3096
3201
|
const modal = (0, import_nice_modal_react4.useModal)();
|
|
3097
3202
|
const { isLoading, error, erc20Balances } = useBaseERC20Token();
|
|
@@ -3110,14 +3215,14 @@ var CryptoSelectModal = import_nice_modal_react4.default.create(() => {
|
|
|
3110
3215
|
};
|
|
3111
3216
|
const userCoins = [nativeBalance, ...erc20Balances].filter(Boolean);
|
|
3112
3217
|
const userCoinSymbols = userCoins.map((c) => c.symbol);
|
|
3113
|
-
return /* @__PURE__ */ (0,
|
|
3114
|
-
/* @__PURE__ */ (0,
|
|
3115
|
-
/* @__PURE__ */ (0,
|
|
3116
|
-
/* @__PURE__ */ (0,
|
|
3117
|
-
/* @__PURE__ */ (0,
|
|
3118
|
-
/* @__PURE__ */ (0,
|
|
3119
|
-
/* @__PURE__ */ (0,
|
|
3120
|
-
/* @__PURE__ */ (0,
|
|
3218
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(Dialog, { open: modal.visible, onOpenChange: modal.remove, children: [
|
|
3219
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DialogDescription, { className: "hidden", children: "Crypto Select Modal" }),
|
|
3220
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(DialogContent, { showCloseButton: false, className: "max-h-[90vh] gap-0 p-0", children: [
|
|
3221
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
|
|
3222
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
3223
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("button", { className: "rounded-md hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "25", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("path", { stroke: "#000", d: "m15 6.5-6 6 6 6" }) }) }),
|
|
3224
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(DialogTitle, { className: "text-primary text-2xl font-semibold", children: "Select a token" }),
|
|
3225
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("button", { className: "rounded-md p-1 hover:bg-gray-100", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "17", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3121
3226
|
"path",
|
|
3122
3227
|
{
|
|
3123
3228
|
fill: "#000",
|
|
@@ -3125,22 +3230,22 @@ var CryptoSelectModal = import_nice_modal_react4.default.create(() => {
|
|
|
3125
3230
|
}
|
|
3126
3231
|
) }) })
|
|
3127
3232
|
] }),
|
|
3128
|
-
/* @__PURE__ */ (0,
|
|
3233
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Input2, { onChange: (e) => setSearch(e.target.value), placeholder: "Search by token name", value: search })
|
|
3129
3234
|
] }),
|
|
3130
|
-
/* @__PURE__ */ (0,
|
|
3131
|
-
/* @__PURE__ */ (0,
|
|
3132
|
-
/* @__PURE__ */ (0,
|
|
3133
|
-
(error || nativeError) && /* @__PURE__ */ (0,
|
|
3134
|
-
/* @__PURE__ */ (0,
|
|
3135
|
-
isLoadingNative && /* @__PURE__ */ (0,
|
|
3136
|
-
nativeBalance && /* @__PURE__ */ (0,
|
|
3235
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Separator2, { className: "hidden md:block" }),
|
|
3236
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
|
|
3237
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h3", { className: "text-primary text-xl font-semibold", children: "Tokens with wallet balance" }),
|
|
3238
|
+
(error || nativeError) && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-center text-sm text-red-500", children: "Something wrong" }),
|
|
3239
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex w-full flex-col gap-1", children: [
|
|
3240
|
+
isLoadingNative && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3241
|
+
nativeBalance && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
3137
3242
|
"button",
|
|
3138
3243
|
{
|
|
3139
3244
|
className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-black hover:bg-gray-100",
|
|
3140
3245
|
onClick: () => handleSelect(nativeBalance),
|
|
3141
3246
|
children: [
|
|
3142
|
-
/* @__PURE__ */ (0,
|
|
3143
|
-
nativeBalance.logoURI && /* @__PURE__ */ (0,
|
|
3247
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3248
|
+
nativeBalance.logoURI && /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3144
3249
|
"img",
|
|
3145
3250
|
{
|
|
3146
3251
|
className: "h-8 w-8 shrink-0",
|
|
@@ -3148,53 +3253,53 @@ var CryptoSelectModal = import_nice_modal_react4.default.create(() => {
|
|
|
3148
3253
|
alt: `${nativeBalance.symbol} logo`
|
|
3149
3254
|
}
|
|
3150
3255
|
),
|
|
3151
|
-
/* @__PURE__ */ (0,
|
|
3256
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.symbol })
|
|
3152
3257
|
] }),
|
|
3153
|
-
/* @__PURE__ */ (0,
|
|
3258
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.formatted })
|
|
3154
3259
|
]
|
|
3155
3260
|
},
|
|
3156
3261
|
nativeBalance.symbol
|
|
3157
3262
|
),
|
|
3158
|
-
isLoading && /* @__PURE__ */ (0,
|
|
3159
|
-
/* @__PURE__ */ (0,
|
|
3160
|
-
/* @__PURE__ */ (0,
|
|
3161
|
-
/* @__PURE__ */ (0,
|
|
3263
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
3264
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3265
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3266
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
|
|
3162
3267
|
] }),
|
|
3163
3268
|
erc20Balances.map((coin) => {
|
|
3164
3269
|
const Icon = getSymbolLogo(coin.symbol);
|
|
3165
|
-
return /* @__PURE__ */ (0,
|
|
3270
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(
|
|
3166
3271
|
"button",
|
|
3167
3272
|
{
|
|
3168
3273
|
className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-black hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
|
|
3169
3274
|
onClick: () => handleSelect(coin),
|
|
3170
3275
|
children: [
|
|
3171
|
-
/* @__PURE__ */ (0,
|
|
3276
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3172
3277
|
Boolean(Icon) && Icon,
|
|
3173
|
-
/* @__PURE__ */ (0,
|
|
3278
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm font-medium", children: coin.symbol })
|
|
3174
3279
|
] }),
|
|
3175
|
-
/* @__PURE__ */ (0,
|
|
3280
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm font-medium", children: coin.formatted })
|
|
3176
3281
|
]
|
|
3177
3282
|
},
|
|
3178
3283
|
coin.symbol
|
|
3179
3284
|
);
|
|
3180
3285
|
})
|
|
3181
3286
|
] }),
|
|
3182
|
-
/* @__PURE__ */ (0,
|
|
3183
|
-
/* @__PURE__ */ (0,
|
|
3184
|
-
tokensIsLoading && /* @__PURE__ */ (0,
|
|
3185
|
-
/* @__PURE__ */ (0,
|
|
3186
|
-
/* @__PURE__ */ (0,
|
|
3187
|
-
/* @__PURE__ */ (0,
|
|
3287
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("h3", { className: "text-primary text-xl font-semibold", children: "All Tokens" }),
|
|
3288
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex max-h-[40vh] w-full flex-col gap-1 overflow-y-auto", children: [
|
|
3289
|
+
tokensIsLoading && /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)(import_jsx_runtime35.Fragment, { children: [
|
|
3290
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3291
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" }),
|
|
3292
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-gray-100" })
|
|
3188
3293
|
] }),
|
|
3189
|
-
filteredCoins.map((token) => /* @__PURE__ */ (0,
|
|
3294
|
+
filteredCoins.map((token) => /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(
|
|
3190
3295
|
"button",
|
|
3191
3296
|
{
|
|
3192
3297
|
disabled: !userCoinSymbols.includes(token.symbol),
|
|
3193
3298
|
onClick: () => handleSelect(userCoins.find((c) => c.symbol === token.symbol)),
|
|
3194
3299
|
className: "flex min-h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-black hover:bg-gray-100 disabled:cursor-not-allowed disabled:opacity-50",
|
|
3195
|
-
children: /* @__PURE__ */ (0,
|
|
3196
|
-
token.logoURI ? /* @__PURE__ */ (0,
|
|
3197
|
-
/* @__PURE__ */ (0,
|
|
3300
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime35.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3301
|
+
token.logoURI ? /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("img", { className: "h-8 w-8 shrink-0", src: token.logoURI, alt: `${token.name} logo` }) : /* @__PURE__ */ (0, import_jsx_runtime35.jsx)("div", { className: "h-8 w-8 shrink-0 rounded-full bg-gray-400" }),
|
|
3302
|
+
/* @__PURE__ */ (0, import_jsx_runtime35.jsx)("p", { className: "text-sm font-medium", children: token.symbol })
|
|
3198
3303
|
] })
|
|
3199
3304
|
},
|
|
3200
3305
|
token.symbol
|
|
@@ -3207,44 +3312,44 @@ var CryptoSelectModal = import_nice_modal_react4.default.create(() => {
|
|
|
3207
3312
|
CryptoSelectModal.displayName = "CryptoSelectModal";
|
|
3208
3313
|
|
|
3209
3314
|
// src/components/CryptoTab/Crypto/SelectCoinButton.tsx
|
|
3210
|
-
var
|
|
3315
|
+
var import_jsx_runtime36 = require("react/jsx-runtime");
|
|
3211
3316
|
var SelectCoinButton = () => {
|
|
3212
3317
|
const openModal = () => {
|
|
3213
3318
|
import_nice_modal_react5.default.show(CryptoSelectModal);
|
|
3214
3319
|
};
|
|
3215
|
-
return /* @__PURE__ */ (0,
|
|
3216
|
-
/* @__PURE__ */ (0,
|
|
3217
|
-
/* @__PURE__ */ (0,
|
|
3218
|
-
/* @__PURE__ */ (0,
|
|
3219
|
-
/* @__PURE__ */ (0,
|
|
3320
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("button", { onClick: openModal, type: "button", className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
|
|
3321
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "bg-primary flex h-full w-11 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white" }) }),
|
|
3322
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsxs)("div", { className: "flex h-full w-full items-center justify-between px-3", children: [
|
|
3323
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("p", { className: "font-medium text-black/50", children: "Select a token" }) }),
|
|
3324
|
+
/* @__PURE__ */ (0, import_jsx_runtime36.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "16", height: "16", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime36.jsx)("path", { stroke: "#000", strokeLinecap: "round", d: "m6 12.43 4-4-4-4" }) })
|
|
3220
3325
|
] })
|
|
3221
3326
|
] });
|
|
3222
3327
|
};
|
|
3223
3328
|
|
|
3224
3329
|
// src/components/CryptoTab/Crypto/SelectedCoin.tsx
|
|
3225
|
-
var
|
|
3330
|
+
var import_jsx_runtime37 = require("react/jsx-runtime");
|
|
3226
3331
|
var SelectedCoin = (props) => {
|
|
3227
3332
|
const { coin, balance, logoURI } = props;
|
|
3228
3333
|
const Icon = getSymbolLogo(coin);
|
|
3229
|
-
return /* @__PURE__ */ (0,
|
|
3230
|
-
/* @__PURE__ */ (0,
|
|
3231
|
-
/* @__PURE__ */ (0,
|
|
3232
|
-
/* @__PURE__ */ (0,
|
|
3334
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "bg-primary/8 flex h-11 w-full overflow-hidden rounded-md", children: [
|
|
3335
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "bg-primary flex h-full w-11 items-center justify-center", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "flex h-5 w-5 items-center justify-center rounded-full bg-white", children: /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("div", { className: "bg-primary h-2.5 w-2.5 rounded-full" }) }) }),
|
|
3336
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "border-primary flex h-full w-full items-center justify-between rounded-r-md border-1 !border-l-0 px-3", children: [
|
|
3337
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
3233
3338
|
Icon,
|
|
3234
|
-
!Icon && logoURI && /* @__PURE__ */ (0,
|
|
3235
|
-
/* @__PURE__ */ (0,
|
|
3236
|
-
/* @__PURE__ */ (0,
|
|
3339
|
+
!Icon && logoURI && /* @__PURE__ */ (0, import_jsx_runtime37.jsx)("img", { className: "mr-1 h-8 w-8 shrink-0", src: logoURI, alt: `${coin} logo` }),
|
|
3340
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("p", { className: "font-semibold text-black", children: coin }),
|
|
3341
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.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_runtime37.jsx)("path", { d: "M6 12.4341L10 8.43408L6 4.43408", stroke: "black", strokeLinecap: "round" }) })
|
|
3237
3342
|
] }),
|
|
3238
|
-
/* @__PURE__ */ (0,
|
|
3343
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsxs)("p", { className: "text-xs font-medium text-black/50", children: [
|
|
3239
3344
|
"Wallet balance ",
|
|
3240
|
-
/* @__PURE__ */ (0,
|
|
3345
|
+
/* @__PURE__ */ (0, import_jsx_runtime37.jsx)("span", { className: "text-black", children: balance })
|
|
3241
3346
|
] })
|
|
3242
3347
|
] })
|
|
3243
3348
|
] });
|
|
3244
3349
|
};
|
|
3245
3350
|
|
|
3246
3351
|
// src/components/CryptoTab/Crypto/Crypto.tsx
|
|
3247
|
-
var
|
|
3352
|
+
var import_jsx_runtime38 = require("react/jsx-runtime");
|
|
3248
3353
|
var Crypto = () => {
|
|
3249
3354
|
const { address } = (0, import_wagmi4.useAccount)();
|
|
3250
3355
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
@@ -3268,14 +3373,14 @@ var Crypto = () => {
|
|
|
3268
3373
|
(0, import_react15.useEffect)(() => {
|
|
3269
3374
|
register(handlePay);
|
|
3270
3375
|
}, [register, handlePay]);
|
|
3271
|
-
return /* @__PURE__ */ (0,
|
|
3272
|
-
/* @__PURE__ */ (0,
|
|
3273
|
-
/* @__PURE__ */ (0,
|
|
3274
|
-
/* @__PURE__ */ (0,
|
|
3376
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
3377
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [
|
|
3378
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h3", { className: "text-primary text-xl leading-[1.7] font-semibold", children: "Pay with Crypto" }),
|
|
3379
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(ConnectButton, {})
|
|
3275
3380
|
] }),
|
|
3276
|
-
!isWalletConnected && /* @__PURE__ */ (0,
|
|
3277
|
-
isWalletConnected && /* @__PURE__ */ (0,
|
|
3278
|
-
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ (0,
|
|
3381
|
+
!isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Logos, {}),
|
|
3382
|
+
isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex w-full flex-col gap-1", children: [
|
|
3383
|
+
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
3279
3384
|
SelectedCoin,
|
|
3280
3385
|
{
|
|
3281
3386
|
coin: selectedPaymentMethod.method.symbol,
|
|
@@ -3283,13 +3388,13 @@ var Crypto = () => {
|
|
|
3283
3388
|
logoURI: selectedPaymentMethod.method.logoURI
|
|
3284
3389
|
}
|
|
3285
3390
|
),
|
|
3286
|
-
/* @__PURE__ */ (0,
|
|
3391
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(SelectCoinButton, {})
|
|
3287
3392
|
] })
|
|
3288
3393
|
] });
|
|
3289
3394
|
};
|
|
3290
3395
|
|
|
3291
3396
|
// src/components/CryptoTab/Crypto/CryptoWrapper.tsx
|
|
3292
|
-
var
|
|
3397
|
+
var import_jsx_runtime39 = require("react/jsx-runtime");
|
|
3293
3398
|
var queryClient = new import_react_query.QueryClient();
|
|
3294
3399
|
var CHAINS = [import_chains.base];
|
|
3295
3400
|
var wagmiConfigCache = /* @__PURE__ */ new Map();
|
|
@@ -3304,36 +3409,34 @@ function getCachedWagmiConfig(projectId, appName) {
|
|
|
3304
3409
|
}
|
|
3305
3410
|
var CryptoWrapper = () => {
|
|
3306
3411
|
const { spreePayConfig, configIsLoading } = useSpreePayConfig();
|
|
3307
|
-
const
|
|
3308
|
-
|
|
3309
|
-
|
|
3310
|
-
const cfg2 = getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
|
|
3311
|
-
setWagmiConfig((prev) => prev ? prev : cfg2);
|
|
3412
|
+
const wagmiConfig = (0, import_react16.useMemo)(() => {
|
|
3413
|
+
if (!spreePayConfig) return null;
|
|
3414
|
+
return getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
|
|
3312
3415
|
}, [spreePayConfig]);
|
|
3313
3416
|
if (configIsLoading || !wagmiConfig) return null;
|
|
3314
|
-
return /* @__PURE__ */ (0,
|
|
3417
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_wagmi5.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_rainbowkit2.RainbowKitProvider, { theme: (0, import_rainbowkit2.lightTheme)({ borderRadius: "large" }), children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(import_nice_modal_react6.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(Crypto, {}) }) }) }) });
|
|
3315
3418
|
};
|
|
3316
3419
|
|
|
3317
3420
|
// src/components/CryptoTab/CryptoTab.tsx
|
|
3318
|
-
var
|
|
3421
|
+
var import_jsx_runtime40 = require("react/jsx-runtime");
|
|
3319
3422
|
var CryptoTab = () => {
|
|
3320
3423
|
const { spreePayConfig } = useSpreePayConfig();
|
|
3321
|
-
return /* @__PURE__ */ (0,
|
|
3322
|
-
/* @__PURE__ */ (0,
|
|
3323
|
-
/* @__PURE__ */ (0,
|
|
3424
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { children: [
|
|
3425
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(CryptoWrapper, {}) }),
|
|
3426
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(PointsSwitch, { disabled: true, message: spreePayConfig?.crypto.pointsInfoMessage }) })
|
|
3324
3427
|
] });
|
|
3325
3428
|
};
|
|
3326
3429
|
|
|
3327
3430
|
// src/components/TabButtons.tsx
|
|
3328
|
-
var
|
|
3329
|
-
var TabButton = ({ isDisabled =
|
|
3330
|
-
return /* @__PURE__ */ (0,
|
|
3431
|
+
var import_jsx_runtime41 = require("react/jsx-runtime");
|
|
3432
|
+
var TabButton = ({ isDisabled = false, isActive, children, onClick }) => {
|
|
3433
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3331
3434
|
"button",
|
|
3332
3435
|
{
|
|
3333
3436
|
disabled: isDisabled,
|
|
3334
3437
|
onClick,
|
|
3335
3438
|
className: cn(
|
|
3336
|
-
"flex w-[132px] flex-col items-baseline rounded-sm border
|
|
3439
|
+
"flex w-[132px] flex-col items-baseline rounded-sm border border-black/50 px-2.5 py-1.5 text-sm text-black",
|
|
3337
3440
|
{ "opacity-50": !isActive || isDisabled },
|
|
3338
3441
|
{ "cursor-not-allowed": isDisabled },
|
|
3339
3442
|
{ "bg-primary/7 border-primary text-primary": isActive }
|
|
@@ -3344,83 +3447,71 @@ var TabButton = ({ isDisabled = true, isActive, children, onClick }) => {
|
|
|
3344
3447
|
};
|
|
3345
3448
|
var TabButtons = (props) => {
|
|
3346
3449
|
const { value, onChange } = props;
|
|
3347
|
-
const { spreePayConfig } = useSpreePayConfig();
|
|
3450
|
+
const { spreePayConfig, configIsLoading } = useSpreePayConfig();
|
|
3348
3451
|
const handleChange = (type) => () => {
|
|
3349
3452
|
if (value !== type) {
|
|
3350
3453
|
onChange({ type, method: null });
|
|
3351
3454
|
}
|
|
3352
3455
|
};
|
|
3353
|
-
return /* @__PURE__ */ (0,
|
|
3354
|
-
/* @__PURE__ */ (0,
|
|
3355
|
-
|
|
3356
|
-
{
|
|
3357
|
-
|
|
3358
|
-
|
|
3359
|
-
|
|
3360
|
-
|
|
3361
|
-
|
|
3362
|
-
|
|
3363
|
-
|
|
3364
|
-
|
|
3365
|
-
|
|
3366
|
-
|
|
3367
|
-
|
|
3368
|
-
|
|
3369
|
-
|
|
3370
|
-
|
|
3371
|
-
|
|
3372
|
-
|
|
3373
|
-
|
|
3374
|
-
|
|
3375
|
-
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
"path",
|
|
3389
|
-
{
|
|
3390
|
-
fill: "currentColor",
|
|
3391
|
-
d: "M21.15 0c4.7 0 8.5 3.58 8.5 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.1.09 3.71 0 6.5-2.8 6.5-6s-2.79-6-6.5-6c-.37 0-.74.03-1.1.09A8 8 0 0 0 17.8.65 8.93 8.93 0 0 1 21.15 0Z"
|
|
3392
|
-
}
|
|
3393
|
-
),
|
|
3394
|
-
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "2" })
|
|
3395
|
-
] }),
|
|
3396
|
-
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "text-sm font-medium", children: "Crypto" })
|
|
3397
|
-
]
|
|
3398
|
-
}
|
|
3399
|
-
)
|
|
3456
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex gap-2", children: [
|
|
3457
|
+
configIsLoading && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(import_jsx_runtime41.Fragment, { children: [
|
|
3458
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "bg-primary/7 h-[58px] w-[132px] animate-pulse rounded-sm" }),
|
|
3459
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("div", { className: "bg-primary/7 h-[58px] w-[132px] animate-pulse rounded-sm" })
|
|
3460
|
+
] }),
|
|
3461
|
+
spreePayConfig?.creditCard.enabled && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(TabButton, { onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */), isActive: value === "CREDIT_CARD" /* CREDIT_CARD */, children: [
|
|
3462
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", children: /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3463
|
+
"path",
|
|
3464
|
+
{
|
|
3465
|
+
fill: "currentColor",
|
|
3466
|
+
d: "M22 6v12c0 .55-.2 1.02-.59 1.41-.39.4-.86.59-1.41.59H4c-.55 0-1.02-.2-1.41-.59-.4-.39-.59-.86-.59-1.41V6c0-.55.2-1.02.59-1.41C2.98 4.19 3.45 4 4 4h16c.55 0 1.02.2 1.41.59.4.39.59.86.59 1.41ZM4 8h16V6H4v2Zm0 4v6h16v-6H4Z"
|
|
3467
|
+
}
|
|
3468
|
+
) }),
|
|
3469
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "text-sm font-medium", children: "Card" })
|
|
3470
|
+
] }),
|
|
3471
|
+
spreePayConfig?.crypto.enabled && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)(TabButton, { onClick: handleChange("CRYPTO" /* CRYPTO */), isActive: value === "CRYPTO" /* CRYPTO */, children: [
|
|
3472
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("svg", { className: "my-1", xmlns: "http://www.w3.org/2000/svg", width: "30", height: "16", fill: "none", children: [
|
|
3473
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3474
|
+
"path",
|
|
3475
|
+
{
|
|
3476
|
+
fill: "currentColor",
|
|
3477
|
+
d: "M14.5 0C19.2 0 23 3.58 23 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.11.09 3.7 0 6.5-2.8 6.5-6s-2.8-6-6.5-6c-.38 0-.75.03-1.11.09A8 8 0 0 0 11.15.65 8.93 8.93 0 0 1 14.5 0Z"
|
|
3478
|
+
}
|
|
3479
|
+
),
|
|
3480
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
3481
|
+
"path",
|
|
3482
|
+
{
|
|
3483
|
+
fill: "currentColor",
|
|
3484
|
+
d: "M21.15 0c4.7 0 8.5 3.58 8.5 8s-3.8 8-8.5 8a8.93 8.93 0 0 1-3.35-.65 8 8 0 0 0 2.24-1.44c.36.06.73.09 1.1.09 3.71 0 6.5-2.8 6.5-6s-2.79-6-6.5-6c-.37 0-.74.03-1.1.09A8 8 0 0 0 17.8.65 8.93 8.93 0 0 1 21.15 0Z"
|
|
3485
|
+
}
|
|
3486
|
+
),
|
|
3487
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("circle", { cx: "8", cy: "8", r: "7", stroke: "currentColor", strokeWidth: "2" })
|
|
3488
|
+
] }),
|
|
3489
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("p", { className: "text-sm font-medium", children: "Crypto" })
|
|
3490
|
+
] })
|
|
3400
3491
|
] });
|
|
3401
3492
|
};
|
|
3402
3493
|
|
|
3403
3494
|
// src/components/Tabs.tsx
|
|
3404
|
-
var
|
|
3495
|
+
var import_jsx_runtime42 = require("react/jsx-runtime");
|
|
3405
3496
|
var Tabs = () => {
|
|
3406
3497
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
3407
|
-
return /* @__PURE__ */ (0,
|
|
3408
|
-
/* @__PURE__ */ (0,
|
|
3409
|
-
/* @__PURE__ */ (0,
|
|
3410
|
-
/* @__PURE__ */ (0,
|
|
3498
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "mb-4 rounded-3xl border border-black/25 bg-white", children: [
|
|
3499
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsxs)("div", { className: "flex w-full flex-col gap-4 border-b-1 border-black/7 px-5 py-5 md:px-7 md:py-6", children: [
|
|
3500
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)("h2", { className: "text-primary text-2xl font-semibold", children: "Choose a Payment Method" }),
|
|
3501
|
+
/* @__PURE__ */ (0, import_jsx_runtime42.jsx)(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
|
|
3411
3502
|
] }),
|
|
3412
|
-
selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0,
|
|
3413
|
-
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0,
|
|
3503
|
+
selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CreditCardTab, {}),
|
|
3504
|
+
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(CryptoTab, {})
|
|
3414
3505
|
] });
|
|
3415
3506
|
};
|
|
3416
3507
|
|
|
3417
3508
|
// src/SpreePayContent.tsx
|
|
3418
|
-
var
|
|
3509
|
+
var import_jsx_runtime43 = require("react/jsx-runtime");
|
|
3419
3510
|
var SpreePayContent = ({ isLoggedIn }) => {
|
|
3420
|
-
return /* @__PURE__ */ (0,
|
|
3421
|
-
/* @__PURE__ */ (0,
|
|
3422
|
-
/* @__PURE__ */ (0,
|
|
3423
|
-
/* @__PURE__ */ (0,
|
|
3511
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { className: "w-full", children: [
|
|
3512
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(Tabs, {}),
|
|
3513
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CheckoutButton, { isLoggedIn }),
|
|
3514
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(SpreeLegal, {})
|
|
3424
3515
|
] });
|
|
3425
3516
|
};
|
|
3426
3517
|
|
|
@@ -3433,6 +3524,8 @@ function useKeycloakSSO(config) {
|
|
|
3433
3524
|
const initRef = (0, import_react17.useRef)(false);
|
|
3434
3525
|
const kcRef = (0, import_react17.useRef)(null);
|
|
3435
3526
|
const refreshTimerRef = (0, import_react17.useRef)(null);
|
|
3527
|
+
const scheduleRefreshRef = (0, import_react17.useRef)(() => {
|
|
3528
|
+
});
|
|
3436
3529
|
const [error, setError] = (0, import_react17.useState)(null);
|
|
3437
3530
|
const [isChecking, setIsChecking] = (0, import_react17.useState)(enabled);
|
|
3438
3531
|
const [accessToken, setAccessToken] = (0, import_react17.useState)(null);
|
|
@@ -3450,17 +3543,19 @@ function useKeycloakSSO(config) {
|
|
|
3450
3543
|
kc.updateToken(refreshAheadSeconds).then((refreshed) => {
|
|
3451
3544
|
if (refreshed) {
|
|
3452
3545
|
setAccessToken(kc.token ?? null);
|
|
3453
|
-
|
|
3546
|
+
scheduleRefreshRef.current();
|
|
3454
3547
|
}
|
|
3455
3548
|
}).catch((_) => {
|
|
3456
3549
|
kc.login().catch(console.error);
|
|
3457
3550
|
});
|
|
3458
3551
|
}, delayMs);
|
|
3459
3552
|
}, []);
|
|
3553
|
+
(0, import_react17.useEffect)(() => {
|
|
3554
|
+
scheduleRefreshRef.current = scheduleRefresh;
|
|
3555
|
+
}, [scheduleRefresh]);
|
|
3460
3556
|
(0, import_react17.useEffect)(() => {
|
|
3461
3557
|
if (initRef.current || !enabled) return;
|
|
3462
3558
|
initRef.current = true;
|
|
3463
|
-
setIsChecking(true);
|
|
3464
3559
|
const kc = new import_keycloak_js.default({ url, realm, clientId });
|
|
3465
3560
|
kcRef.current = kc;
|
|
3466
3561
|
kc.onTokenExpired = () => {
|
|
@@ -3492,13 +3587,12 @@ function useKeycloakSSO(config) {
|
|
|
3492
3587
|
}
|
|
3493
3588
|
|
|
3494
3589
|
// src/SpreePay.tsx
|
|
3495
|
-
var
|
|
3590
|
+
var import_jsx_runtime44 = require("react/jsx-runtime");
|
|
3496
3591
|
var SpreePayInner = () => {
|
|
3497
|
-
const rootRef = (0, import_react18.useRef)(null);
|
|
3498
3592
|
const [portalEl, setPortalEl] = (0, import_react18.useState)(null);
|
|
3499
|
-
(0, import_react18.
|
|
3500
|
-
if (!
|
|
3501
|
-
const el =
|
|
3593
|
+
const rootRef = (0, import_react18.useCallback)((node) => {
|
|
3594
|
+
if (!node) return;
|
|
3595
|
+
const el = node.querySelector(":scope > .sl-spreepay__portal");
|
|
3502
3596
|
setPortalEl(el ?? null);
|
|
3503
3597
|
}, []);
|
|
3504
3598
|
(0, import_react18.useEffect)(() => {
|
|
@@ -3506,7 +3600,7 @@ var SpreePayInner = () => {
|
|
|
3506
3600
|
}, []);
|
|
3507
3601
|
const { env } = useSpreePayEnv();
|
|
3508
3602
|
const { staticConfig, appProps } = useStaticConfig();
|
|
3509
|
-
const tenantId = env?.tenantId
|
|
3603
|
+
const tenantId = env?.tenantId;
|
|
3510
3604
|
const { isChecking, accessToken } = useKeycloakSSO({
|
|
3511
3605
|
realm: tenantId,
|
|
3512
3606
|
url: staticConfig.keycloakUrl,
|
|
@@ -3526,13 +3620,13 @@ var SpreePayInner = () => {
|
|
|
3526
3620
|
}, [_accessToken, staticConfig, tenantId]);
|
|
3527
3621
|
const getContent = () => {
|
|
3528
3622
|
if (isChecking) {
|
|
3529
|
-
return /* @__PURE__ */ (0,
|
|
3530
|
-
/* @__PURE__ */ (0,
|
|
3531
|
-
/* @__PURE__ */ (0,
|
|
3532
|
-
/* @__PURE__ */ (0,
|
|
3623
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { className: "flex w-full flex-col", children: [
|
|
3624
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "bg-primary/8 mb-4 h-[315px] animate-pulse rounded-3xl" }),
|
|
3625
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "bg-primary/8 h-[135px] animate-pulse rounded-3xl" }),
|
|
3626
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(SpreeLegal, {})
|
|
3533
3627
|
] });
|
|
3534
3628
|
}
|
|
3535
|
-
return /* @__PURE__ */ (0,
|
|
3629
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
3536
3630
|
import_swr5.SWRConfig,
|
|
3537
3631
|
{
|
|
3538
3632
|
value: {
|
|
@@ -3541,17 +3635,17 @@ var SpreePayInner = () => {
|
|
|
3541
3635
|
revalidateOnFocus: false,
|
|
3542
3636
|
revalidateIfStale: false
|
|
3543
3637
|
},
|
|
3544
|
-
children: /* @__PURE__ */ (0,
|
|
3638
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(import_nice_modal_react7.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(SpreePayContent, { isLoggedIn: Boolean(_accessToken) }) }) })
|
|
3545
3639
|
}
|
|
3546
3640
|
);
|
|
3547
3641
|
};
|
|
3548
|
-
return /* @__PURE__ */ (0,
|
|
3549
|
-
/* @__PURE__ */ (0,
|
|
3642
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("div", { ref: rootRef, className: cn("sl-spreepay", appProps.className), children: [
|
|
3643
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)("div", { className: "sl-spreepay__portal" }),
|
|
3550
3644
|
getContent()
|
|
3551
3645
|
] });
|
|
3552
3646
|
};
|
|
3553
3647
|
var SpreePay = (props) => {
|
|
3554
|
-
return /* @__PURE__ */ (0,
|
|
3648
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(StaticConfigProvider, { props, children: /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(SpreePayInner, {}) });
|
|
3555
3649
|
};
|
|
3556
3650
|
|
|
3557
3651
|
// src/hooks/useCapture3DS.ts
|