@superlogic/spree-pay 0.4.12 → 0.5.1
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 +82 -5
- package/build/{CryptoComTab-DAKL7IZF.js → CryptoComTab-ZAWBJUCM.js} +11 -12
- package/build/{CryptoTab-57MMM4AG.js → CryptoTab-632DRL2D.js} +13 -14
- package/build/{chunk-RORSHUSF.js → chunk-4BM6VTMT.js} +6 -7
- package/build/{chunk-JXZZJ7NS.js → chunk-AXNTOSBU.js} +1 -1
- package/build/{chunk-WRFG6YIS.js → chunk-PTEQVWLJ.js} +143 -48
- package/build/index.cjs +635 -507
- package/build/index.css +5 -0
- package/build/index.d.cts +50 -5
- package/build/index.d.ts +50 -5
- package/build/index.js +91 -56
- package/package.json +5 -2
package/build/index.cjs
CHANGED
|
@@ -30,26 +30,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
|
|
|
30
30
|
));
|
|
31
31
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
32
32
|
|
|
33
|
-
// src/types/errors.ts
|
|
34
|
-
var PaymentError;
|
|
35
|
-
var init_errors = __esm({
|
|
36
|
-
"src/types/errors.ts"() {
|
|
37
|
-
"use strict";
|
|
38
|
-
PaymentError = class extends Error {
|
|
39
|
-
status;
|
|
40
|
-
details;
|
|
41
|
-
constructor(message, status, details) {
|
|
42
|
-
super(message);
|
|
43
|
-
this.name = "PaymentError";
|
|
44
|
-
this.status = status;
|
|
45
|
-
this.details = details;
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
});
|
|
50
|
-
|
|
51
33
|
// src/types/payments.ts
|
|
52
|
-
var isNewCard, PaymentType;
|
|
34
|
+
var isNewCard, PaymentType, PaymentStatus;
|
|
53
35
|
var init_payments = __esm({
|
|
54
36
|
"src/types/payments.ts"() {
|
|
55
37
|
"use strict";
|
|
@@ -62,6 +44,88 @@ var init_payments = __esm({
|
|
|
62
44
|
PaymentType2["POINTS"] = "POINTS";
|
|
63
45
|
return PaymentType2;
|
|
64
46
|
})(PaymentType || {});
|
|
47
|
+
PaymentStatus = /* @__PURE__ */ ((PaymentStatus2) => {
|
|
48
|
+
PaymentStatus2["NOT_INITIALIZED"] = "NOT_INITIALIZED";
|
|
49
|
+
PaymentStatus2["PENDING"] = "PENDING";
|
|
50
|
+
PaymentStatus2["AUTHORIZED"] = "AUTHORIZED";
|
|
51
|
+
PaymentStatus2["FAILED"] = "FAILED";
|
|
52
|
+
PaymentStatus2["CAPTURED"] = "CAPTURED";
|
|
53
|
+
PaymentStatus2["VOIDED"] = "VOIDED";
|
|
54
|
+
PaymentStatus2["CAPTURE_FAILED"] = "CAPTURE_FAILED";
|
|
55
|
+
return PaymentStatus2;
|
|
56
|
+
})(PaymentStatus || {});
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// src/types/errors.ts
|
|
61
|
+
var SpreePayHttpError, PaymentErrorCode, PaymentError, isPaymentError, isDeclineStatus, isSuccessStatus, isProcessorRejection, backendCodeFromBody, toPaymentError, settlePaymentResult;
|
|
62
|
+
var init_errors = __esm({
|
|
63
|
+
"src/types/errors.ts"() {
|
|
64
|
+
"use strict";
|
|
65
|
+
SpreePayHttpError = class extends Error {
|
|
66
|
+
constructor(status, body, url) {
|
|
67
|
+
const snippet = body.length > 200 ? `${body.slice(0, 200)}\u2026` : body;
|
|
68
|
+
super(snippet || `Request failed: ${status}`);
|
|
69
|
+
this.status = status;
|
|
70
|
+
this.body = body;
|
|
71
|
+
this.url = url;
|
|
72
|
+
this.name = "SpreePayHttpError";
|
|
73
|
+
}
|
|
74
|
+
status;
|
|
75
|
+
body;
|
|
76
|
+
url;
|
|
77
|
+
};
|
|
78
|
+
PaymentErrorCode = /* @__PURE__ */ ((PaymentErrorCode2) => {
|
|
79
|
+
PaymentErrorCode2["CARD_ERROR"] = "CARD_ERROR";
|
|
80
|
+
PaymentErrorCode2["PAYMENT_ERROR"] = "PAYMENT_ERROR";
|
|
81
|
+
return PaymentErrorCode2;
|
|
82
|
+
})(PaymentErrorCode || {});
|
|
83
|
+
PaymentError = class extends Error {
|
|
84
|
+
status;
|
|
85
|
+
code;
|
|
86
|
+
/**
|
|
87
|
+
* Optional stable code from the backend (e.g. `INSUFFICIENT_FUNDS`) for branching
|
|
88
|
+
* on specific cases without changing the `code` enum. Safe to expose (an
|
|
89
|
+
* identifier, not free-text); absent until the backend supplies one.
|
|
90
|
+
*/
|
|
91
|
+
backendCode;
|
|
92
|
+
constructor(message, status, options) {
|
|
93
|
+
super(message, { cause: options?.cause });
|
|
94
|
+
this.name = "PaymentError";
|
|
95
|
+
this.status = status;
|
|
96
|
+
this.code = options?.code ?? "PAYMENT_ERROR" /* PAYMENT_ERROR */;
|
|
97
|
+
this.backendCode = options?.backendCode;
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
isPaymentError = (e) => e instanceof PaymentError;
|
|
101
|
+
isDeclineStatus = (status) => status === "FAILED" /* FAILED */ || status === "CAPTURE_FAILED" /* CAPTURE_FAILED */;
|
|
102
|
+
isSuccessStatus = (status) => status === "AUTHORIZED" /* AUTHORIZED */ || status === "CAPTURED" /* CAPTURED */;
|
|
103
|
+
isProcessorRejection = (e) => e instanceof SpreePayHttpError && e.status >= 400 && e.status < 500 && e.status !== 401 && e.status !== 403 && e.status !== 404;
|
|
104
|
+
backendCodeFromBody = (e) => {
|
|
105
|
+
try {
|
|
106
|
+
const parsed = JSON.parse(e.body);
|
|
107
|
+
const code = parsed?.code ?? parsed?.errorCode;
|
|
108
|
+
if (typeof code === "string" && code.trim()) return code;
|
|
109
|
+
} catch {
|
|
110
|
+
}
|
|
111
|
+
return void 0;
|
|
112
|
+
};
|
|
113
|
+
toPaymentError = (e, fallbackMessage = "Payment failed", declineCode = "PAYMENT_ERROR" /* PAYMENT_ERROR */) => {
|
|
114
|
+
if (e instanceof PaymentError) return e;
|
|
115
|
+
return new PaymentError(fallbackMessage, "FAILED" /* FAILED */, {
|
|
116
|
+
code: isProcessorRejection(e) ? declineCode : "PAYMENT_ERROR" /* PAYMENT_ERROR */,
|
|
117
|
+
backendCode: e instanceof SpreePayHttpError ? backendCodeFromBody(e) : void 0,
|
|
118
|
+
cause: e
|
|
119
|
+
});
|
|
120
|
+
};
|
|
121
|
+
settlePaymentResult = (res, fallbackMessage, failureCode = "PAYMENT_ERROR" /* PAYMENT_ERROR */) => {
|
|
122
|
+
if (isSuccessStatus(res.status)) {
|
|
123
|
+
return res;
|
|
124
|
+
}
|
|
125
|
+
throw new PaymentError(fallbackMessage, res.status, {
|
|
126
|
+
code: isDeclineStatus(res.status) ? failureCode : "PAYMENT_ERROR" /* PAYMENT_ERROR */
|
|
127
|
+
});
|
|
128
|
+
};
|
|
65
129
|
}
|
|
66
130
|
});
|
|
67
131
|
|
|
@@ -69,7 +133,7 @@ var init_payments = __esm({
|
|
|
69
133
|
var version;
|
|
70
134
|
var init_package = __esm({
|
|
71
135
|
"package.json"() {
|
|
72
|
-
version = "0.
|
|
136
|
+
version = "0.5.1";
|
|
73
137
|
}
|
|
74
138
|
});
|
|
75
139
|
|
|
@@ -228,12 +292,11 @@ var init_SpreePayActionsContext = __esm({
|
|
|
228
292
|
hash: data.hash,
|
|
229
293
|
paymentType: selectedPaymentMethod.type
|
|
230
294
|
});
|
|
231
|
-
throw new
|
|
295
|
+
throw new Error("Payment already in progress");
|
|
232
296
|
}
|
|
233
297
|
processLogger.info("Payment process started", {
|
|
234
298
|
hash: data.hash,
|
|
235
299
|
capture: data.capture,
|
|
236
|
-
hasMetadata: Boolean(data.metadata),
|
|
237
300
|
paymentType: selectedPaymentMethod.type
|
|
238
301
|
});
|
|
239
302
|
inFlightRef.current = true;
|
|
@@ -253,8 +316,7 @@ var init_SpreePayActionsContext = __esm({
|
|
|
253
316
|
paymentType: selectedPaymentMethod.type,
|
|
254
317
|
errorMessage: e instanceof Error ? e.message : String(e)
|
|
255
318
|
});
|
|
256
|
-
|
|
257
|
-
throw new PaymentError("Payment failed", "FAILED" /* FAILED */, e);
|
|
319
|
+
throw toPaymentError(e);
|
|
258
320
|
} finally {
|
|
259
321
|
inFlightRef.current = false;
|
|
260
322
|
setInternalProcessing(false);
|
|
@@ -614,10 +676,11 @@ var init_Iframe3ds = __esm({
|
|
|
614
676
|
});
|
|
615
677
|
|
|
616
678
|
// src/fetcher/client.ts
|
|
617
|
-
var cfg, buildUrl, request, slapiApi, registerApi;
|
|
679
|
+
var cfg, buildUrl, parseResponse, publicGet, request, slapiApi, registerApi;
|
|
618
680
|
var init_client = __esm({
|
|
619
681
|
"src/fetcher/client.ts"() {
|
|
620
682
|
"use strict";
|
|
683
|
+
init_errors();
|
|
621
684
|
cfg = { baseUrl: void 0, accessToken: void 0, tenantId: void 0 };
|
|
622
685
|
buildUrl = (key) => {
|
|
623
686
|
if (!cfg.baseUrl) throw new Error("Missing SLAPI baseUrl. Call registerApi(...) first.");
|
|
@@ -631,6 +694,27 @@ var init_client = __esm({
|
|
|
631
694
|
const qs = usp.toString();
|
|
632
695
|
return cfg.baseUrl + url + (qs ? `?${qs}` : "");
|
|
633
696
|
};
|
|
697
|
+
parseResponse = async (res) => {
|
|
698
|
+
if (!res.ok) {
|
|
699
|
+
const text = await res.text().catch(() => "");
|
|
700
|
+
throw new SpreePayHttpError(res.status, text, res.url);
|
|
701
|
+
}
|
|
702
|
+
const contentType = res.headers.get("content-type") || "";
|
|
703
|
+
if (!contentType.includes("application/json")) {
|
|
704
|
+
return await res.text();
|
|
705
|
+
}
|
|
706
|
+
return await res.json();
|
|
707
|
+
};
|
|
708
|
+
publicGet = async (baseUrl, tenantId, path) => {
|
|
709
|
+
const res = await fetch(`${baseUrl}${path}`, {
|
|
710
|
+
headers: {
|
|
711
|
+
Accept: "application/json",
|
|
712
|
+
["X-Tenant-ID"]: tenantId
|
|
713
|
+
},
|
|
714
|
+
cache: "no-store"
|
|
715
|
+
});
|
|
716
|
+
return parseResponse(res);
|
|
717
|
+
};
|
|
634
718
|
request = async (method, url, body) => {
|
|
635
719
|
if (!cfg.accessToken) throw new Error("Missing SLAPI accessToken. Call registerApi(...) first.");
|
|
636
720
|
if (!cfg.tenantId) throw new Error("Missing SLAPI tenantId. Call registerApi(...) first.");
|
|
@@ -656,15 +740,7 @@ var init_client = __esm({
|
|
|
656
740
|
body: payload,
|
|
657
741
|
cache: "no-store"
|
|
658
742
|
});
|
|
659
|
-
|
|
660
|
-
const text = await res.text().catch(() => "");
|
|
661
|
-
throw new Error(text || `Request failed: ${res.status}`);
|
|
662
|
-
}
|
|
663
|
-
const contentType = res.headers.get("content-type") || "";
|
|
664
|
-
if (!contentType.includes("application/json")) {
|
|
665
|
-
return await res.text();
|
|
666
|
-
}
|
|
667
|
-
return await res.json();
|
|
743
|
+
return parseResponse(res);
|
|
668
744
|
};
|
|
669
745
|
slapiApi = {
|
|
670
746
|
get: async () => {
|
|
@@ -887,10 +963,17 @@ var init_useSpreePayConfig = __esm({
|
|
|
887
963
|
"use strict";
|
|
888
964
|
import_swr = __toESM(require("swr"), 1);
|
|
889
965
|
init_SpreePayActionsContext();
|
|
966
|
+
init_StaticConfigContext();
|
|
967
|
+
init_client();
|
|
890
968
|
URL = "/v1/tenants/configs/spree-pay";
|
|
891
969
|
useSpreePayConfig = () => {
|
|
892
|
-
const { origin } = useSpreePayEnv();
|
|
893
|
-
const {
|
|
970
|
+
const { origin, tenantId } = useSpreePayEnv();
|
|
971
|
+
const { staticConfig } = useStaticConfig();
|
|
972
|
+
const key = origin ? `${URL}?origin=${origin}` : URL;
|
|
973
|
+
const { data, isLoading } = (0, import_swr.default)(
|
|
974
|
+
key,
|
|
975
|
+
(path) => publicGet(staticConfig.slapiUrl, tenantId, path)
|
|
976
|
+
);
|
|
894
977
|
return { spreePayConfig: data ?? null, configIsLoading: isLoading };
|
|
895
978
|
};
|
|
896
979
|
}
|
|
@@ -926,13 +1009,27 @@ var init_useSlapiBalance = __esm({
|
|
|
926
1009
|
}
|
|
927
1010
|
});
|
|
928
1011
|
|
|
1012
|
+
// src/context/LoginStatusContext.tsx
|
|
1013
|
+
var import_react6, import_jsx_runtime5, LoginStatusContext, LoginStatusProvider, useIsLoggedIn;
|
|
1014
|
+
var init_LoginStatusContext = __esm({
|
|
1015
|
+
"src/context/LoginStatusContext.tsx"() {
|
|
1016
|
+
"use strict";
|
|
1017
|
+
"use client";
|
|
1018
|
+
import_react6 = require("react");
|
|
1019
|
+
import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1020
|
+
LoginStatusContext = (0, import_react6.createContext)(false);
|
|
1021
|
+
LoginStatusProvider = ({ isLoggedIn, children }) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(LoginStatusContext.Provider, { value: isLoggedIn, children });
|
|
1022
|
+
useIsLoggedIn = () => (0, import_react6.useContext)(LoginStatusContext);
|
|
1023
|
+
}
|
|
1024
|
+
});
|
|
1025
|
+
|
|
929
1026
|
// src/ui/spinner.tsx
|
|
930
|
-
var
|
|
1027
|
+
var import_jsx_runtime6, Spinner;
|
|
931
1028
|
var init_spinner = __esm({
|
|
932
1029
|
"src/ui/spinner.tsx"() {
|
|
933
1030
|
"use strict";
|
|
934
1031
|
init_utils();
|
|
935
|
-
|
|
1032
|
+
import_jsx_runtime6 = require("react/jsx-runtime");
|
|
936
1033
|
Spinner = (props) => {
|
|
937
1034
|
const { size = "md", className } = props;
|
|
938
1035
|
const sizeClasses = {
|
|
@@ -942,7 +1039,7 @@ var init_spinner = __esm({
|
|
|
942
1039
|
lg: "size-12",
|
|
943
1040
|
xl: "size-16"
|
|
944
1041
|
};
|
|
945
|
-
return /* @__PURE__ */ (0,
|
|
1042
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
946
1043
|
"svg",
|
|
947
1044
|
{
|
|
948
1045
|
className: cn(`${sizeClasses[size]} animate-spin text-(--tertiary)`, className),
|
|
@@ -952,7 +1049,7 @@ var init_spinner = __esm({
|
|
|
952
1049
|
width: "24",
|
|
953
1050
|
height: "24",
|
|
954
1051
|
children: [
|
|
955
|
-
/* @__PURE__ */ (0,
|
|
1052
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
956
1053
|
"path",
|
|
957
1054
|
{
|
|
958
1055
|
d: "M32 3C35.8083 3 39.5794 3.75011 43.0978 5.20749C46.6163 6.66488 49.8132 8.80101 52.5061 11.4939C55.199 14.1868 57.3351 17.3837 58.7925 20.9022C60.2499 24.4206 61 28.1917 61 32C61 35.8083 60.2499 39.5794 58.7925 43.0978C57.3351 46.6163 55.199 49.8132 52.5061 52.5061C49.8132 55.199 46.6163 57.3351 43.0978 58.7925C39.5794 60.2499 35.8083 61 32 61C28.1917 61 24.4206 60.2499 20.9022 58.7925C17.3837 57.3351 14.1868 55.199 11.4939 52.5061C8.801 49.8132 6.66487 46.6163 5.20749 43.0978C3.7501 39.5794 3 35.8083 3 32C3 28.1917 3.75011 24.4206 5.2075 20.9022C6.66489 17.3837 8.80101 14.1868 11.4939 11.4939C14.1868 8.80099 17.3838 6.66487 20.9022 5.20749C24.4206 3.7501 28.1917 3 32 3L32 3Z",
|
|
@@ -962,7 +1059,7 @@ var init_spinner = __esm({
|
|
|
962
1059
|
strokeLinejoin: "round"
|
|
963
1060
|
}
|
|
964
1061
|
),
|
|
965
|
-
/* @__PURE__ */ (0,
|
|
1062
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
966
1063
|
"path",
|
|
967
1064
|
{
|
|
968
1065
|
d: "M32 3C36.5778 3 41.0906 4.08374 45.1692 6.16256C49.2477 8.24138 52.7762 11.2562 55.466 14.9605C58.1558 18.6647 59.9304 22.9531 60.6448 27.4748C61.3591 31.9965 60.9928 36.6232 59.5759 40.9762",
|
|
@@ -1016,7 +1113,7 @@ var init_format = __esm({
|
|
|
1016
1113
|
|
|
1017
1114
|
// src/ui/label.tsx
|
|
1018
1115
|
function Label({ className, ...props }) {
|
|
1019
|
-
return /* @__PURE__ */ (0,
|
|
1116
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1020
1117
|
LabelPrimitive.Root,
|
|
1021
1118
|
{
|
|
1022
1119
|
"data-slot": "label",
|
|
@@ -1028,20 +1125,20 @@ function Label({ className, ...props }) {
|
|
|
1028
1125
|
}
|
|
1029
1126
|
);
|
|
1030
1127
|
}
|
|
1031
|
-
var LabelPrimitive,
|
|
1128
|
+
var LabelPrimitive, import_jsx_runtime7;
|
|
1032
1129
|
var init_label = __esm({
|
|
1033
1130
|
"src/ui/label.tsx"() {
|
|
1034
1131
|
"use strict";
|
|
1035
1132
|
"use client";
|
|
1036
1133
|
LabelPrimitive = __toESM(require("@radix-ui/react-label"), 1);
|
|
1037
1134
|
init_utils();
|
|
1038
|
-
|
|
1135
|
+
import_jsx_runtime7 = require("react/jsx-runtime");
|
|
1039
1136
|
}
|
|
1040
1137
|
});
|
|
1041
1138
|
|
|
1042
1139
|
// src/ui/switch.tsx
|
|
1043
1140
|
function Switch({ className, ...props }) {
|
|
1044
|
-
return /* @__PURE__ */ (0,
|
|
1141
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1045
1142
|
SwitchPrimitive.Root,
|
|
1046
1143
|
{
|
|
1047
1144
|
"data-slot": "switch",
|
|
@@ -1050,7 +1147,7 @@ function Switch({ className, ...props }) {
|
|
|
1050
1147
|
className
|
|
1051
1148
|
),
|
|
1052
1149
|
...props,
|
|
1053
|
-
children: /* @__PURE__ */ (0,
|
|
1150
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
1054
1151
|
SwitchPrimitive.Thumb,
|
|
1055
1152
|
{
|
|
1056
1153
|
"data-slot": "switch-thumb",
|
|
@@ -1060,29 +1157,29 @@ function Switch({ className, ...props }) {
|
|
|
1060
1157
|
}
|
|
1061
1158
|
);
|
|
1062
1159
|
}
|
|
1063
|
-
var SwitchPrimitive,
|
|
1160
|
+
var SwitchPrimitive, import_jsx_runtime8;
|
|
1064
1161
|
var init_switch = __esm({
|
|
1065
1162
|
"src/ui/switch.tsx"() {
|
|
1066
1163
|
"use strict";
|
|
1067
1164
|
"use client";
|
|
1068
1165
|
SwitchPrimitive = __toESM(require("@radix-ui/react-switch"), 1);
|
|
1069
1166
|
init_utils();
|
|
1070
|
-
|
|
1167
|
+
import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1071
1168
|
}
|
|
1072
1169
|
});
|
|
1073
1170
|
|
|
1074
1171
|
// src/components/common/InfoBanner.tsx
|
|
1075
|
-
var import_xss,
|
|
1172
|
+
var import_xss, import_jsx_runtime9, InfoBanner;
|
|
1076
1173
|
var init_InfoBanner = __esm({
|
|
1077
1174
|
"src/components/common/InfoBanner.tsx"() {
|
|
1078
1175
|
"use strict";
|
|
1079
1176
|
import_xss = __toESM(require("xss"), 1);
|
|
1080
1177
|
init_utils();
|
|
1081
|
-
|
|
1178
|
+
import_jsx_runtime9 = require("react/jsx-runtime");
|
|
1082
1179
|
InfoBanner = (props) => {
|
|
1083
1180
|
const { type = "info", message } = props;
|
|
1084
1181
|
if (!message) return null;
|
|
1085
|
-
return /* @__PURE__ */ (0,
|
|
1182
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
1086
1183
|
"div",
|
|
1087
1184
|
{
|
|
1088
1185
|
className: cn("flex w-full gap-1.5 rounded-md p-2", {
|
|
@@ -1090,14 +1187,14 @@ var init_InfoBanner = __esm({
|
|
|
1090
1187
|
"bg-(--s-warning)/10": type === "warning"
|
|
1091
1188
|
}),
|
|
1092
1189
|
children: [
|
|
1093
|
-
type === "info" && /* @__PURE__ */ (0,
|
|
1190
|
+
type === "info" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1094
1191
|
"svg",
|
|
1095
1192
|
{
|
|
1096
1193
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1097
1194
|
fill: "none",
|
|
1098
1195
|
viewBox: "0 0 20 20",
|
|
1099
1196
|
className: "size-5 shrink-0 text-(--positive)",
|
|
1100
|
-
children: /* @__PURE__ */ (0,
|
|
1197
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1101
1198
|
"path",
|
|
1102
1199
|
{
|
|
1103
1200
|
fill: "currentColor",
|
|
@@ -1106,14 +1203,14 @@ var init_InfoBanner = __esm({
|
|
|
1106
1203
|
)
|
|
1107
1204
|
}
|
|
1108
1205
|
),
|
|
1109
|
-
type === "warning" && /* @__PURE__ */ (0,
|
|
1206
|
+
type === "warning" && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1110
1207
|
"svg",
|
|
1111
1208
|
{
|
|
1112
1209
|
xmlns: "http://www.w3.org/2000/svg",
|
|
1113
1210
|
fill: "none",
|
|
1114
1211
|
viewBox: "0 0 20 20",
|
|
1115
1212
|
className: "size-5 shrink-0 text-(--warning)",
|
|
1116
|
-
children: /* @__PURE__ */ (0,
|
|
1213
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1117
1214
|
"path",
|
|
1118
1215
|
{
|
|
1119
1216
|
fill: "currentColor",
|
|
@@ -1122,7 +1219,7 @@ var init_InfoBanner = __esm({
|
|
|
1122
1219
|
)
|
|
1123
1220
|
}
|
|
1124
1221
|
),
|
|
1125
|
-
/* @__PURE__ */ (0,
|
|
1222
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
1126
1223
|
"p",
|
|
1127
1224
|
{
|
|
1128
1225
|
className: "break-anywhere text-[14px] leading-5 text-(--primary) [&_a]:underline",
|
|
@@ -1137,11 +1234,11 @@ var init_InfoBanner = __esm({
|
|
|
1137
1234
|
});
|
|
1138
1235
|
|
|
1139
1236
|
// src/components/common/PointsSwitch.tsx
|
|
1140
|
-
var
|
|
1237
|
+
var import_react7, import_jsx_runtime10, PointsSwitch;
|
|
1141
1238
|
var init_PointsSwitch = __esm({
|
|
1142
1239
|
"src/components/common/PointsSwitch.tsx"() {
|
|
1143
1240
|
"use strict";
|
|
1144
|
-
|
|
1241
|
+
import_react7 = require("react");
|
|
1145
1242
|
init_StaticConfigContext();
|
|
1146
1243
|
init_useSlapiBalance();
|
|
1147
1244
|
init_useSpreePayConfig();
|
|
@@ -1149,7 +1246,7 @@ var init_PointsSwitch = __esm({
|
|
|
1149
1246
|
init_switch();
|
|
1150
1247
|
init_format();
|
|
1151
1248
|
init_InfoBanner();
|
|
1152
|
-
|
|
1249
|
+
import_jsx_runtime10 = require("react/jsx-runtime");
|
|
1153
1250
|
PointsSwitch = (props) => {
|
|
1154
1251
|
const { disabled = false, value, onChange, message } = props;
|
|
1155
1252
|
const { spreePayConfig } = useSpreePayConfig();
|
|
@@ -1158,29 +1255,29 @@ var init_PointsSwitch = __esm({
|
|
|
1158
1255
|
const { balance } = useSlapiBalance();
|
|
1159
1256
|
const hasForeignCurrency = !!(currencyCode && exchangeRate && foreignCurrencyAmount);
|
|
1160
1257
|
const formatPointsValue = (usd) => hasForeignCurrency ? formatCurrency(usd / exchangeRate, currencyCode) : formatCurrency(usd);
|
|
1161
|
-
const id = (0,
|
|
1162
|
-
return /* @__PURE__ */ (0,
|
|
1163
|
-
/* @__PURE__ */ (0,
|
|
1164
|
-
/* @__PURE__ */ (0,
|
|
1165
|
-
/* @__PURE__ */ (0,
|
|
1166
|
-
/* @__PURE__ */ (0,
|
|
1258
|
+
const id = (0, import_react7.useId)();
|
|
1259
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex flex-col gap-6", children: [
|
|
1260
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center justify-between gap-3", children: [
|
|
1261
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-3", children: [
|
|
1262
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(Switch, { checked: value, onCheckedChange: onChange, disabled, id }),
|
|
1263
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(
|
|
1167
1264
|
Label,
|
|
1168
1265
|
{
|
|
1169
1266
|
htmlFor: id,
|
|
1170
1267
|
className: "text-md flex-col items-baseline gap-0 leading-[1.3] font-medium text-(--brand-primary) sm:flex-row sm:gap-2 md:text-[22px]",
|
|
1171
1268
|
children: [
|
|
1172
1269
|
"Use Points ",
|
|
1173
|
-
/* @__PURE__ */ (0,
|
|
1270
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-xs font-medium text-(--tertiary)", children: "Optional" })
|
|
1174
1271
|
]
|
|
1175
1272
|
}
|
|
1176
1273
|
)
|
|
1177
1274
|
] }),
|
|
1178
|
-
/* @__PURE__ */ (0,
|
|
1179
|
-
balance?.availablePoints ? /* @__PURE__ */ (0,
|
|
1275
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("div", { className: "flex items-center gap-2.5", children: [
|
|
1276
|
+
balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("p", { className: "flex-1 text-right text-sm font-medium text-(--brand-primary)", children: [
|
|
1180
1277
|
formatPoints(balance.availablePoints, spreePayConfig?.pointsTitle),
|
|
1181
|
-
!!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ (0,
|
|
1278
|
+
!!spreePayConfig?.pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("span", { className: "text-(--secondary)", children: ` \xB7 ${formatPointsValue(balance.availablePoints * spreePayConfig.pointsConversionRatio)}` })
|
|
1182
1279
|
] }) : null,
|
|
1183
|
-
Boolean(topUpLink) && /* @__PURE__ */ (0,
|
|
1280
|
+
Boolean(topUpLink) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
1184
1281
|
"a",
|
|
1185
1282
|
{
|
|
1186
1283
|
className: "cursor-pointer rounded-full bg-(--s-brand) px-2 py-1.5 text-xs font-medium text-(--inverse) hover:bg-(--s-brand-hover)",
|
|
@@ -1192,25 +1289,25 @@ var init_PointsSwitch = __esm({
|
|
|
1192
1289
|
)
|
|
1193
1290
|
] })
|
|
1194
1291
|
] }),
|
|
1195
|
-
message && /* @__PURE__ */ (0,
|
|
1292
|
+
message && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(InfoBanner, { type: "warning", message })
|
|
1196
1293
|
] });
|
|
1197
1294
|
};
|
|
1198
1295
|
}
|
|
1199
1296
|
});
|
|
1200
1297
|
|
|
1201
1298
|
// src/components/common/Legal.tsx
|
|
1202
|
-
var
|
|
1299
|
+
var import_jsx_runtime11, Legal;
|
|
1203
1300
|
var init_Legal = __esm({
|
|
1204
1301
|
"src/components/common/Legal.tsx"() {
|
|
1205
1302
|
"use strict";
|
|
1206
1303
|
init_useSpreePayConfig();
|
|
1207
|
-
|
|
1304
|
+
import_jsx_runtime11 = require("react/jsx-runtime");
|
|
1208
1305
|
Legal = () => {
|
|
1209
1306
|
const { spreePayConfig } = useSpreePayConfig();
|
|
1210
|
-
return /* @__PURE__ */ (0,
|
|
1307
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)("p", { className: "text-xs leading-5 font-medium text-(--secondary)", children: [
|
|
1211
1308
|
"By clicking on the button below I acknowledge that I have read and accepted the",
|
|
1212
1309
|
" ",
|
|
1213
|
-
/* @__PURE__ */ (0,
|
|
1310
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
1214
1311
|
"a",
|
|
1215
1312
|
{
|
|
1216
1313
|
className: "whitespace-nowrap underline",
|
|
@@ -1237,10 +1334,11 @@ var init_common = __esm({
|
|
|
1237
1334
|
});
|
|
1238
1335
|
|
|
1239
1336
|
// src/components/CheckoutButton.tsx
|
|
1240
|
-
var
|
|
1337
|
+
var import_jsx_runtime12, CheckoutButton;
|
|
1241
1338
|
var init_CheckoutButton = __esm({
|
|
1242
1339
|
"src/components/CheckoutButton.tsx"() {
|
|
1243
1340
|
"use strict";
|
|
1341
|
+
init_LoginStatusContext();
|
|
1244
1342
|
init_SpreePayActionsContext();
|
|
1245
1343
|
init_StaticConfigContext();
|
|
1246
1344
|
init_useSpreePayConfig();
|
|
@@ -1249,8 +1347,9 @@ var init_CheckoutButton = __esm({
|
|
|
1249
1347
|
init_split();
|
|
1250
1348
|
init_transactionFee();
|
|
1251
1349
|
init_common();
|
|
1252
|
-
|
|
1253
|
-
CheckoutButton = (
|
|
1350
|
+
import_jsx_runtime12 = require("react/jsx-runtime");
|
|
1351
|
+
CheckoutButton = () => {
|
|
1352
|
+
const isLoggedIn = useIsLoggedIn();
|
|
1254
1353
|
const { appProps, staticConfig } = useStaticConfig();
|
|
1255
1354
|
const {
|
|
1256
1355
|
amount,
|
|
@@ -1280,7 +1379,7 @@ var init_CheckoutButton = __esm({
|
|
|
1280
1379
|
};
|
|
1281
1380
|
const getCheckoutContent = () => {
|
|
1282
1381
|
if (!!isProcessing || isInternalProcessing) {
|
|
1283
|
-
return /* @__PURE__ */ (0,
|
|
1382
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Spinner, { className: "inline", size: "sm" });
|
|
1284
1383
|
}
|
|
1285
1384
|
if (isCC && amount) {
|
|
1286
1385
|
if (pointsAmount && usdAmount) {
|
|
@@ -1300,22 +1399,19 @@ var init_CheckoutButton = __esm({
|
|
|
1300
1399
|
return "Checkout";
|
|
1301
1400
|
};
|
|
1302
1401
|
const checkoutClass = "text-(--inverse) h-14 leading-14 w-full cursor-pointer rounded-4xl bg-(--s-brand) hover:bg-(--s-brand-hover) px-4 text-center text-xl leading-6 font-medium disabled:cursor-not-allowed disabled:bg-(--s-disabled) disabled:text-(--disabled)";
|
|
1303
|
-
return /* @__PURE__ */ (0,
|
|
1304
|
-
/* @__PURE__ */ (0,
|
|
1305
|
-
isLoggedIn ? /* @__PURE__ */ (0,
|
|
1402
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("div", { className: "flex w-full flex-col gap-4 p-6 text-xs leading-5 font-medium text-(--secondary) md:px-7", children: [
|
|
1403
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(Legal, {}),
|
|
1404
|
+
isLoggedIn ? /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(import_jsx_runtime12.Fragment, { children: onProcess && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)("button", { disabled: isDisabled, onClick: onProcess, className: checkoutClass, children: getCheckoutContent() }) }) : /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1306
1405
|
"a",
|
|
1307
1406
|
{
|
|
1308
1407
|
href: `${staticConfig.keycloakUrl}/realms/${tenantId}/protocol/openid-connect/auth?client_id=${keycloakClientId ?? "oneof-next"}&response_type=code&redirect_uri=${window.location.href}`,
|
|
1309
1408
|
className: checkoutClass,
|
|
1310
|
-
children:
|
|
1311
|
-
"Log in / Sign up",
|
|
1312
|
-
tenantId === "moca" ? " for an AIR account" : ""
|
|
1313
|
-
]
|
|
1409
|
+
children: spreePayConfig?.loginLabel || "Log in / Sign up"
|
|
1314
1410
|
}
|
|
1315
1411
|
),
|
|
1316
|
-
/* @__PURE__ */ (0,
|
|
1317
|
-
/* @__PURE__ */ (0,
|
|
1318
|
-
/* @__PURE__ */ (0,
|
|
1412
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsxs)("a", { href: "https://www.spree.finance/", className: "flex items-center justify-center gap-2 hover:underline", children: [
|
|
1413
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("p", { children: "Powered by" }),
|
|
1414
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "h-[30px]", viewBox: "0 0 66 30", children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
1319
1415
|
"path",
|
|
1320
1416
|
{
|
|
1321
1417
|
fill: "currentColor",
|
|
@@ -1552,7 +1648,7 @@ var init_useCryptoPayment = __esm({
|
|
|
1552
1648
|
});
|
|
1553
1649
|
throw error;
|
|
1554
1650
|
}
|
|
1555
|
-
const { capture, hash
|
|
1651
|
+
const { capture, hash } = params;
|
|
1556
1652
|
const TOKEN = selectedPaymentMethod.method.symbol;
|
|
1557
1653
|
cryptoPaymentLogger.info("Starting crypto payment", {
|
|
1558
1654
|
hash,
|
|
@@ -1612,7 +1708,6 @@ var init_useCryptoPayment = __esm({
|
|
|
1612
1708
|
const paymentRes = await SlapiPaymentService.createPayment({
|
|
1613
1709
|
hash,
|
|
1614
1710
|
capture,
|
|
1615
|
-
metadata,
|
|
1616
1711
|
type: "CRYPTO" /* CRYPTO */,
|
|
1617
1712
|
crypto: {
|
|
1618
1713
|
token: TOKEN,
|
|
@@ -1666,26 +1761,26 @@ var init_useCryptoPayment = __esm({
|
|
|
1666
1761
|
});
|
|
1667
1762
|
|
|
1668
1763
|
// src/components/CryptoTab/Crypto/ConnectButton.tsx
|
|
1669
|
-
var import_rainbowkit,
|
|
1764
|
+
var import_rainbowkit, import_jsx_runtime31, ConnectButton;
|
|
1670
1765
|
var init_ConnectButton = __esm({
|
|
1671
1766
|
"src/components/CryptoTab/Crypto/ConnectButton.tsx"() {
|
|
1672
1767
|
"use strict";
|
|
1673
1768
|
import_rainbowkit = require("@rainbow-me/rainbowkit");
|
|
1674
1769
|
init_utils();
|
|
1675
|
-
|
|
1770
|
+
import_jsx_runtime31 = require("react/jsx-runtime");
|
|
1676
1771
|
ConnectButton = () => {
|
|
1677
1772
|
const buttonCN = "h-9 rounded-full border border-(--b-brand) px-4 text-sm font-medium text-(--brand-primary)";
|
|
1678
|
-
return /* @__PURE__ */ (0,
|
|
1773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_rainbowkit.ConnectButton.Custom, { children: ({ mounted, chain, account, openAccountModal, openChainModal, openConnectModal }) => {
|
|
1679
1774
|
if (!mounted) return null;
|
|
1680
|
-
return /* @__PURE__ */ (0,
|
|
1775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)(import_jsx_runtime31.Fragment, { children: (() => {
|
|
1681
1776
|
if (!mounted || !account || !chain) {
|
|
1682
|
-
return /* @__PURE__ */ (0,
|
|
1777
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { className: buttonCN, onClick: openConnectModal, children: "Connect wallet" });
|
|
1683
1778
|
}
|
|
1684
1779
|
if (chain.unsupported) {
|
|
1685
|
-
return /* @__PURE__ */ (0,
|
|
1780
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("button", { className: buttonCN, onClick: openChainModal, children: "Select a Network" });
|
|
1686
1781
|
}
|
|
1687
|
-
return /* @__PURE__ */ (0,
|
|
1688
|
-
chain.hasIcon && /* @__PURE__ */ (0,
|
|
1782
|
+
return /* @__PURE__ */ (0, import_jsx_runtime31.jsxs)("button", { className: cn(buttonCN, "flex items-center gap-2 pl-1.5"), onClick: openAccountModal, children: [
|
|
1783
|
+
chain.hasIcon && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("div", { className: "size-6 overflow-hidden rounded-full", style: { background: chain.iconBackground }, children: chain.iconUrl && /* @__PURE__ */ (0, import_jsx_runtime31.jsx)("img", { alt: chain.name ?? "Chain icon", src: chain.iconUrl }) }),
|
|
1689
1784
|
account.displayName
|
|
1690
1785
|
] });
|
|
1691
1786
|
})() });
|
|
@@ -1698,32 +1793,32 @@ var init_ConnectButton = __esm({
|
|
|
1698
1793
|
function getSymbolLogo(symbol) {
|
|
1699
1794
|
return symbolLogos[symbol] ?? null;
|
|
1700
1795
|
}
|
|
1701
|
-
var
|
|
1796
|
+
var import_jsx_runtime32, MOCA_SVG, USDC_SVG, USDT_SVG, WETH_SVG, symbolLogos;
|
|
1702
1797
|
var init_symbolLogos = __esm({
|
|
1703
1798
|
"src/config/symbolLogos.tsx"() {
|
|
1704
1799
|
"use strict";
|
|
1705
|
-
|
|
1706
|
-
MOCA_SVG = /* @__PURE__ */ (0,
|
|
1707
|
-
/* @__PURE__ */ (0,
|
|
1708
|
-
/* @__PURE__ */ (0,
|
|
1800
|
+
import_jsx_runtime32 = require("react/jsx-runtime");
|
|
1801
|
+
MOCA_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-7", viewBox: "0 0 28 28", children: [
|
|
1802
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("circle", { cx: "14", cy: "14", r: "13.5", fill: "#c15f97" }),
|
|
1803
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1709
1804
|
"path",
|
|
1710
1805
|
{
|
|
1711
1806
|
fill: "#fff",
|
|
1712
1807
|
d: "M16.06 6.65c.3 0 .59.16.74.43l6.06 10.5a.85.85 0 1 1-1.47.84L16.06 9.2l-1.51 2.62-.02.03-3.8 6.57a.85.85 0 0 1-1.47-.84l3.57-6.18-1.27-2.2-5.32 9.22a.85.85 0 0 1-1.48-.84l6.07-10.5.06-.1a.85.85 0 0 1 1.4.1l1.52 2.62 1.52-2.62.06-.1c.16-.2.4-.33.67-.33"
|
|
1713
1808
|
}
|
|
1714
1809
|
),
|
|
1715
|
-
/* @__PURE__ */ (0,
|
|
1810
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("circle", { cx: "16", cy: "14", r: "1.5", fill: "#fff" })
|
|
1716
1811
|
] });
|
|
1717
|
-
USDC_SVG = /* @__PURE__ */ (0,
|
|
1718
|
-
/* @__PURE__ */ (0,
|
|
1719
|
-
/* @__PURE__ */ (0,
|
|
1812
|
+
USDC_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "size-7", fill: "none", viewBox: "0 0 28 28", children: [
|
|
1813
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#2775ca", d: "M14 28c7.76 0 14-6.24 14-14S21.76 0 14 0 0 6.24 0 14s6.24 14 14 14" }),
|
|
1814
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1720
1815
|
"path",
|
|
1721
1816
|
{
|
|
1722
1817
|
fill: "#fff",
|
|
1723
1818
|
d: "M17.85 16.22c0-2.04-1.23-2.74-3.68-3.04-1.75-.23-2.1-.7-2.1-1.51 0-.82.59-1.34 1.75-1.34 1.05 0 1.64.35 1.93 1.22.06.18.23.3.4.3h.94a.4.4 0 0 0 .41-.42v-.05a2.91 2.91 0 0 0-2.63-2.4v-1.4c0-.23-.17-.4-.46-.46h-.88c-.23 0-.4.17-.46.46v1.35c-1.75.23-2.86 1.4-2.86 2.85 0 1.93 1.16 2.69 3.61 2.98 1.64.29 2.16.64 2.16 1.57 0 .94-.81 1.58-1.92 1.58-1.52 0-2.04-.64-2.22-1.52-.06-.23-.23-.35-.4-.35h-1a.4.4 0 0 0-.4.41v.06c.23 1.46 1.16 2.5 3.08 2.8v1.4c0 .23.18.4.47.47h.88c.23 0 .4-.18.46-.47v-1.4c1.75-.3 2.92-1.52 2.92-3.1Z"
|
|
1724
1819
|
}
|
|
1725
1820
|
),
|
|
1726
|
-
/* @__PURE__ */ (0,
|
|
1821
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1727
1822
|
"path",
|
|
1728
1823
|
{
|
|
1729
1824
|
fill: "#fff",
|
|
@@ -1731,9 +1826,9 @@ var init_symbolLogos = __esm({
|
|
|
1731
1826
|
}
|
|
1732
1827
|
)
|
|
1733
1828
|
] });
|
|
1734
|
-
USDT_SVG = /* @__PURE__ */ (0,
|
|
1735
|
-
/* @__PURE__ */ (0,
|
|
1736
|
-
/* @__PURE__ */ (0,
|
|
1829
|
+
USDT_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "size-7", fill: "none", viewBox: "0 0 28 28", children: [
|
|
1830
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#26a17b", d: "M14 28a14 14 0 1 0 0-28 14 14 0 0 0 0 28" }),
|
|
1831
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1737
1832
|
"path",
|
|
1738
1833
|
{
|
|
1739
1834
|
fill: "#fff",
|
|
@@ -1741,23 +1836,23 @@ var init_symbolLogos = __esm({
|
|
|
1741
1836
|
}
|
|
1742
1837
|
)
|
|
1743
1838
|
] });
|
|
1744
|
-
WETH_SVG = /* @__PURE__ */ (0,
|
|
1745
|
-
/* @__PURE__ */ (0,
|
|
1746
|
-
/* @__PURE__ */ (0,
|
|
1839
|
+
WETH_SVG = /* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-7", viewBox: "0 0 24 24", children: [
|
|
1840
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsxs)("g", { clipPath: "url(#clip0_528_9173)", children: [
|
|
1841
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1747
1842
|
"path",
|
|
1748
1843
|
{
|
|
1749
1844
|
fill: "#000",
|
|
1750
1845
|
d: "M17.14 20.57c0 .95-1.31 2.01-3.39 2.4h-2.59c-4.65 0-8.42-1.07-8.42-2.4 0-1.32 3.77-2.4 8.42-2.4s5.98 1.08 5.98 2.4Z"
|
|
1751
1846
|
}
|
|
1752
1847
|
),
|
|
1753
|
-
/* @__PURE__ */ (0,
|
|
1848
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1754
1849
|
"path",
|
|
1755
1850
|
{
|
|
1756
1851
|
fill: "#F61F7D",
|
|
1757
1852
|
d: "M23.31 11c0 5.86-5.18 11.63-11.07 11.63-5.9 0-11.9-6.17-11.9-12.03C.34 4.75 5.12 0 11.01 0s12.3 5.15 12.3 11Z"
|
|
1758
1853
|
}
|
|
1759
1854
|
),
|
|
1760
|
-
/* @__PURE__ */ (0,
|
|
1855
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1761
1856
|
"path",
|
|
1762
1857
|
{
|
|
1763
1858
|
fill: "#000",
|
|
@@ -1766,8 +1861,8 @@ var init_symbolLogos = __esm({
|
|
|
1766
1861
|
clipRule: "evenodd"
|
|
1767
1862
|
}
|
|
1768
1863
|
),
|
|
1769
|
-
/* @__PURE__ */ (0,
|
|
1770
|
-
/* @__PURE__ */ (0,
|
|
1864
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#fff", d: "M24 12.17a10.8 10.8 0 1 1-21.6 0 10.8 10.8 0 0 1 21.6 0Z" }),
|
|
1865
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1771
1866
|
"path",
|
|
1772
1867
|
{
|
|
1773
1868
|
fill: "#000",
|
|
@@ -1776,8 +1871,8 @@ var init_symbolLogos = __esm({
|
|
|
1776
1871
|
clipRule: "evenodd"
|
|
1777
1872
|
}
|
|
1778
1873
|
),
|
|
1779
|
-
/* @__PURE__ */ (0,
|
|
1780
|
-
/* @__PURE__ */ (0,
|
|
1874
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#000", fillRule: "evenodd", d: "M3.02 10.63.7 8.75l.74-.86 2.34 1.87-.75.87Z", clipRule: "evenodd" }),
|
|
1875
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)(
|
|
1781
1876
|
"path",
|
|
1782
1877
|
{
|
|
1783
1878
|
fill: "#000",
|
|
@@ -1785,7 +1880,7 @@ var init_symbolLogos = __esm({
|
|
|
1785
1880
|
}
|
|
1786
1881
|
)
|
|
1787
1882
|
] }),
|
|
1788
|
-
/* @__PURE__ */ (0,
|
|
1883
|
+
/* @__PURE__ */ (0, import_jsx_runtime32.jsx)("defs", { children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("clipPath", { id: "clip0_528_9173", children: /* @__PURE__ */ (0, import_jsx_runtime32.jsx)("path", { fill: "#fff", d: "M0 0h24v24H0z" }) }) })
|
|
1789
1884
|
] });
|
|
1790
1885
|
symbolLogos = {
|
|
1791
1886
|
MOCA: MOCA_SVG,
|
|
@@ -1797,18 +1892,18 @@ var init_symbolLogos = __esm({
|
|
|
1797
1892
|
});
|
|
1798
1893
|
|
|
1799
1894
|
// src/components/CryptoTab/Crypto/Logos.tsx
|
|
1800
|
-
var
|
|
1895
|
+
var import_jsx_runtime33, Logos;
|
|
1801
1896
|
var init_Logos = __esm({
|
|
1802
1897
|
"src/components/CryptoTab/Crypto/Logos.tsx"() {
|
|
1803
1898
|
"use strict";
|
|
1804
1899
|
init_symbolLogos();
|
|
1805
|
-
|
|
1900
|
+
import_jsx_runtime33 = require("react/jsx-runtime");
|
|
1806
1901
|
Logos = () => {
|
|
1807
|
-
return /* @__PURE__ */ (0,
|
|
1808
|
-
/* @__PURE__ */ (0,
|
|
1809
|
-
/* @__PURE__ */ (0,
|
|
1810
|
-
/* @__PURE__ */ (0,
|
|
1811
|
-
/* @__PURE__ */ (0,
|
|
1902
|
+
return /* @__PURE__ */ (0, import_jsx_runtime33.jsxs)("div", { className: "flex", children: [
|
|
1903
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "rounded-full border border-(--b-primary)", children: getSymbolLogo("MOCA") }),
|
|
1904
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary)", children: getSymbolLogo("USDC") }),
|
|
1905
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary)", children: getSymbolLogo("USDT") }),
|
|
1906
|
+
/* @__PURE__ */ (0, import_jsx_runtime33.jsx)("div", { className: "-ml-2.5 rounded-full border border-(--b-primary) bg-(--s-primary)", children: getSymbolLogo("WETH") })
|
|
1812
1907
|
] });
|
|
1813
1908
|
};
|
|
1814
1909
|
}
|
|
@@ -1816,7 +1911,7 @@ var init_Logos = __esm({
|
|
|
1816
1911
|
|
|
1817
1912
|
// ../ui/src/components/input.tsx
|
|
1818
1913
|
function Input2({ className, type, ...props }) {
|
|
1819
|
-
return /* @__PURE__ */ (0,
|
|
1914
|
+
return /* @__PURE__ */ (0, import_jsx_runtime34.jsx)(
|
|
1820
1915
|
"input",
|
|
1821
1916
|
{
|
|
1822
1917
|
type,
|
|
@@ -1831,24 +1926,24 @@ function Input2({ className, type, ...props }) {
|
|
|
1831
1926
|
}
|
|
1832
1927
|
);
|
|
1833
1928
|
}
|
|
1834
|
-
var
|
|
1929
|
+
var import_jsx_runtime34;
|
|
1835
1930
|
var init_input = __esm({
|
|
1836
1931
|
"../ui/src/components/input.tsx"() {
|
|
1837
1932
|
"use strict";
|
|
1838
1933
|
init_utils2();
|
|
1839
|
-
|
|
1934
|
+
import_jsx_runtime34 = require("react/jsx-runtime");
|
|
1840
1935
|
}
|
|
1841
1936
|
});
|
|
1842
1937
|
|
|
1843
1938
|
// ../../node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-primitive/dist/index.mjs
|
|
1844
|
-
var React13, ReactDOM2, import_react_slot5,
|
|
1939
|
+
var React13, ReactDOM2, import_react_slot5, import_jsx_runtime35, NODES2, Primitive2;
|
|
1845
1940
|
var init_dist = __esm({
|
|
1846
1941
|
"../../node_modules/@radix-ui/react-separator/node_modules/@radix-ui/react-primitive/dist/index.mjs"() {
|
|
1847
1942
|
"use strict";
|
|
1848
1943
|
React13 = __toESM(require("react"), 1);
|
|
1849
1944
|
ReactDOM2 = __toESM(require("react-dom"), 1);
|
|
1850
1945
|
import_react_slot5 = require("@radix-ui/react-slot");
|
|
1851
|
-
|
|
1946
|
+
import_jsx_runtime35 = require("react/jsx-runtime");
|
|
1852
1947
|
NODES2 = [
|
|
1853
1948
|
"a",
|
|
1854
1949
|
"button",
|
|
@@ -1876,7 +1971,7 @@ var init_dist = __esm({
|
|
|
1876
1971
|
if (typeof window !== "undefined") {
|
|
1877
1972
|
window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
|
|
1878
1973
|
}
|
|
1879
|
-
return /* @__PURE__ */ (0,
|
|
1974
|
+
return /* @__PURE__ */ (0, import_jsx_runtime35.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
1880
1975
|
});
|
|
1881
1976
|
Node2.displayName = `Primitive.${node}`;
|
|
1882
1977
|
return { ...primitive, [node]: Node2 };
|
|
@@ -1888,13 +1983,13 @@ var init_dist = __esm({
|
|
|
1888
1983
|
function isValidOrientation(orientation) {
|
|
1889
1984
|
return ORIENTATIONS.includes(orientation);
|
|
1890
1985
|
}
|
|
1891
|
-
var React14,
|
|
1986
|
+
var React14, import_jsx_runtime36, NAME, DEFAULT_ORIENTATION, ORIENTATIONS, Separator, Root6;
|
|
1892
1987
|
var init_dist2 = __esm({
|
|
1893
1988
|
"../../node_modules/@radix-ui/react-separator/dist/index.mjs"() {
|
|
1894
1989
|
"use strict";
|
|
1895
1990
|
React14 = __toESM(require("react"), 1);
|
|
1896
1991
|
init_dist();
|
|
1897
|
-
|
|
1992
|
+
import_jsx_runtime36 = require("react/jsx-runtime");
|
|
1898
1993
|
NAME = "Separator";
|
|
1899
1994
|
DEFAULT_ORIENTATION = "horizontal";
|
|
1900
1995
|
ORIENTATIONS = ["horizontal", "vertical"];
|
|
@@ -1903,7 +1998,7 @@ var init_dist2 = __esm({
|
|
|
1903
1998
|
const orientation = isValidOrientation(orientationProp) ? orientationProp : DEFAULT_ORIENTATION;
|
|
1904
1999
|
const ariaOrientation = orientation === "vertical" ? orientation : void 0;
|
|
1905
2000
|
const semanticProps = decorative ? { role: "none" } : { "aria-orientation": ariaOrientation, role: "separator" };
|
|
1906
|
-
return /* @__PURE__ */ (0,
|
|
2001
|
+
return /* @__PURE__ */ (0, import_jsx_runtime36.jsx)(
|
|
1907
2002
|
Primitive2.div,
|
|
1908
2003
|
{
|
|
1909
2004
|
"data-orientation": orientation,
|
|
@@ -1925,7 +2020,7 @@ function Separator2({
|
|
|
1925
2020
|
decorative = true,
|
|
1926
2021
|
...props
|
|
1927
2022
|
}) {
|
|
1928
|
-
return /* @__PURE__ */ (0,
|
|
2023
|
+
return /* @__PURE__ */ (0, import_jsx_runtime37.jsx)(
|
|
1929
2024
|
Root6,
|
|
1930
2025
|
{
|
|
1931
2026
|
"data-slot": "separator",
|
|
@@ -1939,14 +2034,14 @@ function Separator2({
|
|
|
1939
2034
|
}
|
|
1940
2035
|
);
|
|
1941
2036
|
}
|
|
1942
|
-
var
|
|
2037
|
+
var import_jsx_runtime37;
|
|
1943
2038
|
var init_separator = __esm({
|
|
1944
2039
|
"../ui/src/components/separator.tsx"() {
|
|
1945
2040
|
"use strict";
|
|
1946
2041
|
"use client";
|
|
1947
2042
|
init_dist2();
|
|
1948
2043
|
init_utils2();
|
|
1949
|
-
|
|
2044
|
+
import_jsx_runtime37 = require("react/jsx-runtime");
|
|
1950
2045
|
}
|
|
1951
2046
|
});
|
|
1952
2047
|
|
|
@@ -2062,11 +2157,11 @@ var init_useBaseTokens = __esm({
|
|
|
2062
2157
|
});
|
|
2063
2158
|
|
|
2064
2159
|
// src/modals/CryptoSelectModal.tsx
|
|
2065
|
-
var
|
|
2160
|
+
var import_react17, import_nice_modal_react5, import_jsx_runtime38, CryptoSelectModal;
|
|
2066
2161
|
var init_CryptoSelectModal = __esm({
|
|
2067
2162
|
"src/modals/CryptoSelectModal.tsx"() {
|
|
2068
2163
|
"use strict";
|
|
2069
|
-
|
|
2164
|
+
import_react17 = require("react");
|
|
2070
2165
|
import_nice_modal_react5 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
2071
2166
|
init_input();
|
|
2072
2167
|
init_separator();
|
|
@@ -2076,14 +2171,14 @@ var init_CryptoSelectModal = __esm({
|
|
|
2076
2171
|
init_useBaseNativeToken();
|
|
2077
2172
|
init_useBaseTokens();
|
|
2078
2173
|
init_dialog();
|
|
2079
|
-
|
|
2174
|
+
import_jsx_runtime38 = require("react/jsx-runtime");
|
|
2080
2175
|
CryptoSelectModal = import_nice_modal_react5.default.create(() => {
|
|
2081
2176
|
const modal = (0, import_nice_modal_react5.useModal)();
|
|
2082
2177
|
const { isLoading, error, erc20Balances } = useBaseERC20Token();
|
|
2083
2178
|
const { isLoadingNative, nativeError, nativeBalance } = useBaseNativeToken();
|
|
2084
2179
|
const { tokens, tokensIsLoading } = useBaseTokens();
|
|
2085
|
-
const [search, setSearch] = (0,
|
|
2086
|
-
const filteredCoins = (0,
|
|
2180
|
+
const [search, setSearch] = (0, import_react17.useState)("");
|
|
2181
|
+
const filteredCoins = (0, import_react17.useMemo)(() => {
|
|
2087
2182
|
return tokens.filter(
|
|
2088
2183
|
(coin) => coin.name.toLowerCase().includes(search.toLowerCase()) || coin.symbol.toLowerCase().includes(search.toLowerCase())
|
|
2089
2184
|
);
|
|
@@ -2094,13 +2189,13 @@ var init_CryptoSelectModal = __esm({
|
|
|
2094
2189
|
setSelectedPaymentMethod({ type: "CRYPTO" /* CRYPTO */, method: coin });
|
|
2095
2190
|
};
|
|
2096
2191
|
const userCoins = [nativeBalance, ...erc20Balances].filter(Boolean);
|
|
2097
|
-
return /* @__PURE__ */ (0,
|
|
2098
|
-
/* @__PURE__ */ (0,
|
|
2099
|
-
/* @__PURE__ */ (0,
|
|
2100
|
-
/* @__PURE__ */ (0,
|
|
2101
|
-
/* @__PURE__ */ (0,
|
|
2102
|
-
/* @__PURE__ */ (0,
|
|
2103
|
-
/* @__PURE__ */ (0,
|
|
2192
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Dialog, { open: modal.visible, onOpenChange: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(DialogContent, { showCloseButton: false, className: "max-h-[90vh] gap-0 p-0", children: [
|
|
2193
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DialogDescription, { className: "sr-only", children: "Crypto Select Modal" }),
|
|
2194
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
|
|
2195
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center justify-between gap-4", children: [
|
|
2196
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("button", { className: "rounded-md hover:bg-(--s-primary-hover)", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-6", viewBox: "0 0 24 25", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("path", { stroke: "currentColor", d: "m15 6.5-6 6 6 6" }) }) }),
|
|
2197
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(DialogTitle, { className: "text-2xl font-medium text-(--brand-primary)", children: "Select a token" }),
|
|
2198
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("button", { className: "rounded-md p-1 hover:bg-(--s-primary-hover)", onClick: modal.remove, children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-4", viewBox: "0 0 16 17", children: /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2104
2199
|
"path",
|
|
2105
2200
|
{
|
|
2106
2201
|
fill: "currentColor",
|
|
@@ -2108,71 +2203,71 @@ var init_CryptoSelectModal = __esm({
|
|
|
2108
2203
|
}
|
|
2109
2204
|
) }) })
|
|
2110
2205
|
] }),
|
|
2111
|
-
/* @__PURE__ */ (0,
|
|
2206
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Input2, { onChange: (e) => setSearch(e.target.value), placeholder: "Search by token name", value: search })
|
|
2112
2207
|
] }),
|
|
2113
|
-
/* @__PURE__ */ (0,
|
|
2114
|
-
/* @__PURE__ */ (0,
|
|
2115
|
-
/* @__PURE__ */ (0,
|
|
2116
|
-
(error || nativeError) && /* @__PURE__ */ (0,
|
|
2117
|
-
/* @__PURE__ */ (0,
|
|
2118
|
-
isLoadingNative && /* @__PURE__ */ (0,
|
|
2119
|
-
nativeBalance && /* @__PURE__ */ (0,
|
|
2208
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)(Separator2, { className: "hidden md:block" }),
|
|
2209
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex flex-col gap-4 px-5 py-5 md:px-7", children: [
|
|
2210
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h3", { className: "text-md font-medium text-(--brand-primary)", children: "Tokens with wallet balance" }),
|
|
2211
|
+
(error || nativeError) && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-center text-sm text-(--negative)", children: "Something wrong" }),
|
|
2212
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex w-full flex-col gap-1", children: [
|
|
2213
|
+
isLoadingNative && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
|
|
2214
|
+
nativeBalance && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
2120
2215
|
"button",
|
|
2121
2216
|
{
|
|
2122
2217
|
className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-(--brand-primary) hover:bg-(--s-primary-hover)",
|
|
2123
2218
|
onClick: () => handleSelect(nativeBalance),
|
|
2124
2219
|
children: [
|
|
2125
|
-
/* @__PURE__ */ (0,
|
|
2126
|
-
nativeBalance.logoURI && /* @__PURE__ */ (0,
|
|
2127
|
-
/* @__PURE__ */ (0,
|
|
2220
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2221
|
+
nativeBalance.logoURI && /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("img", { className: "size-8 shrink-0", src: nativeBalance.logoURI, alt: `${nativeBalance.symbol} logo` }),
|
|
2222
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.symbol })
|
|
2128
2223
|
] }),
|
|
2129
|
-
/* @__PURE__ */ (0,
|
|
2224
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: nativeBalance.formatted })
|
|
2130
2225
|
]
|
|
2131
2226
|
},
|
|
2132
2227
|
nativeBalance.symbol
|
|
2133
2228
|
),
|
|
2134
|
-
isLoading && /* @__PURE__ */ (0,
|
|
2135
|
-
/* @__PURE__ */ (0,
|
|
2136
|
-
/* @__PURE__ */ (0,
|
|
2137
|
-
/* @__PURE__ */ (0,
|
|
2229
|
+
isLoading && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
|
|
2230
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
|
|
2231
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
|
|
2232
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" })
|
|
2138
2233
|
] }),
|
|
2139
2234
|
erc20Balances.map((coin) => {
|
|
2140
2235
|
const Icon = getSymbolLogo(coin.symbol);
|
|
2141
|
-
return /* @__PURE__ */ (0,
|
|
2236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(
|
|
2142
2237
|
"button",
|
|
2143
2238
|
{
|
|
2144
2239
|
className: "flex h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-(--brand-primary) hover:bg-(--s-primary-hover) disabled:cursor-not-allowed disabled:opacity-50",
|
|
2145
2240
|
onClick: () => handleSelect(coin),
|
|
2146
2241
|
children: [
|
|
2147
|
-
/* @__PURE__ */ (0,
|
|
2242
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2148
2243
|
Boolean(Icon) && Icon,
|
|
2149
|
-
/* @__PURE__ */ (0,
|
|
2244
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: coin.symbol })
|
|
2150
2245
|
] }),
|
|
2151
|
-
/* @__PURE__ */ (0,
|
|
2246
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: coin.formatted })
|
|
2152
2247
|
]
|
|
2153
2248
|
},
|
|
2154
2249
|
coin.symbol
|
|
2155
2250
|
);
|
|
2156
2251
|
})
|
|
2157
2252
|
] }),
|
|
2158
|
-
/* @__PURE__ */ (0,
|
|
2159
|
-
/* @__PURE__ */ (0,
|
|
2160
|
-
tokensIsLoading && /* @__PURE__ */ (0,
|
|
2161
|
-
/* @__PURE__ */ (0,
|
|
2162
|
-
/* @__PURE__ */ (0,
|
|
2163
|
-
/* @__PURE__ */ (0,
|
|
2253
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("h3", { className: "text-md font-medium text-(--brand-primary)", children: "All Tokens" }),
|
|
2254
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex max-h-[40vh] w-full flex-col gap-1 overflow-y-auto", children: [
|
|
2255
|
+
tokensIsLoading && /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)(import_jsx_runtime38.Fragment, { children: [
|
|
2256
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
|
|
2257
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" }),
|
|
2258
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "h-11 animate-pulse rounded-md bg-(--s-primary)" })
|
|
2164
2259
|
] }),
|
|
2165
2260
|
filteredCoins.map((token) => {
|
|
2166
2261
|
const userCoin = userCoins.find((c) => c.symbol === token.symbol);
|
|
2167
|
-
return /* @__PURE__ */ (0,
|
|
2262
|
+
return /* @__PURE__ */ (0, import_jsx_runtime38.jsx)(
|
|
2168
2263
|
"button",
|
|
2169
2264
|
{
|
|
2170
2265
|
disabled: !userCoin,
|
|
2171
2266
|
onClick: () => userCoin && handleSelect(userCoin),
|
|
2172
2267
|
className: "flex min-h-11 w-full items-center justify-between gap-4 rounded-sm px-1.5 text-(--brand-primary) hover:bg-(--s-primary-hover) disabled:cursor-not-allowed disabled:opacity-50",
|
|
2173
|
-
children: /* @__PURE__ */ (0,
|
|
2174
|
-
token.logoURI ? /* @__PURE__ */ (0,
|
|
2175
|
-
/* @__PURE__ */ (0,
|
|
2268
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime38.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
2269
|
+
token.logoURI ? /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("img", { className: "size-8 shrink-0", src: token.logoURI, alt: `${token.name} logo` }) : /* @__PURE__ */ (0, import_jsx_runtime38.jsx)("div", { className: "size-8 shrink-0 rounded-full bg-(--s-tertiary)" }),
|
|
2270
|
+
/* @__PURE__ */ (0, import_jsx_runtime38.jsx)("p", { className: "text-sm font-medium", children: token.symbol })
|
|
2176
2271
|
] })
|
|
2177
2272
|
},
|
|
2178
2273
|
token.symbol
|
|
@@ -2187,25 +2282,25 @@ var init_CryptoSelectModal = __esm({
|
|
|
2187
2282
|
});
|
|
2188
2283
|
|
|
2189
2284
|
// src/components/CryptoTab/Crypto/SelectCoinButton.tsx
|
|
2190
|
-
var import_nice_modal_react6,
|
|
2285
|
+
var import_nice_modal_react6, import_jsx_runtime39, SelectCoinButton;
|
|
2191
2286
|
var init_SelectCoinButton = __esm({
|
|
2192
2287
|
"src/components/CryptoTab/Crypto/SelectCoinButton.tsx"() {
|
|
2193
2288
|
"use strict";
|
|
2194
2289
|
import_nice_modal_react6 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
2195
2290
|
init_CryptoSelectModal();
|
|
2196
|
-
|
|
2291
|
+
import_jsx_runtime39 = require("react/jsx-runtime");
|
|
2197
2292
|
SelectCoinButton = () => {
|
|
2198
2293
|
const openModal = () => {
|
|
2199
2294
|
import_nice_modal_react6.default.show(CryptoSelectModal);
|
|
2200
2295
|
};
|
|
2201
|
-
return /* @__PURE__ */ (0,
|
|
2296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime39.jsx)(
|
|
2202
2297
|
"button",
|
|
2203
2298
|
{
|
|
2204
2299
|
onClick: openModal,
|
|
2205
2300
|
className: "flex h-11 w-full overflow-hidden rounded-md bg-(--s-primary) hover:bg-(--s-primary-hover)",
|
|
2206
|
-
children: /* @__PURE__ */ (0,
|
|
2207
|
-
/* @__PURE__ */ (0,
|
|
2208
|
-
/* @__PURE__ */ (0,
|
|
2301
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime39.jsxs)("div", { className: "flex h-full w-full items-center justify-between px-3", children: [
|
|
2302
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("div", { className: "flex items-center", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("p", { className: "font-medium text-(--secondary)", children: "Select a token" }) }),
|
|
2303
|
+
/* @__PURE__ */ (0, import_jsx_runtime39.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-4", viewBox: "0 0 16 16", children: /* @__PURE__ */ (0, import_jsx_runtime39.jsx)("path", { stroke: "currentColor", d: "m6 12.43 4-4-4-4" }) })
|
|
2209
2304
|
] })
|
|
2210
2305
|
}
|
|
2211
2306
|
);
|
|
@@ -2214,27 +2309,27 @@ var init_SelectCoinButton = __esm({
|
|
|
2214
2309
|
});
|
|
2215
2310
|
|
|
2216
2311
|
// src/components/CryptoTab/Crypto/SelectedCoin.tsx
|
|
2217
|
-
var
|
|
2312
|
+
var import_jsx_runtime40, SelectedCoin;
|
|
2218
2313
|
var init_SelectedCoin = __esm({
|
|
2219
2314
|
"src/components/CryptoTab/Crypto/SelectedCoin.tsx"() {
|
|
2220
2315
|
"use strict";
|
|
2221
2316
|
init_symbolLogos();
|
|
2222
|
-
|
|
2317
|
+
import_jsx_runtime40 = require("react/jsx-runtime");
|
|
2223
2318
|
SelectedCoin = (props) => {
|
|
2224
2319
|
const { coin, balance, logoURI } = props;
|
|
2225
2320
|
const Icon = getSymbolLogo(coin);
|
|
2226
|
-
return /* @__PURE__ */ (0,
|
|
2227
|
-
/* @__PURE__ */ (0,
|
|
2228
|
-
/* @__PURE__ */ (0,
|
|
2229
|
-
/* @__PURE__ */ (0,
|
|
2321
|
+
return /* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex h-12 w-full overflow-hidden rounded-md border-2 border-(--b-brand) bg-(--s-primary)", children: [
|
|
2322
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "flex h-full w-11 shrink-0 items-center justify-center border-r border-(--b-brand) bg-(--s-primary)", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) }) }),
|
|
2323
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex h-full w-full items-center justify-between rounded-r-md px-3", children: [
|
|
2324
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("div", { className: "flex items-center gap-1", children: [
|
|
2230
2325
|
Icon,
|
|
2231
|
-
!Icon && logoURI && /* @__PURE__ */ (0,
|
|
2232
|
-
/* @__PURE__ */ (0,
|
|
2233
|
-
/* @__PURE__ */ (0,
|
|
2326
|
+
!Icon && logoURI && /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("img", { className: "mr-1 size-8 shrink-0", src: logoURI, alt: `${coin} logo` }),
|
|
2327
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("p", { className: "font-semibold text-(--brand-primary)", children: coin }),
|
|
2328
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "size-4", fill: "none", viewBox: "0 0 16 16", children: /* @__PURE__ */ (0, import_jsx_runtime40.jsx)("path", { stroke: "currentColor", d: "m6 12.434 4-4-4-4" }) })
|
|
2234
2329
|
] }),
|
|
2235
|
-
/* @__PURE__ */ (0,
|
|
2330
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsxs)("p", { className: "text-xs font-medium text-(--secondary)", children: [
|
|
2236
2331
|
"Wallet balance ",
|
|
2237
|
-
/* @__PURE__ */ (0,
|
|
2332
|
+
/* @__PURE__ */ (0, import_jsx_runtime40.jsx)("span", { className: "text-(--brand-primary)", children: balance })
|
|
2238
2333
|
] })
|
|
2239
2334
|
] })
|
|
2240
2335
|
] });
|
|
@@ -2243,11 +2338,11 @@ var init_SelectedCoin = __esm({
|
|
|
2243
2338
|
});
|
|
2244
2339
|
|
|
2245
2340
|
// src/components/CryptoTab/Crypto/Crypto.tsx
|
|
2246
|
-
var
|
|
2341
|
+
var import_react18, import_wagmi4, import_jsx_runtime41, Crypto;
|
|
2247
2342
|
var init_Crypto = __esm({
|
|
2248
2343
|
"src/components/CryptoTab/Crypto/Crypto.tsx"() {
|
|
2249
2344
|
"use strict";
|
|
2250
|
-
|
|
2345
|
+
import_react18 = require("react");
|
|
2251
2346
|
import_wagmi4 = require("wagmi");
|
|
2252
2347
|
init_SpreePayActionsContext();
|
|
2253
2348
|
init_useCryptoPayment();
|
|
@@ -2258,7 +2353,7 @@ var init_Crypto = __esm({
|
|
|
2258
2353
|
init_Logos();
|
|
2259
2354
|
init_SelectCoinButton();
|
|
2260
2355
|
init_SelectedCoin();
|
|
2261
|
-
|
|
2356
|
+
import_jsx_runtime41 = require("react/jsx-runtime");
|
|
2262
2357
|
Crypto = () => {
|
|
2263
2358
|
const { address } = (0, import_wagmi4.useAccount)();
|
|
2264
2359
|
const { selectedPaymentMethod } = useSpreePaymentMethod();
|
|
@@ -2266,31 +2361,28 @@ var init_Crypto = __esm({
|
|
|
2266
2361
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2267
2362
|
const isWalletConnected = Boolean(address);
|
|
2268
2363
|
const { register } = useSpreePayRegister();
|
|
2269
|
-
const handlePay = (0,
|
|
2364
|
+
const handlePay = (0, import_react18.useCallback)(
|
|
2270
2365
|
async (data) => {
|
|
2271
2366
|
try {
|
|
2272
2367
|
const res = await cryptoPayment(data);
|
|
2273
|
-
|
|
2274
|
-
|
|
2275
|
-
|
|
2276
|
-
return Promise.reject(new PaymentError("Crypto payment failed", res.status));
|
|
2277
|
-
} catch (_) {
|
|
2278
|
-
return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
|
|
2368
|
+
return settlePaymentResult(res, "Crypto payment failed");
|
|
2369
|
+
} catch (e) {
|
|
2370
|
+
return Promise.reject(toPaymentError(e, "Crypto payment failed"));
|
|
2279
2371
|
}
|
|
2280
2372
|
},
|
|
2281
2373
|
[cryptoPayment]
|
|
2282
2374
|
);
|
|
2283
|
-
(0,
|
|
2375
|
+
(0, import_react18.useEffect)(() => {
|
|
2284
2376
|
register(handlePay);
|
|
2285
2377
|
}, [register, handlePay]);
|
|
2286
|
-
return /* @__PURE__ */ (0,
|
|
2287
|
-
/* @__PURE__ */ (0,
|
|
2288
|
-
/* @__PURE__ */ (0,
|
|
2289
|
-
/* @__PURE__ */ (0,
|
|
2378
|
+
return /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
2379
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex w-full items-center justify-between gap-4", children: [
|
|
2380
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)("h3", { className: "text-lg leading-7 font-medium text-(--brand-primary) md:text-[22px]", children: "Pay with Crypto" }),
|
|
2381
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(ConnectButton, {})
|
|
2290
2382
|
] }),
|
|
2291
|
-
!isWalletConnected && /* @__PURE__ */ (0,
|
|
2292
|
-
isWalletConnected && /* @__PURE__ */ (0,
|
|
2293
|
-
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ (0,
|
|
2383
|
+
!isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(Logos, {}),
|
|
2384
|
+
isWalletConnected && /* @__PURE__ */ (0, import_jsx_runtime41.jsxs)("div", { className: "flex w-full flex-col gap-4", children: [
|
|
2385
|
+
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && selectedPaymentMethod.method && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(
|
|
2294
2386
|
SelectedCoin,
|
|
2295
2387
|
{
|
|
2296
2388
|
coin: selectedPaymentMethod.method.symbol,
|
|
@@ -2298,9 +2390,9 @@ var init_Crypto = __esm({
|
|
|
2298
2390
|
logoURI: selectedPaymentMethod.method.logoURI
|
|
2299
2391
|
}
|
|
2300
2392
|
),
|
|
2301
|
-
/* @__PURE__ */ (0,
|
|
2393
|
+
/* @__PURE__ */ (0, import_jsx_runtime41.jsx)(SelectCoinButton, {})
|
|
2302
2394
|
] }),
|
|
2303
|
-
spreePayConfig?.crypto.infoMessage && /* @__PURE__ */ (0,
|
|
2395
|
+
spreePayConfig?.crypto.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime41.jsx)(InfoBanner, { message: spreePayConfig.crypto.infoMessage })
|
|
2304
2396
|
] });
|
|
2305
2397
|
};
|
|
2306
2398
|
}
|
|
@@ -2316,31 +2408,33 @@ function getCachedWagmiConfig(projectId, appName) {
|
|
|
2316
2408
|
}
|
|
2317
2409
|
return cfg2;
|
|
2318
2410
|
}
|
|
2319
|
-
var
|
|
2411
|
+
var import_react19, import_react_query, import_nice_modal_react7, import_rainbowkit2, import_styles, import_wagmi5, import_chains, import_jsx_runtime42, queryClient, CHAINS, wagmiConfigCache, CryptoWrapper;
|
|
2320
2412
|
var init_CryptoWrapper = __esm({
|
|
2321
2413
|
"src/components/CryptoTab/Crypto/CryptoWrapper.tsx"() {
|
|
2322
2414
|
"use strict";
|
|
2323
|
-
|
|
2415
|
+
import_react19 = require("react");
|
|
2324
2416
|
import_react_query = require("@tanstack/react-query");
|
|
2325
2417
|
import_nice_modal_react7 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
2326
2418
|
import_rainbowkit2 = require("@rainbow-me/rainbowkit");
|
|
2327
2419
|
import_styles = require("@rainbow-me/rainbowkit/styles.css");
|
|
2328
2420
|
import_wagmi5 = require("wagmi");
|
|
2329
2421
|
import_chains = require("wagmi/chains");
|
|
2422
|
+
init_LoginStatusContext();
|
|
2330
2423
|
init_useSpreePayConfig();
|
|
2331
2424
|
init_Crypto();
|
|
2332
|
-
|
|
2425
|
+
import_jsx_runtime42 = require("react/jsx-runtime");
|
|
2333
2426
|
queryClient = new import_react_query.QueryClient();
|
|
2334
2427
|
CHAINS = [import_chains.base];
|
|
2335
2428
|
wagmiConfigCache = /* @__PURE__ */ new Map();
|
|
2336
2429
|
CryptoWrapper = () => {
|
|
2430
|
+
const isLoggedIn = useIsLoggedIn();
|
|
2337
2431
|
const { spreePayConfig, configIsLoading } = useSpreePayConfig();
|
|
2338
|
-
const wagmiConfig = (0,
|
|
2432
|
+
const wagmiConfig = (0, import_react19.useMemo)(() => {
|
|
2339
2433
|
if (!spreePayConfig) return null;
|
|
2340
2434
|
return getCachedWagmiConfig(spreePayConfig.rainbowProjectId, spreePayConfig.rainbowAppName);
|
|
2341
2435
|
}, [spreePayConfig]);
|
|
2342
|
-
if (configIsLoading || !wagmiConfig) return null;
|
|
2343
|
-
return /* @__PURE__ */ (0,
|
|
2436
|
+
if (!isLoggedIn || configIsLoading || !wagmiConfig) return null;
|
|
2437
|
+
return /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_wagmi5.WagmiProvider, { config: wagmiConfig, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_react_query.QueryClientProvider, { client: queryClient, children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_rainbowkit2.RainbowKitProvider, { theme: (0, import_rainbowkit2.lightTheme)({ borderRadius: "large" }), children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(import_nice_modal_react7.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime42.jsx)(Crypto, {}) }) }) }) });
|
|
2344
2438
|
};
|
|
2345
2439
|
}
|
|
2346
2440
|
});
|
|
@@ -2354,7 +2448,7 @@ var init_Crypto2 = __esm({
|
|
|
2354
2448
|
});
|
|
2355
2449
|
|
|
2356
2450
|
// src/components/CryptoTab/CryptoTab.tsx
|
|
2357
|
-
var
|
|
2451
|
+
var import_jsx_runtime43, CryptoTab;
|
|
2358
2452
|
var init_CryptoTab = __esm({
|
|
2359
2453
|
"src/components/CryptoTab/CryptoTab.tsx"() {
|
|
2360
2454
|
"use strict";
|
|
@@ -2362,13 +2456,13 @@ var init_CryptoTab = __esm({
|
|
|
2362
2456
|
init_CheckoutButton();
|
|
2363
2457
|
init_common();
|
|
2364
2458
|
init_Crypto2();
|
|
2365
|
-
|
|
2366
|
-
CryptoTab = (
|
|
2459
|
+
import_jsx_runtime43 = require("react/jsx-runtime");
|
|
2460
|
+
CryptoTab = () => {
|
|
2367
2461
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2368
|
-
return /* @__PURE__ */ (0,
|
|
2369
|
-
/* @__PURE__ */ (0,
|
|
2370
|
-
!spreePayConfig?.crypto.hidePoints && /* @__PURE__ */ (0,
|
|
2371
|
-
/* @__PURE__ */ (0,
|
|
2462
|
+
return /* @__PURE__ */ (0, import_jsx_runtime43.jsxs)("div", { children: [
|
|
2463
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "border-b border-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CryptoWrapper, {}) }),
|
|
2464
|
+
!spreePayConfig?.crypto.hidePoints && /* @__PURE__ */ (0, import_jsx_runtime43.jsx)("div", { className: "border-b border-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: /* @__PURE__ */ (0, import_jsx_runtime43.jsx)(PointsSwitch, { disabled: true, message: spreePayConfig?.crypto.pointsInfoMessage }) }),
|
|
2465
|
+
/* @__PURE__ */ (0, import_jsx_runtime43.jsx)(CheckoutButton, {})
|
|
2372
2466
|
] });
|
|
2373
2467
|
};
|
|
2374
2468
|
}
|
|
@@ -2404,11 +2498,10 @@ var init_useCryptoComPayment = __esm({
|
|
|
2404
2498
|
if (selectedPaymentMethod.type !== "CDC" /* CDC */) {
|
|
2405
2499
|
throw new Error("Unsupported payment method");
|
|
2406
2500
|
}
|
|
2407
|
-
const { hash
|
|
2501
|
+
const { hash } = params;
|
|
2408
2502
|
cryptoComLogger.info("Starting Crypto.com Pay payment", { hash });
|
|
2409
2503
|
const { data: paymentResData } = await SlapiPaymentService.createPayment({
|
|
2410
2504
|
hash,
|
|
2411
|
-
metadata,
|
|
2412
2505
|
type: "CDC" /* CDC */,
|
|
2413
2506
|
cdc: {
|
|
2414
2507
|
returnUrl: `${typeof window !== "undefined" ? window.location.origin : ""}${redirect3dsURI}?payment_intent=success`,
|
|
@@ -2454,24 +2547,26 @@ var init_useCryptoComPayment = __esm({
|
|
|
2454
2547
|
});
|
|
2455
2548
|
|
|
2456
2549
|
// src/components/CryptoComTab/Checkout.tsx
|
|
2457
|
-
var
|
|
2550
|
+
var import_jsx_runtime44, Checkout;
|
|
2458
2551
|
var init_Checkout = __esm({
|
|
2459
2552
|
"src/components/CryptoComTab/Checkout.tsx"() {
|
|
2460
2553
|
"use strict";
|
|
2554
|
+
init_LoginStatusContext();
|
|
2461
2555
|
init_SpreePayActionsContext();
|
|
2462
2556
|
init_StaticConfigContext();
|
|
2463
|
-
|
|
2557
|
+
import_jsx_runtime44 = require("react/jsx-runtime");
|
|
2464
2558
|
Checkout = () => {
|
|
2559
|
+
const isLoggedIn = useIsLoggedIn();
|
|
2465
2560
|
const { appProps } = useStaticConfig();
|
|
2466
2561
|
const { isInternalProcessing } = useSpreePaymentMethod();
|
|
2467
|
-
return /* @__PURE__ */ (0,
|
|
2562
|
+
return /* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
2468
2563
|
"button",
|
|
2469
2564
|
{
|
|
2470
2565
|
onClick: appProps.onProcess,
|
|
2471
|
-
disabled: !!appProps.isProcessing || isInternalProcessing,
|
|
2566
|
+
disabled: !isLoggedIn || !!appProps.isProcessing || isInternalProcessing,
|
|
2472
2567
|
className: "flex flex-col items-center rounded-md bg-(--crypto-pay-bg) p-2 text-(--brand-primary) hover:bg-(--crypto-pay-bg-hover) disabled:cursor-not-allowed disabled:bg-(--crypto-pay-bg-hover) disabled:text-(--disabled)",
|
|
2473
|
-
children: /* @__PURE__ */ (0,
|
|
2474
|
-
/* @__PURE__ */ (0,
|
|
2568
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime44.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", className: "h-7 w-[76px]", fill: "none", viewBox: "0 0 76 28", children: [
|
|
2569
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
2475
2570
|
"path",
|
|
2476
2571
|
{
|
|
2477
2572
|
fill: "currentColor",
|
|
@@ -2480,7 +2575,7 @@ var init_Checkout = __esm({
|
|
|
2480
2575
|
clipRule: "evenodd"
|
|
2481
2576
|
}
|
|
2482
2577
|
),
|
|
2483
|
-
/* @__PURE__ */ (0,
|
|
2578
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
2484
2579
|
"path",
|
|
2485
2580
|
{
|
|
2486
2581
|
fill: "currentColor",
|
|
@@ -2489,7 +2584,7 @@ var init_Checkout = __esm({
|
|
|
2489
2584
|
clipRule: "evenodd"
|
|
2490
2585
|
}
|
|
2491
2586
|
),
|
|
2492
|
-
/* @__PURE__ */ (0,
|
|
2587
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
2493
2588
|
"path",
|
|
2494
2589
|
{
|
|
2495
2590
|
fill: "currentColor",
|
|
@@ -2498,7 +2593,7 @@ var init_Checkout = __esm({
|
|
|
2498
2593
|
clipRule: "evenodd"
|
|
2499
2594
|
}
|
|
2500
2595
|
),
|
|
2501
|
-
/* @__PURE__ */ (0,
|
|
2596
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
2502
2597
|
"path",
|
|
2503
2598
|
{
|
|
2504
2599
|
fill: "currentColor",
|
|
@@ -2507,7 +2602,7 @@ var init_Checkout = __esm({
|
|
|
2507
2602
|
clipRule: "evenodd"
|
|
2508
2603
|
}
|
|
2509
2604
|
),
|
|
2510
|
-
/* @__PURE__ */ (0,
|
|
2605
|
+
/* @__PURE__ */ (0, import_jsx_runtime44.jsx)(
|
|
2511
2606
|
"path",
|
|
2512
2607
|
{
|
|
2513
2608
|
fill: "currentColor",
|
|
@@ -2524,43 +2619,40 @@ var init_Checkout = __esm({
|
|
|
2524
2619
|
});
|
|
2525
2620
|
|
|
2526
2621
|
// src/components/CryptoComTab/CryptoComTab.tsx
|
|
2527
|
-
var
|
|
2622
|
+
var import_react20, import_jsx_runtime45, CryptoComTab;
|
|
2528
2623
|
var init_CryptoComTab = __esm({
|
|
2529
2624
|
"src/components/CryptoComTab/CryptoComTab.tsx"() {
|
|
2530
2625
|
"use strict";
|
|
2531
|
-
|
|
2626
|
+
import_react20 = require("react");
|
|
2532
2627
|
init_SpreePayActionsContext();
|
|
2533
2628
|
init_useCryptoComPayment();
|
|
2534
2629
|
init_useSpreePayConfig();
|
|
2535
2630
|
init_errors();
|
|
2536
2631
|
init_common();
|
|
2537
2632
|
init_Checkout();
|
|
2538
|
-
|
|
2633
|
+
import_jsx_runtime45 = require("react/jsx-runtime");
|
|
2539
2634
|
CryptoComTab = () => {
|
|
2540
2635
|
const { register } = useSpreePayRegister();
|
|
2541
2636
|
const { cryptoComPayment } = useCryptoComPayment();
|
|
2542
2637
|
const { spreePayConfig } = useSpreePayConfig();
|
|
2543
|
-
const handlePay = (0,
|
|
2638
|
+
const handlePay = (0, import_react20.useCallback)(
|
|
2544
2639
|
async (data) => {
|
|
2545
2640
|
try {
|
|
2546
2641
|
const res = await cryptoComPayment(data);
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
return Promise.reject(new PaymentError("Crypto payment failed", res.status));
|
|
2551
|
-
} catch (_) {
|
|
2552
|
-
return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
|
|
2642
|
+
return settlePaymentResult(res, "Crypto payment failed");
|
|
2643
|
+
} catch (e) {
|
|
2644
|
+
return Promise.reject(toPaymentError(e, "Crypto payment failed"));
|
|
2553
2645
|
}
|
|
2554
2646
|
},
|
|
2555
2647
|
[cryptoComPayment]
|
|
2556
2648
|
);
|
|
2557
|
-
(0,
|
|
2649
|
+
(0, import_react20.useEffect)(() => {
|
|
2558
2650
|
register(handlePay);
|
|
2559
2651
|
}, [register, handlePay]);
|
|
2560
|
-
return /* @__PURE__ */ (0,
|
|
2561
|
-
spreePayConfig?.cryptoCom.infoMessage && /* @__PURE__ */ (0,
|
|
2562
|
-
/* @__PURE__ */ (0,
|
|
2563
|
-
/* @__PURE__ */ (0,
|
|
2652
|
+
return /* @__PURE__ */ (0, import_jsx_runtime45.jsxs)("div", { className: "flex w-full flex-col gap-4 border-b border-b-(--border-component-specific-card) px-5 py-5 md:px-7 md:py-6", children: [
|
|
2653
|
+
spreePayConfig?.cryptoCom.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime45.jsx)(InfoBanner, { message: spreePayConfig.cryptoCom.infoMessage }),
|
|
2654
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Legal, {}),
|
|
2655
|
+
/* @__PURE__ */ (0, import_jsx_runtime45.jsx)(Checkout, {})
|
|
2564
2656
|
] });
|
|
2565
2657
|
};
|
|
2566
2658
|
}
|
|
@@ -2582,10 +2674,15 @@ var init_CryptoComTab2 = __esm({
|
|
|
2582
2674
|
var index_exports = {};
|
|
2583
2675
|
__export(index_exports, {
|
|
2584
2676
|
LogLevel: () => LogLevel,
|
|
2677
|
+
PaymentError: () => PaymentError,
|
|
2678
|
+
PaymentErrorCode: () => PaymentErrorCode,
|
|
2679
|
+
PaymentStatus: () => PaymentStatus,
|
|
2585
2680
|
PaymentType: () => PaymentType,
|
|
2586
2681
|
SpreePay: () => SpreePay,
|
|
2682
|
+
SpreePayHttpError: () => SpreePayHttpError,
|
|
2587
2683
|
SpreePayProvider: () => SpreePayProvider,
|
|
2588
2684
|
configureLogger: () => configureLogger,
|
|
2685
|
+
isPaymentError: () => isPaymentError,
|
|
2589
2686
|
logger: () => logger,
|
|
2590
2687
|
useCapture3DS: () => useCapture3DS,
|
|
2591
2688
|
useSpreePay: () => useSpreePay
|
|
@@ -2593,15 +2690,15 @@ __export(index_exports, {
|
|
|
2593
2690
|
module.exports = __toCommonJS(index_exports);
|
|
2594
2691
|
|
|
2595
2692
|
// src/SpreePay.tsx
|
|
2596
|
-
var
|
|
2693
|
+
var import_react24 = require("react");
|
|
2597
2694
|
var import_nice_modal_react9 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
2598
2695
|
var import_swr5 = require("swr");
|
|
2599
2696
|
|
|
2600
2697
|
// src/SpreePayContent.tsx
|
|
2601
|
-
var
|
|
2698
|
+
var import_react21 = require("react");
|
|
2602
2699
|
|
|
2603
2700
|
// src/components/CreditCardTab/CreditCardTab.tsx
|
|
2604
|
-
var
|
|
2701
|
+
var import_react16 = require("react");
|
|
2605
2702
|
init_SpreePayActionsContext();
|
|
2606
2703
|
init_StaticConfigContext();
|
|
2607
2704
|
|
|
@@ -2627,12 +2724,8 @@ var useCardPayment = () => {
|
|
|
2627
2724
|
});
|
|
2628
2725
|
throw error;
|
|
2629
2726
|
}
|
|
2630
|
-
const { hash, capture
|
|
2631
|
-
cardPaymentLogger.info("Starting card payment", {
|
|
2632
|
-
hash,
|
|
2633
|
-
capture,
|
|
2634
|
-
hasMetadata: Boolean(metadata)
|
|
2635
|
-
});
|
|
2727
|
+
const { hash, capture } = params;
|
|
2728
|
+
cardPaymentLogger.info("Starting card payment", { hash, capture });
|
|
2636
2729
|
const card = selectedPaymentMethod.method;
|
|
2637
2730
|
let cardId;
|
|
2638
2731
|
if ("token" in card) {
|
|
@@ -2663,7 +2756,6 @@ var useCardPayment = () => {
|
|
|
2663
2756
|
const { data: paymentResData } = await SlapiPaymentService.createPayment({
|
|
2664
2757
|
hash,
|
|
2665
2758
|
capture,
|
|
2666
|
-
metadata,
|
|
2667
2759
|
type: "CREDIT_CARD" /* CREDIT_CARD */,
|
|
2668
2760
|
card: {
|
|
2669
2761
|
cardId,
|
|
@@ -2831,16 +2923,20 @@ init_useSpreePayConfig();
|
|
|
2831
2923
|
var import_nice_modal_react3 = __toESM(require("@ebay/nice-modal-react"), 1);
|
|
2832
2924
|
init_Iframe3ds();
|
|
2833
2925
|
init_slapi();
|
|
2926
|
+
init_errors();
|
|
2834
2927
|
var REFRESH_INTERVAL = 3 * 1e3;
|
|
2835
2928
|
var MAX_RETRIES = 10;
|
|
2836
2929
|
async function longPollPoints(paymentId) {
|
|
2837
2930
|
let retries = 0;
|
|
2838
2931
|
while (retries < MAX_RETRIES) {
|
|
2839
2932
|
const { detail } = await SlapiPaymentService.getStatus(paymentId);
|
|
2840
|
-
if (detail.status
|
|
2841
|
-
throw new
|
|
2933
|
+
if (isDeclineStatus(detail.status)) {
|
|
2934
|
+
throw new PaymentError("Something went wrong with the points payment.", detail.status, {
|
|
2935
|
+
code: "PAYMENT_ERROR" /* PAYMENT_ERROR */,
|
|
2936
|
+
backendCode: detail.errorCode ?? void 0
|
|
2937
|
+
});
|
|
2842
2938
|
}
|
|
2843
|
-
if (
|
|
2939
|
+
if (isSuccessStatus(detail.status)) {
|
|
2844
2940
|
return detail.status;
|
|
2845
2941
|
}
|
|
2846
2942
|
await new Promise((res) => setTimeout(res, REFRESH_INTERVAL));
|
|
@@ -2853,13 +2949,21 @@ async function longPollCardStatus(paymentId) {
|
|
|
2853
2949
|
let shown3ds = false;
|
|
2854
2950
|
while (retries < MAX_RETRIES) {
|
|
2855
2951
|
const { detail } = await SlapiPaymentService.getStatus(paymentId);
|
|
2856
|
-
if (detail.status
|
|
2857
|
-
|
|
2952
|
+
if (isDeclineStatus(detail.status)) {
|
|
2953
|
+
const isPointsLeg = detail.validationType === "POINTS";
|
|
2954
|
+
throw new PaymentError(
|
|
2955
|
+
isPointsLeg ? "Something went wrong with the points payment." : "Your card payment could not be completed.",
|
|
2956
|
+
detail.status,
|
|
2957
|
+
{
|
|
2958
|
+
code: isPointsLeg ? "PAYMENT_ERROR" /* PAYMENT_ERROR */ : "CARD_ERROR" /* CARD_ERROR */,
|
|
2959
|
+
backendCode: detail.errorCode ?? void 0
|
|
2960
|
+
}
|
|
2961
|
+
);
|
|
2858
2962
|
}
|
|
2859
2963
|
if (
|
|
2860
2964
|
// Process to points payment
|
|
2861
2965
|
detail.validationType === "POINTS" || // early card payment completion
|
|
2862
|
-
|
|
2966
|
+
isSuccessStatus(detail.status)
|
|
2863
2967
|
) {
|
|
2864
2968
|
return detail.status;
|
|
2865
2969
|
}
|
|
@@ -2889,7 +2993,7 @@ var usePointsPayment = (mode = "web2") => {
|
|
|
2889
2993
|
});
|
|
2890
2994
|
throw error;
|
|
2891
2995
|
}
|
|
2892
|
-
const { hash, capture
|
|
2996
|
+
const { hash, capture } = params;
|
|
2893
2997
|
pointsPaymentLogger.info("Starting points payment", {
|
|
2894
2998
|
hash,
|
|
2895
2999
|
capture,
|
|
@@ -2904,7 +3008,6 @@ var usePointsPayment = (mode = "web2") => {
|
|
|
2904
3008
|
hash,
|
|
2905
3009
|
// capture should be always true for web2 points payments
|
|
2906
3010
|
capture: mode === "web2" ? true : capture,
|
|
2907
|
-
metadata,
|
|
2908
3011
|
type: "POINTS" /* POINTS */
|
|
2909
3012
|
});
|
|
2910
3013
|
pointsPaymentLogger.info("Points payment created", {
|
|
@@ -3005,7 +3108,7 @@ var useSplitCardPayments = (mode = "web2") => {
|
|
|
3005
3108
|
if (selectedPaymentMethod.type !== "CREDIT_CARD" /* CREDIT_CARD */ || !selectedPaymentMethod.method || !params.points) {
|
|
3006
3109
|
throw new Error("Unsupported payment method");
|
|
3007
3110
|
}
|
|
3008
|
-
const { hash, capture,
|
|
3111
|
+
const { hash, capture, points } = params;
|
|
3009
3112
|
splitPaymentLogger.info("Starting split card+points payment", { hash, mode, points, capture });
|
|
3010
3113
|
const card = selectedPaymentMethod.method;
|
|
3011
3114
|
let cardId;
|
|
@@ -3033,7 +3136,6 @@ var useSplitCardPayments = (mode = "web2") => {
|
|
|
3033
3136
|
const { data: paymentResData } = await SlapiPaymentService.createPayment({
|
|
3034
3137
|
hash,
|
|
3035
3138
|
capture,
|
|
3036
|
-
metadata,
|
|
3037
3139
|
type: "SPLIT" /* CREDIT_CARD_SPLIT */,
|
|
3038
3140
|
card: {
|
|
3039
3141
|
cardId,
|
|
@@ -3150,21 +3252,22 @@ init_split();
|
|
|
3150
3252
|
init_CheckoutButton();
|
|
3151
3253
|
|
|
3152
3254
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
3153
|
-
var
|
|
3255
|
+
var import_react10 = require("react");
|
|
3154
3256
|
var import_react_stripe_js2 = require("@stripe/react-stripe-js");
|
|
3155
3257
|
var import_stripe_js = require("@stripe/stripe-js");
|
|
3258
|
+
init_LoginStatusContext();
|
|
3156
3259
|
init_SpreePayActionsContext();
|
|
3157
3260
|
init_useSpreePayConfig();
|
|
3158
3261
|
init_InfoBanner();
|
|
3159
3262
|
|
|
3160
3263
|
// src/components/CreditCardTab/CreditCard/CardsList.tsx
|
|
3161
|
-
var
|
|
3264
|
+
var import_react8 = require("react");
|
|
3162
3265
|
init_utils();
|
|
3163
3266
|
init_slapi();
|
|
3164
3267
|
init_payments();
|
|
3165
|
-
var
|
|
3268
|
+
var import_jsx_runtime13 = require("react/jsx-runtime");
|
|
3166
3269
|
var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
|
|
3167
|
-
const [isRemoving, setIsRemoving] = (0,
|
|
3270
|
+
const [isRemoving, setIsRemoving] = (0, import_react8.useState)(false);
|
|
3168
3271
|
const removeDisabled = isSelected || isRemoving;
|
|
3169
3272
|
const handleRemove = async (e) => {
|
|
3170
3273
|
e.stopPropagation();
|
|
@@ -3175,7 +3278,7 @@ var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
|
|
|
3175
3278
|
setIsRemoving(false);
|
|
3176
3279
|
}
|
|
3177
3280
|
};
|
|
3178
|
-
return /* @__PURE__ */ (0,
|
|
3281
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
3179
3282
|
"div",
|
|
3180
3283
|
{
|
|
3181
3284
|
role: "button",
|
|
@@ -3187,36 +3290,36 @@ var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
|
|
|
3187
3290
|
{ "border-(--b-brand)": isSelected }
|
|
3188
3291
|
),
|
|
3189
3292
|
children: [
|
|
3190
|
-
/* @__PURE__ */ (0,
|
|
3293
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3191
3294
|
"div",
|
|
3192
3295
|
{
|
|
3193
3296
|
className: cn("flex h-full w-11 shrink-0 items-center justify-center border-r border-(--b-inverse)", {
|
|
3194
3297
|
"border-(--b-brand)": isSelected
|
|
3195
3298
|
}),
|
|
3196
|
-
children: /* @__PURE__ */ (0,
|
|
3299
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: isSelected && /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) })
|
|
3197
3300
|
}
|
|
3198
3301
|
),
|
|
3199
|
-
/* @__PURE__ */ (0,
|
|
3302
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)(
|
|
3200
3303
|
"div",
|
|
3201
3304
|
{
|
|
3202
3305
|
className: cn("flex h-full w-full items-center justify-between rounded-r-sm pr-2 pl-3", {
|
|
3203
3306
|
"border-(--primary)": isSelected
|
|
3204
3307
|
}),
|
|
3205
3308
|
children: [
|
|
3206
|
-
/* @__PURE__ */ (0,
|
|
3207
|
-
/* @__PURE__ */ (0,
|
|
3208
|
-
/* @__PURE__ */ (0,
|
|
3309
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("p", { className: "text-sm font-medium text-(--brand-primary)", children: card.schema }) }),
|
|
3310
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3311
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsxs)("p", { className: "text-sm font-medium text-(--secondary)", children: [
|
|
3209
3312
|
"Ending in ",
|
|
3210
|
-
/* @__PURE__ */ (0,
|
|
3313
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)("span", { className: "text-(--brand-primary)", children: card.lastFourNumbers })
|
|
3211
3314
|
] }),
|
|
3212
|
-
/* @__PURE__ */ (0,
|
|
3315
|
+
/* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3213
3316
|
"button",
|
|
3214
3317
|
{
|
|
3215
3318
|
type: "button",
|
|
3216
3319
|
onClick: handleRemove,
|
|
3217
3320
|
disabled: removeDisabled,
|
|
3218
3321
|
className: "text-tertiary rounded-md p-1 transition-all hover:bg-(--s-secondary) disabled:cursor-not-allowed disabled:opacity-50",
|
|
3219
|
-
children: /* @__PURE__ */ (0,
|
|
3322
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "currentColor", className: "size-5", viewBox: "0 0 20 20", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("path", { d: "M6.35 16.17q-.57 0-.96-.4a1.3 1.3 0 0 1-.39-.95V4.5h-.83v-.83H7.5v-.64h5v.64h3.33v.83H15v10.32q0 .58-.39.96a1.3 1.3 0 0 1-.96.39zM14.17 4.5H5.83v10.32q0 .23.15.37.15.15.37.15h7.3q.2 0 .36-.16.15-.17.16-.36zm-6 9.17h.84v-7.5h-.84zm2.82 0h.84v-7.5h-.84z" }) })
|
|
3220
3323
|
}
|
|
3221
3324
|
)
|
|
3222
3325
|
] })
|
|
@@ -3229,7 +3332,7 @@ var CardListItem = ({ card, isSelected, onSelect, onRemove }) => {
|
|
|
3229
3332
|
};
|
|
3230
3333
|
var CardsList = ({ selectedCard, setCard, newCards, onRemoveNewCard }) => {
|
|
3231
3334
|
const { cards, cardsIsLoading, mutateCards } = useCards();
|
|
3232
|
-
const allCards = (0,
|
|
3335
|
+
const allCards = (0, import_react8.useMemo)(() => [...cards, ...newCards], [cards, newCards]);
|
|
3233
3336
|
const handleRemove = async (card) => {
|
|
3234
3337
|
if (isNewCard(card)) {
|
|
3235
3338
|
onRemoveNewCard(card);
|
|
@@ -3239,10 +3342,10 @@ var CardsList = ({ selectedCard, setCard, newCards, onRemoveNewCard }) => {
|
|
|
3239
3342
|
}
|
|
3240
3343
|
};
|
|
3241
3344
|
if (cardsIsLoading) {
|
|
3242
|
-
return /* @__PURE__ */ (0,
|
|
3345
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex w-full flex-col", children: /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "h-11 animate-pulse rounded-sm bg-(--s-primary)" }) });
|
|
3243
3346
|
}
|
|
3244
3347
|
if (allCards.length === 0) return null;
|
|
3245
|
-
return /* @__PURE__ */ (0,
|
|
3348
|
+
return /* @__PURE__ */ (0, import_jsx_runtime13.jsx)("div", { className: "flex w-full flex-col gap-4", children: allCards.map((card) => /* @__PURE__ */ (0, import_jsx_runtime13.jsx)(
|
|
3246
3349
|
CardListItem,
|
|
3247
3350
|
{
|
|
3248
3351
|
isSelected: selectedCard?.id === card.id,
|
|
@@ -3255,14 +3358,14 @@ var CardsList = ({ selectedCard, setCard, newCards, onRemoveNewCard }) => {
|
|
|
3255
3358
|
};
|
|
3256
3359
|
|
|
3257
3360
|
// src/components/CreditCardTab/CreditCard/CreditCardForm.tsx
|
|
3258
|
-
var
|
|
3361
|
+
var import_react9 = require("react");
|
|
3259
3362
|
var import_react_stripe_js = require("@stripe/react-stripe-js");
|
|
3260
3363
|
|
|
3261
3364
|
// src/ui/button.tsx
|
|
3262
3365
|
var import_react_slot = require("@radix-ui/react-slot");
|
|
3263
3366
|
var import_class_variance_authority = require("class-variance-authority");
|
|
3264
3367
|
init_utils();
|
|
3265
|
-
var
|
|
3368
|
+
var import_jsx_runtime14 = require("react/jsx-runtime");
|
|
3266
3369
|
var buttonVariants = (0, import_class_variance_authority.cva)(
|
|
3267
3370
|
"inline-flex items-center justify-center gap-2 whitespace-nowrap rounded-full text-sm transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive",
|
|
3268
3371
|
{
|
|
@@ -3297,16 +3400,16 @@ function Button({
|
|
|
3297
3400
|
...props
|
|
3298
3401
|
}) {
|
|
3299
3402
|
const Comp = asChild ? import_react_slot.Slot : "button";
|
|
3300
|
-
return /* @__PURE__ */ (0,
|
|
3403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime14.jsx)(Comp, { "data-slot": "button", className: cn(buttonVariants({ variant, size, className })), ...props });
|
|
3301
3404
|
}
|
|
3302
3405
|
|
|
3303
3406
|
// src/ui/checkbox.tsx
|
|
3304
3407
|
var CheckboxPrimitive = __toESM(require("@radix-ui/react-checkbox"), 1);
|
|
3305
3408
|
var import_lucide_react2 = require("lucide-react");
|
|
3306
3409
|
init_utils();
|
|
3307
|
-
var
|
|
3410
|
+
var import_jsx_runtime15 = require("react/jsx-runtime");
|
|
3308
3411
|
function Checkbox({ className, ...props }) {
|
|
3309
|
-
return /* @__PURE__ */ (0,
|
|
3412
|
+
return /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3310
3413
|
CheckboxPrimitive.Root,
|
|
3311
3414
|
{
|
|
3312
3415
|
"data-slot": "checkbox",
|
|
@@ -3315,12 +3418,12 @@ function Checkbox({ className, ...props }) {
|
|
|
3315
3418
|
className
|
|
3316
3419
|
),
|
|
3317
3420
|
...props,
|
|
3318
|
-
children: /* @__PURE__ */ (0,
|
|
3421
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(
|
|
3319
3422
|
CheckboxPrimitive.Indicator,
|
|
3320
3423
|
{
|
|
3321
3424
|
"data-slot": "checkbox-indicator",
|
|
3322
3425
|
className: "flex items-center justify-center text-current transition-none",
|
|
3323
|
-
children: /* @__PURE__ */ (0,
|
|
3426
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime15.jsx)(import_lucide_react2.CheckIcon, { className: "size-3.5 text-(--inverse)" })
|
|
3324
3427
|
}
|
|
3325
3428
|
)
|
|
3326
3429
|
}
|
|
@@ -3330,7 +3433,7 @@ function Checkbox({ className, ...props }) {
|
|
|
3330
3433
|
// src/components/CreditCardTab/CreditCard/CreditCardForm.tsx
|
|
3331
3434
|
init_label();
|
|
3332
3435
|
init_logger();
|
|
3333
|
-
var
|
|
3436
|
+
var import_jsx_runtime16 = require("react/jsx-runtime");
|
|
3334
3437
|
var cardFormLogger = logger.child("card-form");
|
|
3335
3438
|
var stripeElementClasses = {
|
|
3336
3439
|
base: "w-full rounded-[12px] bg-(--s-primary) px-5 py-4 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring focus-visible:ring-offset-1 disabled:cursor-not-allowed disabled:opacity-50",
|
|
@@ -3338,14 +3441,14 @@ var stripeElementClasses = {
|
|
|
3338
3441
|
focus: "border-ring ring-ring/50 ring-2"
|
|
3339
3442
|
};
|
|
3340
3443
|
var CreditCardForm = ({ cancel, saveCard }) => {
|
|
3341
|
-
const [cardError, setCardError] = (0,
|
|
3342
|
-
const [stripeStyles, setStripeStyles] = (0,
|
|
3343
|
-
const [shouldSaveCard, setShouldSaveCard] = (0,
|
|
3344
|
-
const [isSubmitting, setIsSubmitting] = (0,
|
|
3444
|
+
const [cardError, setCardError] = (0, import_react9.useState)(void 0);
|
|
3445
|
+
const [stripeStyles, setStripeStyles] = (0, import_react9.useState)({});
|
|
3446
|
+
const [shouldSaveCard, setShouldSaveCard] = (0, import_react9.useState)(true);
|
|
3447
|
+
const [isSubmitting, setIsSubmitting] = (0, import_react9.useState)(false);
|
|
3345
3448
|
const elements = (0, import_react_stripe_js.useElements)();
|
|
3346
3449
|
const stripe = (0, import_react_stripe_js.useStripe)();
|
|
3347
|
-
const [id] = (0,
|
|
3348
|
-
const formRef = (0,
|
|
3450
|
+
const [id] = (0, import_react9.useState)(() => crypto.randomUUID());
|
|
3451
|
+
const formRef = (0, import_react9.useCallback)((node) => {
|
|
3349
3452
|
if (!node) return;
|
|
3350
3453
|
const container = node.closest(".sl-spreepay");
|
|
3351
3454
|
if (!container) return;
|
|
@@ -3403,9 +3506,9 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
3403
3506
|
setIsSubmitting(false);
|
|
3404
3507
|
}
|
|
3405
3508
|
};
|
|
3406
|
-
return /* @__PURE__ */ (0,
|
|
3407
|
-
/* @__PURE__ */ (0,
|
|
3408
|
-
/* @__PURE__ */ (0,
|
|
3509
|
+
return /* @__PURE__ */ (0, import_jsx_runtime16.jsxs)(import_jsx_runtime16.Fragment, { children: [
|
|
3510
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { ref: formRef, className: "flex w-full flex-col gap-4", children: [
|
|
3511
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3409
3512
|
import_react_stripe_js.CardNumberElement,
|
|
3410
3513
|
{
|
|
3411
3514
|
options: {
|
|
@@ -3415,8 +3518,8 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
3415
3518
|
}
|
|
3416
3519
|
}
|
|
3417
3520
|
),
|
|
3418
|
-
/* @__PURE__ */ (0,
|
|
3419
|
-
/* @__PURE__ */ (0,
|
|
3521
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex w-full gap-4", children: [
|
|
3522
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3420
3523
|
import_react_stripe_js.CardExpiryElement,
|
|
3421
3524
|
{
|
|
3422
3525
|
options: {
|
|
@@ -3426,7 +3529,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
3426
3529
|
}
|
|
3427
3530
|
}
|
|
3428
3531
|
),
|
|
3429
|
-
/* @__PURE__ */ (0,
|
|
3532
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3430
3533
|
import_react_stripe_js.CardCvcElement,
|
|
3431
3534
|
{
|
|
3432
3535
|
options: {
|
|
@@ -3437,14 +3540,14 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
3437
3540
|
}
|
|
3438
3541
|
)
|
|
3439
3542
|
] }),
|
|
3440
|
-
cardError && /* @__PURE__ */ (0,
|
|
3543
|
+
cardError && /* @__PURE__ */ (0, import_jsx_runtime16.jsx)("p", { className: "text-destructive mt-1 text-sm", children: cardError })
|
|
3441
3544
|
] }),
|
|
3442
|
-
/* @__PURE__ */ (0,
|
|
3443
|
-
/* @__PURE__ */ (0,
|
|
3444
|
-
/* @__PURE__ */ (0,
|
|
3545
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex items-center gap-2", children: [
|
|
3546
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Checkbox, { checked: shouldSaveCard, onCheckedChange: (v) => setShouldSaveCard(v === true), id: "saveCard" }),
|
|
3547
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(Label, { className: "text-sm font-medium", htmlFor: "saveCard", children: "Save card for future purchases" })
|
|
3445
3548
|
] }),
|
|
3446
|
-
/* @__PURE__ */ (0,
|
|
3447
|
-
/* @__PURE__ */ (0,
|
|
3549
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsxs)("div", { className: "flex w-full justify-end gap-2", children: [
|
|
3550
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3448
3551
|
Button,
|
|
3449
3552
|
{
|
|
3450
3553
|
variant: "outline",
|
|
@@ -3454,7 +3557,7 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
3454
3557
|
children: "Cancel"
|
|
3455
3558
|
}
|
|
3456
3559
|
),
|
|
3457
|
-
/* @__PURE__ */ (0,
|
|
3560
|
+
/* @__PURE__ */ (0, import_jsx_runtime16.jsx)(
|
|
3458
3561
|
Button,
|
|
3459
3562
|
{
|
|
3460
3563
|
className: "bg-(--s-brand) font-medium text-(--inverse) hover:bg-(--s-brand-hover)",
|
|
@@ -3468,13 +3571,14 @@ var CreditCardForm = ({ cancel, saveCard }) => {
|
|
|
3468
3571
|
};
|
|
3469
3572
|
|
|
3470
3573
|
// src/components/CreditCardTab/CreditCard/CreditCard.tsx
|
|
3471
|
-
var
|
|
3574
|
+
var import_jsx_runtime17 = require("react/jsx-runtime");
|
|
3472
3575
|
var StripeWrapper = ({ onCancel, saveNewCard, publicKey }) => {
|
|
3473
|
-
const stripePromise = (0,
|
|
3474
|
-
return /* @__PURE__ */ (0,
|
|
3576
|
+
const stripePromise = (0, import_react10.useMemo)(() => (0, import_stripe_js.loadStripe)(publicKey), [publicKey]);
|
|
3577
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(import_react_stripe_js2.Elements, { stripe: stripePromise, children: /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(CreditCardForm, { cancel: onCancel, saveCard: saveNewCard }) });
|
|
3475
3578
|
};
|
|
3476
3579
|
var CreditCard = ({ newCards, setNewCards }) => {
|
|
3477
|
-
const [showForm, setShowForm] = (0,
|
|
3580
|
+
const [showForm, setShowForm] = (0, import_react10.useState)(false);
|
|
3581
|
+
const isLoggedIn = useIsLoggedIn();
|
|
3478
3582
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
3479
3583
|
const { spreePayConfig } = useSpreePayConfig();
|
|
3480
3584
|
const setCard = (card) => {
|
|
@@ -3490,19 +3594,27 @@ var CreditCard = ({ newCards, setNewCards }) => {
|
|
|
3490
3594
|
setCard(newCard);
|
|
3491
3595
|
setShowForm(false);
|
|
3492
3596
|
};
|
|
3493
|
-
const removeNewCard = (0,
|
|
3597
|
+
const removeNewCard = (0, import_react10.useCallback)(
|
|
3494
3598
|
(card) => {
|
|
3495
3599
|
setNewCards((prev) => prev.filter((c) => c.id !== card.id));
|
|
3496
3600
|
},
|
|
3497
3601
|
[setNewCards]
|
|
3498
3602
|
);
|
|
3603
|
+
const handleAddNewCard = () => {
|
|
3604
|
+
setSelectedPaymentMethod({
|
|
3605
|
+
...selectedPaymentMethod,
|
|
3606
|
+
type: "CREDIT_CARD" /* CREDIT_CARD */,
|
|
3607
|
+
method: null
|
|
3608
|
+
});
|
|
3609
|
+
setShowForm(true);
|
|
3610
|
+
};
|
|
3499
3611
|
const handleCancel = () => {
|
|
3500
3612
|
setShowForm(false);
|
|
3501
3613
|
};
|
|
3502
|
-
return /* @__PURE__ */ (0,
|
|
3503
|
-
/* @__PURE__ */ (0,
|
|
3504
|
-
!showForm && /* @__PURE__ */ (0,
|
|
3505
|
-
/* @__PURE__ */ (0,
|
|
3614
|
+
return /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)("div", { className: "flex flex-col items-baseline gap-4", children: [
|
|
3615
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)("h3", { className: "text-[22px] leading-9 font-medium text-(--brand-primary)", children: "Your Cards" }),
|
|
3616
|
+
!showForm && /* @__PURE__ */ (0, import_jsx_runtime17.jsxs)(import_jsx_runtime17.Fragment, { children: [
|
|
3617
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3506
3618
|
CardsList,
|
|
3507
3619
|
{
|
|
3508
3620
|
selectedCard: selectedPaymentMethod?.type === "CREDIT_CARD" /* CREDIT_CARD */ ? selectedPaymentMethod.method : null,
|
|
@@ -3511,30 +3623,31 @@ var CreditCard = ({ newCards, setNewCards }) => {
|
|
|
3511
3623
|
onRemoveNewCard: removeNewCard
|
|
3512
3624
|
}
|
|
3513
3625
|
),
|
|
3514
|
-
spreePayConfig?.creditCard.infoMessage && /* @__PURE__ */ (0,
|
|
3515
|
-
/* @__PURE__ */ (0,
|
|
3626
|
+
spreePayConfig?.creditCard.infoMessage && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(InfoBanner, { message: spreePayConfig.creditCard.infoMessage }),
|
|
3627
|
+
/* @__PURE__ */ (0, import_jsx_runtime17.jsx)(
|
|
3516
3628
|
"button",
|
|
3517
3629
|
{
|
|
3518
|
-
onClick:
|
|
3519
|
-
disabled: !spreePayConfig?.stripePublicKey,
|
|
3630
|
+
onClick: handleAddNewCard,
|
|
3631
|
+
disabled: !isLoggedIn || !spreePayConfig?.stripePublicKey,
|
|
3520
3632
|
className: "text-md text-(--brand-primary) hover:underline disabled:cursor-not-allowed disabled:no-underline disabled:opacity-50",
|
|
3521
3633
|
children: "Add new card"
|
|
3522
3634
|
}
|
|
3523
3635
|
)
|
|
3524
3636
|
] }),
|
|
3525
|
-
spreePayConfig?.stripePublicKey && showForm && /* @__PURE__ */ (0,
|
|
3637
|
+
isLoggedIn && spreePayConfig?.stripePublicKey && showForm && /* @__PURE__ */ (0, import_jsx_runtime17.jsx)(StripeWrapper, { onCancel: handleCancel, saveNewCard, publicKey: spreePayConfig.stripePublicKey })
|
|
3526
3638
|
] });
|
|
3527
3639
|
};
|
|
3528
3640
|
|
|
3529
3641
|
// src/components/CreditCardTab/Points/Points.tsx
|
|
3530
|
-
var
|
|
3642
|
+
var import_react15 = require("react");
|
|
3643
|
+
init_LoginStatusContext();
|
|
3531
3644
|
init_SpreePayActionsContext();
|
|
3532
3645
|
init_StaticConfigContext();
|
|
3533
3646
|
init_useSpreePayConfig();
|
|
3534
3647
|
init_common();
|
|
3535
3648
|
|
|
3536
3649
|
// src/components/CreditCardTab/Points/SplitBlock.tsx
|
|
3537
|
-
var
|
|
3650
|
+
var import_react14 = require("react");
|
|
3538
3651
|
var import_airkit2 = require("@mocanetwork/airkit");
|
|
3539
3652
|
init_SpreePayActionsContext();
|
|
3540
3653
|
init_StaticConfigContext();
|
|
@@ -3544,7 +3657,7 @@ init_format();
|
|
|
3544
3657
|
init_logger();
|
|
3545
3658
|
|
|
3546
3659
|
// src/components/CreditCardTab/Points/PointsSelector.tsx
|
|
3547
|
-
var
|
|
3660
|
+
var import_react13 = require("react");
|
|
3548
3661
|
init_SpreePayActionsContext();
|
|
3549
3662
|
init_StaticConfigContext();
|
|
3550
3663
|
init_useSlapiBalance();
|
|
@@ -3553,9 +3666,9 @@ init_utils();
|
|
|
3553
3666
|
|
|
3554
3667
|
// src/ui/input.tsx
|
|
3555
3668
|
init_utils();
|
|
3556
|
-
var
|
|
3669
|
+
var import_jsx_runtime18 = require("react/jsx-runtime");
|
|
3557
3670
|
function Input({ className, type, ...props }) {
|
|
3558
|
-
return /* @__PURE__ */ (0,
|
|
3671
|
+
return /* @__PURE__ */ (0, import_jsx_runtime18.jsx)(
|
|
3559
3672
|
"input",
|
|
3560
3673
|
{
|
|
3561
3674
|
type,
|
|
@@ -3632,7 +3745,7 @@ function useComposedRefs(...refs) {
|
|
|
3632
3745
|
|
|
3633
3746
|
// ../../node_modules/@radix-ui/react-context/dist/index.mjs
|
|
3634
3747
|
var React3 = __toESM(require("react"), 1);
|
|
3635
|
-
var
|
|
3748
|
+
var import_jsx_runtime19 = require("react/jsx-runtime");
|
|
3636
3749
|
function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
3637
3750
|
let defaultContexts = [];
|
|
3638
3751
|
function createContext32(rootComponentName, defaultContext) {
|
|
@@ -3643,7 +3756,7 @@ function createContextScope(scopeName, createContextScopeDeps = []) {
|
|
|
3643
3756
|
const { scope, children, ...context } = props;
|
|
3644
3757
|
const Context = scope?.[scopeName]?.[index] || BaseContext;
|
|
3645
3758
|
const value = React3.useMemo(() => context, Object.values(context));
|
|
3646
|
-
return /* @__PURE__ */ (0,
|
|
3759
|
+
return /* @__PURE__ */ (0, import_jsx_runtime19.jsx)(Context.Provider, { value, children });
|
|
3647
3760
|
};
|
|
3648
3761
|
Provider.displayName = rootComponentName + "Provider";
|
|
3649
3762
|
function useContext22(consumerName, scope) {
|
|
@@ -3768,7 +3881,7 @@ function isFunction(value) {
|
|
|
3768
3881
|
|
|
3769
3882
|
// ../../node_modules/@radix-ui/react-direction/dist/index.mjs
|
|
3770
3883
|
var React6 = __toESM(require("react"), 1);
|
|
3771
|
-
var
|
|
3884
|
+
var import_jsx_runtime20 = require("react/jsx-runtime");
|
|
3772
3885
|
var DirectionContext = React6.createContext(void 0);
|
|
3773
3886
|
function useDirection(localDir) {
|
|
3774
3887
|
const globalDir = React6.useContext(DirectionContext);
|
|
@@ -3829,7 +3942,7 @@ function useSize(element) {
|
|
|
3829
3942
|
var React9 = __toESM(require("react"), 1);
|
|
3830
3943
|
var ReactDOM = __toESM(require("react-dom"), 1);
|
|
3831
3944
|
var import_react_slot2 = require("@radix-ui/react-slot");
|
|
3832
|
-
var
|
|
3945
|
+
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3833
3946
|
var NODES = [
|
|
3834
3947
|
"a",
|
|
3835
3948
|
"button",
|
|
@@ -3857,19 +3970,19 @@ var Primitive = NODES.reduce((primitive, node) => {
|
|
|
3857
3970
|
if (typeof window !== "undefined") {
|
|
3858
3971
|
window[/* @__PURE__ */ Symbol.for("radix-ui")] = true;
|
|
3859
3972
|
}
|
|
3860
|
-
return /* @__PURE__ */ (0,
|
|
3973
|
+
return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(Comp, { ...primitiveProps, ref: forwardedRef });
|
|
3861
3974
|
});
|
|
3862
3975
|
Node2.displayName = `Primitive.${node}`;
|
|
3863
3976
|
return { ...primitive, [node]: Node2 };
|
|
3864
3977
|
}, {});
|
|
3865
3978
|
|
|
3866
3979
|
// ../../node_modules/@radix-ui/react-collection/dist/index.mjs
|
|
3867
|
-
var import_react10 = __toESM(require("react"), 1);
|
|
3868
|
-
var import_react_slot3 = require("@radix-ui/react-slot");
|
|
3869
|
-
var import_jsx_runtime21 = require("react/jsx-runtime");
|
|
3870
3980
|
var import_react11 = __toESM(require("react"), 1);
|
|
3871
|
-
var
|
|
3981
|
+
var import_react_slot3 = require("@radix-ui/react-slot");
|
|
3872
3982
|
var import_jsx_runtime22 = require("react/jsx-runtime");
|
|
3983
|
+
var import_react12 = __toESM(require("react"), 1);
|
|
3984
|
+
var import_react_slot4 = require("@radix-ui/react-slot");
|
|
3985
|
+
var import_jsx_runtime23 = require("react/jsx-runtime");
|
|
3873
3986
|
function createCollection(name) {
|
|
3874
3987
|
const PROVIDER_NAME = name + "CollectionProvider";
|
|
3875
3988
|
const [createCollectionContext, createCollectionScope2] = createContextScope(PROVIDER_NAME);
|
|
@@ -3879,42 +3992,42 @@ function createCollection(name) {
|
|
|
3879
3992
|
);
|
|
3880
3993
|
const CollectionProvider = (props) => {
|
|
3881
3994
|
const { scope, children } = props;
|
|
3882
|
-
const ref =
|
|
3883
|
-
const itemMap =
|
|
3884
|
-
return /* @__PURE__ */ (0,
|
|
3995
|
+
const ref = import_react11.default.useRef(null);
|
|
3996
|
+
const itemMap = import_react11.default.useRef(/* @__PURE__ */ new Map()).current;
|
|
3997
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CollectionProviderImpl, { scope, itemMap, collectionRef: ref, children });
|
|
3885
3998
|
};
|
|
3886
3999
|
CollectionProvider.displayName = PROVIDER_NAME;
|
|
3887
4000
|
const COLLECTION_SLOT_NAME = name + "CollectionSlot";
|
|
3888
4001
|
const CollectionSlotImpl = (0, import_react_slot3.createSlot)(COLLECTION_SLOT_NAME);
|
|
3889
|
-
const CollectionSlot =
|
|
4002
|
+
const CollectionSlot = import_react11.default.forwardRef(
|
|
3890
4003
|
(props, forwardedRef) => {
|
|
3891
4004
|
const { scope, children } = props;
|
|
3892
4005
|
const context = useCollectionContext(COLLECTION_SLOT_NAME, scope);
|
|
3893
4006
|
const composedRefs = useComposedRefs(forwardedRef, context.collectionRef);
|
|
3894
|
-
return /* @__PURE__ */ (0,
|
|
4007
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CollectionSlotImpl, { ref: composedRefs, children });
|
|
3895
4008
|
}
|
|
3896
4009
|
);
|
|
3897
4010
|
CollectionSlot.displayName = COLLECTION_SLOT_NAME;
|
|
3898
4011
|
const ITEM_SLOT_NAME = name + "CollectionItemSlot";
|
|
3899
4012
|
const ITEM_DATA_ATTR = "data-radix-collection-item";
|
|
3900
4013
|
const CollectionItemSlotImpl = (0, import_react_slot3.createSlot)(ITEM_SLOT_NAME);
|
|
3901
|
-
const CollectionItemSlot =
|
|
4014
|
+
const CollectionItemSlot = import_react11.default.forwardRef(
|
|
3902
4015
|
(props, forwardedRef) => {
|
|
3903
4016
|
const { scope, children, ...itemData } = props;
|
|
3904
|
-
const ref =
|
|
4017
|
+
const ref = import_react11.default.useRef(null);
|
|
3905
4018
|
const composedRefs = useComposedRefs(forwardedRef, ref);
|
|
3906
4019
|
const context = useCollectionContext(ITEM_SLOT_NAME, scope);
|
|
3907
|
-
|
|
4020
|
+
import_react11.default.useEffect(() => {
|
|
3908
4021
|
context.itemMap.set(ref, { ref, ...itemData });
|
|
3909
4022
|
return () => void context.itemMap.delete(ref);
|
|
3910
4023
|
});
|
|
3911
|
-
return /* @__PURE__ */ (0,
|
|
4024
|
+
return /* @__PURE__ */ (0, import_jsx_runtime22.jsx)(CollectionItemSlotImpl, { ...{ [ITEM_DATA_ATTR]: "" }, ref: composedRefs, children });
|
|
3912
4025
|
}
|
|
3913
4026
|
);
|
|
3914
4027
|
CollectionItemSlot.displayName = ITEM_SLOT_NAME;
|
|
3915
4028
|
function useCollection2(scope) {
|
|
3916
4029
|
const context = useCollectionContext(name + "CollectionConsumer", scope);
|
|
3917
|
-
const getItems =
|
|
4030
|
+
const getItems = import_react11.default.useCallback(() => {
|
|
3918
4031
|
const collectionNode = context.collectionRef.current;
|
|
3919
4032
|
if (!collectionNode) return [];
|
|
3920
4033
|
const orderedNodes = Array.from(collectionNode.querySelectorAll(`[${ITEM_DATA_ATTR}]`));
|
|
@@ -3934,7 +4047,7 @@ function createCollection(name) {
|
|
|
3934
4047
|
}
|
|
3935
4048
|
|
|
3936
4049
|
// ../../node_modules/@radix-ui/react-slider/dist/index.mjs
|
|
3937
|
-
var
|
|
4050
|
+
var import_jsx_runtime24 = require("react/jsx-runtime");
|
|
3938
4051
|
var PAGE_KEYS = ["PageUp", "PageDown"];
|
|
3939
4052
|
var ARROW_KEYS = ["ArrowUp", "ArrowDown", "ArrowLeft", "ArrowRight"];
|
|
3940
4053
|
var BACK_KEYS = {
|
|
@@ -4012,7 +4125,7 @@ var Slider = React11.forwardRef(
|
|
|
4012
4125
|
}
|
|
4013
4126
|
});
|
|
4014
4127
|
}
|
|
4015
|
-
return /* @__PURE__ */ (0,
|
|
4128
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4016
4129
|
SliderProvider,
|
|
4017
4130
|
{
|
|
4018
4131
|
scope: props.__scopeSlider,
|
|
@@ -4025,7 +4138,7 @@ var Slider = React11.forwardRef(
|
|
|
4025
4138
|
values,
|
|
4026
4139
|
orientation,
|
|
4027
4140
|
form,
|
|
4028
|
-
children: /* @__PURE__ */ (0,
|
|
4141
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Collection.Provider, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Collection.Slot, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4029
4142
|
SliderOrientation,
|
|
4030
4143
|
{
|
|
4031
4144
|
"aria-disabled": disabled,
|
|
@@ -4094,7 +4207,7 @@ var SliderHorizontal = React11.forwardRef(
|
|
|
4094
4207
|
rectRef.current = rect;
|
|
4095
4208
|
return value(pointerPosition - rect.left);
|
|
4096
4209
|
}
|
|
4097
|
-
return /* @__PURE__ */ (0,
|
|
4210
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4098
4211
|
SliderOrientationProvider,
|
|
4099
4212
|
{
|
|
4100
4213
|
scope: props.__scopeSlider,
|
|
@@ -4102,7 +4215,7 @@ var SliderHorizontal = React11.forwardRef(
|
|
|
4102
4215
|
endEdge: isSlidingFromLeft ? "right" : "left",
|
|
4103
4216
|
direction: isSlidingFromLeft ? 1 : -1,
|
|
4104
4217
|
size: "width",
|
|
4105
|
-
children: /* @__PURE__ */ (0,
|
|
4218
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4106
4219
|
SliderImpl,
|
|
4107
4220
|
{
|
|
4108
4221
|
dir: direction,
|
|
@@ -4160,7 +4273,7 @@ var SliderVertical = React11.forwardRef(
|
|
|
4160
4273
|
rectRef.current = rect;
|
|
4161
4274
|
return value(pointerPosition - rect.top);
|
|
4162
4275
|
}
|
|
4163
|
-
return /* @__PURE__ */ (0,
|
|
4276
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4164
4277
|
SliderOrientationProvider,
|
|
4165
4278
|
{
|
|
4166
4279
|
scope: props.__scopeSlider,
|
|
@@ -4168,7 +4281,7 @@ var SliderVertical = React11.forwardRef(
|
|
|
4168
4281
|
endEdge: isSlidingFromBottom ? "top" : "bottom",
|
|
4169
4282
|
size: "height",
|
|
4170
4283
|
direction: isSlidingFromBottom ? 1 : -1,
|
|
4171
|
-
children: /* @__PURE__ */ (0,
|
|
4284
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4172
4285
|
SliderImpl,
|
|
4173
4286
|
{
|
|
4174
4287
|
"data-orientation": "vertical",
|
|
@@ -4214,7 +4327,7 @@ var SliderImpl = React11.forwardRef(
|
|
|
4214
4327
|
...sliderProps
|
|
4215
4328
|
} = props;
|
|
4216
4329
|
const context = useSliderContext(SLIDER_NAME, __scopeSlider);
|
|
4217
|
-
return /* @__PURE__ */ (0,
|
|
4330
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4218
4331
|
Primitive.span,
|
|
4219
4332
|
{
|
|
4220
4333
|
...sliderProps,
|
|
@@ -4261,7 +4374,7 @@ var SliderTrack = React11.forwardRef(
|
|
|
4261
4374
|
(props, forwardedRef) => {
|
|
4262
4375
|
const { __scopeSlider, ...trackProps } = props;
|
|
4263
4376
|
const context = useSliderContext(TRACK_NAME, __scopeSlider);
|
|
4264
|
-
return /* @__PURE__ */ (0,
|
|
4377
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4265
4378
|
Primitive.span,
|
|
4266
4379
|
{
|
|
4267
4380
|
"data-disabled": context.disabled ? "" : void 0,
|
|
@@ -4287,7 +4400,7 @@ var SliderRange = React11.forwardRef(
|
|
|
4287
4400
|
);
|
|
4288
4401
|
const offsetStart = valuesCount > 1 ? Math.min(...percentages) : 0;
|
|
4289
4402
|
const offsetEnd = 100 - Math.max(...percentages);
|
|
4290
|
-
return /* @__PURE__ */ (0,
|
|
4403
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4291
4404
|
Primitive.span,
|
|
4292
4405
|
{
|
|
4293
4406
|
"data-orientation": context.orientation,
|
|
@@ -4314,7 +4427,7 @@ var SliderThumb = React11.forwardRef(
|
|
|
4314
4427
|
() => thumb ? getItems().findIndex((item) => item.ref.current === thumb) : -1,
|
|
4315
4428
|
[getItems, thumb]
|
|
4316
4429
|
);
|
|
4317
|
-
return /* @__PURE__ */ (0,
|
|
4430
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(SliderThumbImpl, { ...props, ref: composedRefs, index });
|
|
4318
4431
|
}
|
|
4319
4432
|
);
|
|
4320
4433
|
var SliderThumbImpl = React11.forwardRef(
|
|
@@ -4339,7 +4452,7 @@ var SliderThumbImpl = React11.forwardRef(
|
|
|
4339
4452
|
};
|
|
4340
4453
|
}
|
|
4341
4454
|
}, [thumb, context.thumbs]);
|
|
4342
|
-
return /* @__PURE__ */ (0,
|
|
4455
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsxs)(
|
|
4343
4456
|
"span",
|
|
4344
4457
|
{
|
|
4345
4458
|
style: {
|
|
@@ -4348,7 +4461,7 @@ var SliderThumbImpl = React11.forwardRef(
|
|
|
4348
4461
|
[orientation.startEdge]: `calc(${percent}% + ${thumbInBoundsOffset}px)`
|
|
4349
4462
|
},
|
|
4350
4463
|
children: [
|
|
4351
|
-
/* @__PURE__ */ (0,
|
|
4464
|
+
/* @__PURE__ */ (0, import_jsx_runtime24.jsx)(Collection.ItemSlot, { scope: props.__scopeSlider, children: /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4352
4465
|
Primitive.span,
|
|
4353
4466
|
{
|
|
4354
4467
|
role: "slider",
|
|
@@ -4368,7 +4481,7 @@ var SliderThumbImpl = React11.forwardRef(
|
|
|
4368
4481
|
})
|
|
4369
4482
|
}
|
|
4370
4483
|
) }),
|
|
4371
|
-
isFormControl && /* @__PURE__ */ (0,
|
|
4484
|
+
isFormControl && /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4372
4485
|
SliderBubbleInput,
|
|
4373
4486
|
{
|
|
4374
4487
|
name: name ?? (context.name ? context.name + (context.values.length > 1 ? "[]" : "") : void 0),
|
|
@@ -4401,7 +4514,7 @@ var SliderBubbleInput = React11.forwardRef(
|
|
|
4401
4514
|
input.dispatchEvent(event);
|
|
4402
4515
|
}
|
|
4403
4516
|
}, [prevValue, value]);
|
|
4404
|
-
return /* @__PURE__ */ (0,
|
|
4517
|
+
return /* @__PURE__ */ (0, import_jsx_runtime24.jsx)(
|
|
4405
4518
|
Primitive.input,
|
|
4406
4519
|
{
|
|
4407
4520
|
style: { display: "none" },
|
|
@@ -4477,14 +4590,14 @@ var Thumb2 = SliderThumb;
|
|
|
4477
4590
|
|
|
4478
4591
|
// src/ui/slider.tsx
|
|
4479
4592
|
init_utils2();
|
|
4480
|
-
var
|
|
4593
|
+
var import_jsx_runtime25 = require("react/jsx-runtime");
|
|
4481
4594
|
function Slider2(props) {
|
|
4482
4595
|
const { className, defaultValue, value, min = 0, max = 100, ...rest } = props;
|
|
4483
4596
|
const _values = React12.useMemo(
|
|
4484
4597
|
() => Array.isArray(value) ? value : Array.isArray(defaultValue) ? defaultValue : [min, max],
|
|
4485
4598
|
[value, defaultValue, min, max]
|
|
4486
4599
|
);
|
|
4487
|
-
return /* @__PURE__ */ (0,
|
|
4600
|
+
return /* @__PURE__ */ (0, import_jsx_runtime25.jsxs)(
|
|
4488
4601
|
Root5,
|
|
4489
4602
|
{
|
|
4490
4603
|
"data-slot": "slider",
|
|
@@ -4498,14 +4611,14 @@ function Slider2(props) {
|
|
|
4498
4611
|
),
|
|
4499
4612
|
...rest,
|
|
4500
4613
|
children: [
|
|
4501
|
-
/* @__PURE__ */ (0,
|
|
4614
|
+
/* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4502
4615
|
Track,
|
|
4503
4616
|
{
|
|
4504
4617
|
"data-slot": "slider-track",
|
|
4505
4618
|
className: cn2(
|
|
4506
4619
|
"relative grow overflow-hidden rounded-full bg-(--primary)/15 data-[orientation=horizontal]:h-1.5 data-[orientation=horizontal]:w-full data-[orientation=vertical]:h-full data-[orientation=vertical]:w-1.5"
|
|
4507
4620
|
),
|
|
4508
|
-
children: /* @__PURE__ */ (0,
|
|
4621
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4509
4622
|
Range,
|
|
4510
4623
|
{
|
|
4511
4624
|
"data-slot": "slider-range",
|
|
@@ -4516,7 +4629,7 @@ function Slider2(props) {
|
|
|
4516
4629
|
)
|
|
4517
4630
|
}
|
|
4518
4631
|
),
|
|
4519
|
-
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0,
|
|
4632
|
+
Array.from({ length: _values.length }, (_, index) => /* @__PURE__ */ (0, import_jsx_runtime25.jsx)(
|
|
4520
4633
|
Thumb2,
|
|
4521
4634
|
{
|
|
4522
4635
|
"data-slot": "slider-thumb",
|
|
@@ -4533,7 +4646,7 @@ function Slider2(props) {
|
|
|
4533
4646
|
init_format();
|
|
4534
4647
|
init_split();
|
|
4535
4648
|
init_transactionFee();
|
|
4536
|
-
var
|
|
4649
|
+
var import_jsx_runtime26 = require("react/jsx-runtime");
|
|
4537
4650
|
var PointsSelector = (props) => {
|
|
4538
4651
|
const { isDisabled, isSelected, onSelect, children } = props;
|
|
4539
4652
|
const { balance } = useSlapiBalance();
|
|
@@ -4547,7 +4660,7 @@ var PointsSelector = (props) => {
|
|
|
4547
4660
|
const maxByAmount = pointsConversionRatio && pointsConversionRatio > 0 ? (amount ?? 0) / pointsConversionRatio : 0;
|
|
4548
4661
|
const max = Math.min(maxByAmount, balance?.availablePoints ?? 0);
|
|
4549
4662
|
const step = 10;
|
|
4550
|
-
const [splitTokens, setSplitTokens] = (0,
|
|
4663
|
+
const [splitTokens, setSplitTokens] = (0, import_react13.useState)(0);
|
|
4551
4664
|
const usdAmount = getSplitAmount(amount ?? 0, splitTokens, pointsConversionRatio);
|
|
4552
4665
|
const pointsValue = String(Math.round(splitTokens));
|
|
4553
4666
|
const usdWithFee = usdAmount + getTransactionFee(usdAmount, transactionFeePercentage);
|
|
@@ -4562,7 +4675,7 @@ var PointsSelector = (props) => {
|
|
|
4562
4675
|
foreignCurrencyAmount: hasForeignCurrency ? parseFloat((committedUsdWithFee / exchangeRate).toFixed(2)) : void 0
|
|
4563
4676
|
});
|
|
4564
4677
|
};
|
|
4565
|
-
return /* @__PURE__ */ (0,
|
|
4678
|
+
return /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)(
|
|
4566
4679
|
"button",
|
|
4567
4680
|
{
|
|
4568
4681
|
disabled: isDisabled,
|
|
@@ -4574,8 +4687,8 @@ var PointsSelector = (props) => {
|
|
|
4574
4687
|
}
|
|
4575
4688
|
),
|
|
4576
4689
|
children: [
|
|
4577
|
-
/* @__PURE__ */ (0,
|
|
4578
|
-
/* @__PURE__ */ (0,
|
|
4690
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex h-11 w-full bg-(--s-primary) hover:bg-(--s-primary-hover)", children: [
|
|
4691
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4579
4692
|
"div",
|
|
4580
4693
|
{
|
|
4581
4694
|
className: cn(
|
|
@@ -4584,14 +4697,14 @@ var PointsSelector = (props) => {
|
|
|
4584
4697
|
"border-(--b-brand)": isSelected
|
|
4585
4698
|
}
|
|
4586
4699
|
),
|
|
4587
|
-
children: /* @__PURE__ */ (0,
|
|
4700
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex size-5 items-center justify-center rounded-full border-2 border-(--brand-primary)", children: isSelected && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "size-2 rounded-full bg-(--brand-primary)" }) })
|
|
4588
4701
|
}
|
|
4589
4702
|
),
|
|
4590
|
-
/* @__PURE__ */ (0,
|
|
4703
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex h-full w-full items-center justify-between gap-2 px-2 sm:gap-3 sm:px-3", children })
|
|
4591
4704
|
] }),
|
|
4592
|
-
isSelected && /* @__PURE__ */ (0,
|
|
4593
|
-
/* @__PURE__ */ (0,
|
|
4594
|
-
/* @__PURE__ */ (0,
|
|
4705
|
+
isSelected && /* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "px-2 pt-5 pb-2 sm:px-3 md:px-4", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex justify-between gap-2 sm:gap-3", children: [
|
|
4706
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
4707
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4595
4708
|
Input,
|
|
4596
4709
|
{
|
|
4597
4710
|
readOnly: true,
|
|
@@ -4602,9 +4715,9 @@ var PointsSelector = (props) => {
|
|
|
4602
4715
|
onClick: (e) => e.stopPropagation()
|
|
4603
4716
|
}
|
|
4604
4717
|
),
|
|
4605
|
-
/* @__PURE__ */ (0,
|
|
4718
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-left text-xs leading-5 text-(--tertiary)", children: "Points" })
|
|
4606
4719
|
] }),
|
|
4607
|
-
/* @__PURE__ */ (0,
|
|
4720
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("div", { className: "flex w-full items-center pb-6", children: /* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4608
4721
|
Slider2,
|
|
4609
4722
|
{
|
|
4610
4723
|
value: [splitTokens],
|
|
@@ -4616,8 +4729,8 @@ var PointsSelector = (props) => {
|
|
|
4616
4729
|
step
|
|
4617
4730
|
}
|
|
4618
4731
|
) }),
|
|
4619
|
-
/* @__PURE__ */ (0,
|
|
4620
|
-
/* @__PURE__ */ (0,
|
|
4732
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsxs)("div", { className: "flex flex-col gap-1", children: [
|
|
4733
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)(
|
|
4621
4734
|
Input,
|
|
4622
4735
|
{
|
|
4623
4736
|
readOnly: true,
|
|
@@ -4628,7 +4741,7 @@ var PointsSelector = (props) => {
|
|
|
4628
4741
|
onClick: (e) => e.stopPropagation()
|
|
4629
4742
|
}
|
|
4630
4743
|
),
|
|
4631
|
-
/* @__PURE__ */ (0,
|
|
4744
|
+
/* @__PURE__ */ (0, import_jsx_runtime26.jsx)("p", { className: "text-left text-xs leading-5 text-(--tertiary)", children: "Card" })
|
|
4632
4745
|
] })
|
|
4633
4746
|
] }) })
|
|
4634
4747
|
]
|
|
@@ -4637,7 +4750,7 @@ var PointsSelector = (props) => {
|
|
|
4637
4750
|
};
|
|
4638
4751
|
|
|
4639
4752
|
// src/components/CreditCardTab/Points/SplitBlock.tsx
|
|
4640
|
-
var
|
|
4753
|
+
var import_jsx_runtime27 = require("react/jsx-runtime");
|
|
4641
4754
|
var splitBlockLogger = logger.child("split-block");
|
|
4642
4755
|
var SplitBlock = (props) => {
|
|
4643
4756
|
const { onToggle, isSelected, onSelect } = props;
|
|
@@ -4645,14 +4758,14 @@ var SplitBlock = (props) => {
|
|
|
4645
4758
|
const { spreePayConfig } = useSpreePayConfig();
|
|
4646
4759
|
const { appProps } = useStaticConfig();
|
|
4647
4760
|
const { currencyCode, exchangeRate, foreignCurrencyAmount } = appProps;
|
|
4648
|
-
const [address, setAddress] = (0,
|
|
4649
|
-
const [walletReady, setWalletReady] = (0,
|
|
4761
|
+
const [address, setAddress] = (0, import_react14.useState)(null);
|
|
4762
|
+
const [walletReady, setWalletReady] = (0, import_react14.useState)(false);
|
|
4650
4763
|
const { pointsConversionRatio, pointsTitle } = spreePayConfig || {};
|
|
4651
4764
|
const { useWeb3Points, environment } = useSpreePayEnv();
|
|
4652
4765
|
const hasForeignCurrency = !!(currencyCode && exchangeRate && foreignCurrencyAmount);
|
|
4653
4766
|
const formatPointsValue = (usd) => hasForeignCurrency ? formatCurrency(usd / exchangeRate, currencyCode) : formatCurrency(usd);
|
|
4654
|
-
const prevPointsChainRef = (0,
|
|
4655
|
-
const initWallet = (0,
|
|
4767
|
+
const prevPointsChainRef = (0, import_react14.useRef)(spreePayConfig?.pointsChain);
|
|
4768
|
+
const initWallet = (0, import_react14.useCallback)(
|
|
4656
4769
|
async (pointsChain) => {
|
|
4657
4770
|
if (!pointsChain) return;
|
|
4658
4771
|
try {
|
|
@@ -4675,7 +4788,7 @@ var SplitBlock = (props) => {
|
|
|
4675
4788
|
},
|
|
4676
4789
|
[onToggle, environment]
|
|
4677
4790
|
);
|
|
4678
|
-
(0,
|
|
4791
|
+
(0, import_react14.useEffect)(() => {
|
|
4679
4792
|
if (!useWeb3Points) return;
|
|
4680
4793
|
const pointsChainChanged = prevPointsChainRef.current !== spreePayConfig?.pointsChain;
|
|
4681
4794
|
prevPointsChainRef.current = spreePayConfig?.pointsChain;
|
|
@@ -4689,24 +4802,25 @@ var SplitBlock = (props) => {
|
|
|
4689
4802
|
doInit();
|
|
4690
4803
|
}, [spreePayConfig?.pointsChain, initWallet, useWeb3Points]);
|
|
4691
4804
|
const isPointsSelectorDisabled = useWeb3Points ? !walletReady : false;
|
|
4692
|
-
return /* @__PURE__ */ (0,
|
|
4693
|
-
/* @__PURE__ */ (0,
|
|
4694
|
-
/* @__PURE__ */ (0,
|
|
4805
|
+
return /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex flex-col gap-1", children: /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)(PointsSelector, { isDisabled: isPointsSelectorDisabled, onSelect: () => onSelect("air"), isSelected, children: [
|
|
4806
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "flex items-center gap-2", children: balance?.availablePoints ? /* @__PURE__ */ (0, import_jsx_runtime27.jsxs)("p", { className: "text-left text-xs font-medium text-(--brand-primary) sm:text-sm", children: [
|
|
4807
|
+
/* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-(--secondary)", children: "Available" }),
|
|
4695
4808
|
" ",
|
|
4696
4809
|
formatPoints(balance.availablePoints, pointsTitle),
|
|
4697
4810
|
" ",
|
|
4698
|
-
pointsConversionRatio && /* @__PURE__ */ (0,
|
|
4811
|
+
pointsConversionRatio && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("span", { className: "text-(--secondary)", children: formatPointsValue(balance.availablePoints * pointsConversionRatio) })
|
|
4699
4812
|
] }) : null }),
|
|
4700
|
-
isBalanceLoading ? /* @__PURE__ */ (0,
|
|
4701
|
-
address && /* @__PURE__ */ (0,
|
|
4813
|
+
isBalanceLoading ? /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "h-4 w-6 animate-pulse bg-(--s-secondary)" }) : !balance?.availablePoints && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("p", { className: "text-sm font-medium text-(--brand-primary)", children: "No points available" }),
|
|
4814
|
+
address && /* @__PURE__ */ (0, import_jsx_runtime27.jsx)("div", { className: "text-sm font-medium text-(--brand-primary)", children: address.length > 8 ? `${address.slice(0, 4)}...${address.slice(-4)}` : address })
|
|
4702
4815
|
] }) });
|
|
4703
4816
|
};
|
|
4704
4817
|
|
|
4705
4818
|
// src/components/CreditCardTab/Points/Points.tsx
|
|
4706
|
-
var
|
|
4819
|
+
var import_jsx_runtime28 = require("react/jsx-runtime");
|
|
4707
4820
|
var Points = () => {
|
|
4708
|
-
const
|
|
4709
|
-
const [
|
|
4821
|
+
const isLoggedIn = useIsLoggedIn();
|
|
4822
|
+
const [usePoints, setUsePoints] = (0, import_react15.useState)(false);
|
|
4823
|
+
const [selectedPointsType, setSelectedPointsType] = (0, import_react15.useState)(null);
|
|
4710
4824
|
const { setSelectedPaymentMethod, selectedPaymentMethod } = useSpreePaymentMethod();
|
|
4711
4825
|
const { spreePayConfig } = useSpreePayConfig();
|
|
4712
4826
|
const { appProps } = useStaticConfig();
|
|
@@ -4717,17 +4831,17 @@ var Points = () => {
|
|
|
4717
4831
|
setSelectedPaymentMethod({ ...selectedPaymentMethod, pointsAmount: void 0 });
|
|
4718
4832
|
}
|
|
4719
4833
|
};
|
|
4720
|
-
return /* @__PURE__ */ (0,
|
|
4721
|
-
/* @__PURE__ */ (0,
|
|
4834
|
+
return /* @__PURE__ */ (0, import_jsx_runtime28.jsxs)(import_jsx_runtime28.Fragment, { children: [
|
|
4835
|
+
/* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4722
4836
|
PointsSwitch,
|
|
4723
4837
|
{
|
|
4724
4838
|
value: usePoints,
|
|
4725
4839
|
onChange: handleTogglePoints,
|
|
4726
4840
|
message: spreePayConfig?.creditCard.pointsInfoMessage,
|
|
4727
|
-
disabled: !spreePayConfig?.creditCard.enabled || !spreePayConfig?.creditCard.points || appProps.disabledPoints
|
|
4841
|
+
disabled: !isLoggedIn || !spreePayConfig?.creditCard.enabled || !spreePayConfig?.creditCard.points || appProps.disabledPoints
|
|
4728
4842
|
}
|
|
4729
4843
|
),
|
|
4730
|
-
usePoints && /* @__PURE__ */ (0,
|
|
4844
|
+
usePoints && /* @__PURE__ */ (0, import_jsx_runtime28.jsx)(
|
|
4731
4845
|
SplitBlock,
|
|
4732
4846
|
{
|
|
4733
4847
|
onToggle: handleTogglePoints,
|
|
@@ -4739,8 +4853,8 @@ var Points = () => {
|
|
|
4739
4853
|
};
|
|
4740
4854
|
|
|
4741
4855
|
// src/components/CreditCardTab/CreditCardTab.tsx
|
|
4742
|
-
var
|
|
4743
|
-
var CreditCardTab = (
|
|
4856
|
+
var import_jsx_runtime29 = require("react/jsx-runtime");
|
|
4857
|
+
var CreditCardTab = () => {
|
|
4744
4858
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
4745
4859
|
const { useWeb3Points } = useSpreePayEnv();
|
|
4746
4860
|
const { appProps } = useStaticConfig();
|
|
@@ -4748,30 +4862,30 @@ var CreditCardTab = ({ isLoggedIn }) => {
|
|
|
4748
4862
|
const { register } = useSpreePayRegister();
|
|
4749
4863
|
const { cards, mutateCards } = useCards();
|
|
4750
4864
|
const { mutateBalance } = useSlapiBalance();
|
|
4751
|
-
const [newCards, setNewCards] = (0,
|
|
4865
|
+
const [newCards, setNewCards] = (0, import_react16.useState)([]);
|
|
4752
4866
|
const isWeb3Enabled = Boolean(useWeb3Points);
|
|
4753
4867
|
const { cardPayment } = useCardPayment();
|
|
4754
4868
|
const { splitPayment } = useSplitCardPayments(isWeb3Enabled ? "web3" : "web2");
|
|
4755
4869
|
const { pointsPayment } = usePointsPayment(isWeb3Enabled ? "web3" : "web2");
|
|
4756
|
-
const handlePay = (0,
|
|
4870
|
+
const handlePay = (0, import_react16.useCallback)(
|
|
4757
4871
|
async (data) => {
|
|
4872
|
+
const pointsAmount = selectedPaymentMethod.pointsAmount ?? 0;
|
|
4873
|
+
const usdAmount = getSplitAmount(appProps.amount ?? 0, pointsAmount, spreePayConfig?.pointsConversionRatio);
|
|
4874
|
+
const isPurePoints = !usdAmount && pointsAmount > 0;
|
|
4875
|
+
const failureMessage = isPurePoints ? "Points payment failed" : "Card payment failed";
|
|
4876
|
+
const failureCode = isPurePoints ? "PAYMENT_ERROR" /* PAYMENT_ERROR */ : "CARD_ERROR" /* CARD_ERROR */;
|
|
4758
4877
|
try {
|
|
4759
|
-
let res
|
|
4760
|
-
const pointsAmount = selectedPaymentMethod.pointsAmount ?? 0;
|
|
4761
|
-
const usdAmount = getSplitAmount(appProps.amount ?? 0, pointsAmount, spreePayConfig?.pointsConversionRatio);
|
|
4878
|
+
let res;
|
|
4762
4879
|
if (usdAmount && pointsAmount) {
|
|
4763
4880
|
res = await splitPayment({ ...data, points: pointsAmount });
|
|
4764
|
-
} else if (
|
|
4881
|
+
} else if (isPurePoints) {
|
|
4765
4882
|
res = await pointsPayment({ ...data, points: pointsAmount });
|
|
4766
4883
|
} else {
|
|
4767
4884
|
res = await cardPayment(data);
|
|
4768
4885
|
}
|
|
4769
|
-
|
|
4770
|
-
|
|
4771
|
-
|
|
4772
|
-
return Promise.reject(new PaymentError("Card payment failed", res.status));
|
|
4773
|
-
} catch (_) {
|
|
4774
|
-
return Promise.reject(new PaymentError("Payment failed", "FAILED" /* FAILED */));
|
|
4886
|
+
return settlePaymentResult(res, failureMessage, failureCode);
|
|
4887
|
+
} catch (e) {
|
|
4888
|
+
return Promise.reject(toPaymentError(e, failureMessage, failureCode));
|
|
4775
4889
|
} finally {
|
|
4776
4890
|
mutateBalance();
|
|
4777
4891
|
if (selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && selectedPaymentMethod.method && isNewCard(selectedPaymentMethod.method)) {
|
|
@@ -4802,22 +4916,22 @@ var CreditCardTab = ({ isLoggedIn }) => {
|
|
|
4802
4916
|
mutateBalance
|
|
4803
4917
|
]
|
|
4804
4918
|
);
|
|
4805
|
-
(0,
|
|
4919
|
+
(0, import_react16.useEffect)(() => {
|
|
4806
4920
|
register(handlePay);
|
|
4807
4921
|
}, [register, handlePay]);
|
|
4808
|
-
return /* @__PURE__ */ (0,
|
|
4809
|
-
/* @__PURE__ */ (0,
|
|
4810
|
-
!spreePayConfig?.creditCard.hidePoints && /* @__PURE__ */ (0,
|
|
4811
|
-
/* @__PURE__ */ (0,
|
|
4922
|
+
return /* @__PURE__ */ (0, import_jsx_runtime29.jsxs)("div", { children: [
|
|
4923
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.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_runtime29.jsx)(CreditCard, { newCards, setNewCards }) }),
|
|
4924
|
+
!spreePayConfig?.creditCard.hidePoints && /* @__PURE__ */ (0, import_jsx_runtime29.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_runtime29.jsx)(Points, {}) }),
|
|
4925
|
+
/* @__PURE__ */ (0, import_jsx_runtime29.jsx)(CheckoutButton, {})
|
|
4812
4926
|
] });
|
|
4813
4927
|
};
|
|
4814
4928
|
|
|
4815
4929
|
// src/components/TabButtons.tsx
|
|
4816
4930
|
init_useSpreePayConfig();
|
|
4817
4931
|
init_utils();
|
|
4818
|
-
var
|
|
4932
|
+
var import_jsx_runtime30 = require("react/jsx-runtime");
|
|
4819
4933
|
var TabButton = ({ isDisabled = false, isActive, children, onClick }) => {
|
|
4820
|
-
return /* @__PURE__ */ (0,
|
|
4934
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4821
4935
|
"button",
|
|
4822
4936
|
{
|
|
4823
4937
|
disabled: isDisabled,
|
|
@@ -4840,38 +4954,38 @@ var TabButtons = (props) => {
|
|
|
4840
4954
|
onChange({ type, method: null });
|
|
4841
4955
|
}
|
|
4842
4956
|
};
|
|
4843
|
-
return /* @__PURE__ */ (0,
|
|
4844
|
-
configIsLoading && /* @__PURE__ */ (0,
|
|
4845
|
-
spreePayConfig?.creditCard.enabled && /* @__PURE__ */ (0,
|
|
4846
|
-
/* @__PURE__ */ (0,
|
|
4957
|
+
return /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("div", { className: "flex w-full gap-4 overflow-x-auto px-5 py-2 md:px-7", children: [
|
|
4958
|
+
configIsLoading && /* @__PURE__ */ (0, import_jsx_runtime30.jsx)("div", { className: "h-[74px] w-[180px] animate-pulse rounded-md bg-(--s-primary)" }),
|
|
4959
|
+
spreePayConfig?.creditCard.enabled && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(TabButton, { onClick: handleChange("CREDIT_CARD" /* CREDIT_CARD */), isActive: value === "CREDIT_CARD" /* CREDIT_CARD */, children: [
|
|
4960
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-8", viewBox: "0 0 32 32", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4847
4961
|
"path",
|
|
4848
4962
|
{
|
|
4849
4963
|
fill: "currentColor",
|
|
4850
4964
|
d: "M28 8.82v14.36q0 .92-.62 1.54-.6.6-1.53.61H6.15q-.91 0-1.53-.61A2 2 0 0 1 4 23.18V8.82q0-.92.62-1.54.6-.6 1.53-.61h19.7q.91 0 1.53.61.62.62.62 1.54M5.33 11.74h21.34V8.82q0-.31-.26-.56a.8.8 0 0 0-.56-.26H6.15q-.3 0-.56.26a.8.8 0 0 0-.26.56zm0 3.18v8.26q0 .31.26.56t.56.26h19.7q.3 0 .56-.26a.8.8 0 0 0 .26-.56v-8.26z"
|
|
4851
4965
|
}
|
|
4852
4966
|
) }),
|
|
4853
|
-
/* @__PURE__ */ (0,
|
|
4967
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "md:text-md text-sm font-medium", children: "Card" })
|
|
4854
4968
|
] }),
|
|
4855
|
-
spreePayConfig?.crypto.enabled && /* @__PURE__ */ (0,
|
|
4856
|
-
/* @__PURE__ */ (0,
|
|
4969
|
+
spreePayConfig?.crypto.enabled && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(TabButton, { onClick: handleChange("CRYPTO" /* CRYPTO */), isActive: value === "CRYPTO" /* CRYPTO */, children: [
|
|
4970
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "size-8", viewBox: "0 0 32 32", children: /* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4857
4971
|
"path",
|
|
4858
4972
|
{
|
|
4859
4973
|
fill: "currentColor",
|
|
4860
4974
|
d: "M21 9.86a8 8 0 0 1 3 5.43l-2.85-.71a5.4 5.4 0 0 0-3.86-3.67 5.3 5.3 0 0 0-6.46 3.8 5.3 5.3 0 0 0 3.91 6.4 5.4 5.4 0 0 0 5.14-1.43l2.85.7a8 8 0 0 1-5.2 3.39L16.72 27l-2.6-.65.64-2.57a8 8 0 0 1-1.3-.32l-.64 2.57-2.6-.65.82-3.24a7.9 7.9 0 0 1-2.8-8.08 7.9 7.9 0 0 1 6.27-5.82L15.32 5l2.6.64-.65 2.58q.67.1 1.3.32l.65-2.57 2.6.64z"
|
|
4861
4975
|
}
|
|
4862
4976
|
) }),
|
|
4863
|
-
/* @__PURE__ */ (0,
|
|
4977
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "md:text-md text-sm font-medium", children: "Crypto" })
|
|
4864
4978
|
] }),
|
|
4865
|
-
spreePayConfig?.cryptoCom.enabled && /* @__PURE__ */ (0,
|
|
4866
|
-
/* @__PURE__ */ (0,
|
|
4867
|
-
/* @__PURE__ */ (0,
|
|
4979
|
+
spreePayConfig?.cryptoCom.enabled && /* @__PURE__ */ (0, import_jsx_runtime30.jsxs)(TabButton, { onClick: handleChange("CDC" /* CDC */), isActive: value === "CDC" /* CDC */, children: [
|
|
4980
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsxs)("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", className: "h-8 w-11", viewBox: "0 0 44 32", children: [
|
|
4981
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4868
4982
|
"path",
|
|
4869
4983
|
{
|
|
4870
4984
|
fill: "currentColor",
|
|
4871
4985
|
d: "M17.6 11v10l-8.8 5L0 21V11l8.8-5zM2.2 16.69l3.15 5.42h1.26l1.5-1.37v-.7L6.56 18.6v-2.32L4.51 15zm8.87-.42v2.32l-1.55 1.46v.69l1.5 1.35h1.24l3.15-5.4-2.32-1.72zm-4.5-1.95.75 1.95-.23 2.17H8.8l1.72-.01-.21-2.17.74-1.94zm-1.25-4-.8 3.48h8.56l-.83-3.47z"
|
|
4872
4986
|
}
|
|
4873
4987
|
),
|
|
4874
|
-
/* @__PURE__ */ (0,
|
|
4988
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)(
|
|
4875
4989
|
"path",
|
|
4876
4990
|
{
|
|
4877
4991
|
fill: "#009fff",
|
|
@@ -4879,43 +4993,50 @@ var TabButtons = (props) => {
|
|
|
4879
4993
|
}
|
|
4880
4994
|
)
|
|
4881
4995
|
] }),
|
|
4882
|
-
/* @__PURE__ */ (0,
|
|
4996
|
+
/* @__PURE__ */ (0, import_jsx_runtime30.jsx)("p", { className: "md:text-md text-sm font-medium", children: "Crypto.com Pay" })
|
|
4883
4997
|
] })
|
|
4884
4998
|
] });
|
|
4885
4999
|
};
|
|
4886
5000
|
|
|
4887
5001
|
// src/SpreePayContent.tsx
|
|
5002
|
+
init_LoginStatusContext();
|
|
4888
5003
|
init_SpreePayActionsContext();
|
|
4889
|
-
var
|
|
4890
|
-
var CryptoTab2 = (0,
|
|
4891
|
-
var CryptoComTab2 = (0,
|
|
5004
|
+
var import_jsx_runtime46 = require("react/jsx-runtime");
|
|
5005
|
+
var CryptoTab2 = (0, import_react21.lazy)(() => Promise.resolve().then(() => (init_CryptoTab2(), CryptoTab_exports)).then((module2) => ({ default: module2.CryptoTab })));
|
|
5006
|
+
var CryptoComTab2 = (0, import_react21.lazy)(
|
|
4892
5007
|
() => Promise.resolve().then(() => (init_CryptoComTab2(), CryptoComTab_exports)).then((module2) => ({ default: module2.CryptoComTab }))
|
|
4893
5008
|
);
|
|
4894
|
-
var TabLoadingFallback = () => /* @__PURE__ */ (0,
|
|
4895
|
-
/* @__PURE__ */ (0,
|
|
4896
|
-
/* @__PURE__ */ (0,
|
|
5009
|
+
var TabLoadingFallback = () => /* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "flex items-center justify-center px-5 py-8 md:px-7", children: /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex flex-col items-center gap-3", children: [
|
|
5010
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("div", { className: "h-8 w-8 animate-spin rounded-full border-4 border-(--border-component-specific-card) border-t-(--brand-primary)" }),
|
|
5011
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("p", { className: "text-sm text-(--text-tertiary)", children: "Loading payment method..." })
|
|
4897
5012
|
] }) });
|
|
4898
|
-
var SpreePayContent = (
|
|
5013
|
+
var SpreePayContent = () => {
|
|
5014
|
+
const isLoggedIn = useIsLoggedIn();
|
|
4899
5015
|
const { selectedPaymentMethod, setSelectedPaymentMethod } = useSpreePaymentMethod();
|
|
4900
|
-
|
|
4901
|
-
|
|
4902
|
-
|
|
4903
|
-
|
|
5016
|
+
(0, import_react21.useEffect)(() => {
|
|
5017
|
+
if (!isLoggedIn) {
|
|
5018
|
+
setSelectedPaymentMethod({ type: "CREDIT_CARD" /* CREDIT_CARD */, method: null });
|
|
5019
|
+
}
|
|
5020
|
+
}, [isLoggedIn, setSelectedPaymentMethod]);
|
|
5021
|
+
return /* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "w-full overflow-hidden rounded-3xl border border-(--border-component-specific-card) bg-(--surface-component-specific-card-default-card) shadow-[0_6.25px_25px_0_var(--shadow-component-specific-card)]", children: [
|
|
5022
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)("div", { className: "flex w-full flex-col gap-2 border-b border-b-(--border-component-specific-card) pt-5 pb-3 md:pt-6 md:pb-5", children: [
|
|
5023
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)("h2", { className: "px-5 text-[28px] leading-8 font-medium text-(--brand-primary) md:px-7", children: "Choose a payment method" }),
|
|
5024
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsx)(TabButtons, { value: selectedPaymentMethod.type, onChange: setSelectedPaymentMethod })
|
|
4904
5025
|
] }),
|
|
4905
|
-
selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0,
|
|
4906
|
-
/* @__PURE__ */ (0,
|
|
4907
|
-
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0,
|
|
4908
|
-
selectedPaymentMethod.type === "CDC" /* CDC */ && /* @__PURE__ */ (0,
|
|
5026
|
+
selectedPaymentMethod.type === "CREDIT_CARD" /* CREDIT_CARD */ && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CreditCardTab, {}),
|
|
5027
|
+
/* @__PURE__ */ (0, import_jsx_runtime46.jsxs)(import_react21.Suspense, { fallback: /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(TabLoadingFallback, {}), children: [
|
|
5028
|
+
selectedPaymentMethod.type === "CRYPTO" /* CRYPTO */ && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CryptoTab2, {}),
|
|
5029
|
+
selectedPaymentMethod.type === "CDC" /* CDC */ && /* @__PURE__ */ (0, import_jsx_runtime46.jsx)(CryptoComTab2, {})
|
|
4909
5030
|
] })
|
|
4910
5031
|
] });
|
|
4911
5032
|
};
|
|
4912
5033
|
|
|
4913
5034
|
// src/components/ErrorBoundary.tsx
|
|
4914
|
-
var
|
|
5035
|
+
var import_react22 = require("react");
|
|
4915
5036
|
init_utils();
|
|
4916
5037
|
init_logger();
|
|
4917
|
-
var
|
|
4918
|
-
var ErrorBoundary = class extends
|
|
5038
|
+
var import_jsx_runtime47 = require("react/jsx-runtime");
|
|
5039
|
+
var ErrorBoundary = class extends import_react22.Component {
|
|
4919
5040
|
constructor(props) {
|
|
4920
5041
|
super(props);
|
|
4921
5042
|
this.state = { hasError: false, error: null };
|
|
@@ -4933,8 +5054,8 @@ var ErrorBoundary = class extends import_react21.Component {
|
|
|
4933
5054
|
if (this.props.fallback) {
|
|
4934
5055
|
return this.props.fallback;
|
|
4935
5056
|
}
|
|
4936
|
-
return /* @__PURE__ */ (0,
|
|
4937
|
-
/* @__PURE__ */ (0,
|
|
5057
|
+
return /* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: cn("sl-spreepay", this.props.className), children: /* @__PURE__ */ (0, import_jsx_runtime47.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: [
|
|
5058
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("div", { className: "mb-4 flex size-12 items-center justify-center rounded-full bg-(--s-warning-subtle)", children: /* @__PURE__ */ (0, import_jsx_runtime47.jsxs)(
|
|
4938
5059
|
"svg",
|
|
4939
5060
|
{
|
|
4940
5061
|
xmlns: "http://www.w3.org/2000/svg",
|
|
@@ -4946,14 +5067,14 @@ var ErrorBoundary = class extends import_react21.Component {
|
|
|
4946
5067
|
strokeLinejoin: "round",
|
|
4947
5068
|
className: "size-10 text-(--warning)",
|
|
4948
5069
|
children: [
|
|
4949
|
-
/* @__PURE__ */ (0,
|
|
4950
|
-
/* @__PURE__ */ (0,
|
|
4951
|
-
/* @__PURE__ */ (0,
|
|
5070
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("circle", { cx: "12", cy: "12", r: "10" }),
|
|
5071
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("line", { x1: "12", y1: "8", x2: "12", y2: "12" }),
|
|
5072
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("line", { x1: "12", y1: "16", x2: "12.01", y2: "16" })
|
|
4952
5073
|
]
|
|
4953
5074
|
}
|
|
4954
5075
|
) }),
|
|
4955
|
-
/* @__PURE__ */ (0,
|
|
4956
|
-
/* @__PURE__ */ (0,
|
|
5076
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.jsx)("h3", { className: "mb-2 text-lg font-semibold text-(--brand-primary)", children: "Payment Widget Error" }),
|
|
5077
|
+
/* @__PURE__ */ (0, import_jsx_runtime47.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." })
|
|
4957
5078
|
] }) });
|
|
4958
5079
|
}
|
|
4959
5080
|
return this.props.children;
|
|
@@ -4961,27 +5082,28 @@ var ErrorBoundary = class extends import_react21.Component {
|
|
|
4961
5082
|
};
|
|
4962
5083
|
|
|
4963
5084
|
// src/SpreePay.tsx
|
|
5085
|
+
init_LoginStatusContext();
|
|
4964
5086
|
init_SpreePayActionsContext();
|
|
4965
5087
|
init_StaticConfigContext();
|
|
4966
5088
|
init_client();
|
|
4967
5089
|
|
|
4968
5090
|
// src/hooks/useKeycloakSSO.ts
|
|
4969
|
-
var
|
|
5091
|
+
var import_react23 = require("react");
|
|
4970
5092
|
var import_keycloak_js = __toESM(require("keycloak-js"), 1);
|
|
4971
5093
|
init_logger();
|
|
4972
5094
|
var refreshAheadSeconds = 60;
|
|
4973
5095
|
var keycloakLogger = logger.child("keycloak");
|
|
4974
5096
|
function useKeycloakSSO(config2) {
|
|
4975
5097
|
const { url, realm, clientId, ssoPageURI, enabled } = config2;
|
|
4976
|
-
const initRef = (0,
|
|
4977
|
-
const kcRef = (0,
|
|
4978
|
-
const refreshTimerRef = (0,
|
|
4979
|
-
const scheduleRefreshRef = (0,
|
|
5098
|
+
const initRef = (0, import_react23.useRef)(false);
|
|
5099
|
+
const kcRef = (0, import_react23.useRef)(null);
|
|
5100
|
+
const refreshTimerRef = (0, import_react23.useRef)(null);
|
|
5101
|
+
const scheduleRefreshRef = (0, import_react23.useRef)(() => {
|
|
4980
5102
|
});
|
|
4981
|
-
const [error, setError] = (0,
|
|
4982
|
-
const [isChecking, setIsChecking] = (0,
|
|
4983
|
-
const [accessToken, setAccessToken] = (0,
|
|
4984
|
-
const scheduleRefresh = (0,
|
|
5103
|
+
const [error, setError] = (0, import_react23.useState)(null);
|
|
5104
|
+
const [isChecking, setIsChecking] = (0, import_react23.useState)(enabled);
|
|
5105
|
+
const [accessToken, setAccessToken] = (0, import_react23.useState)(null);
|
|
5106
|
+
const scheduleRefresh = (0, import_react23.useCallback)(() => {
|
|
4985
5107
|
const kc = kcRef.current;
|
|
4986
5108
|
if (!kc || !kc.tokenParsed || !kc.tokenParsed.exp) {
|
|
4987
5109
|
return;
|
|
@@ -5005,10 +5127,10 @@ function useKeycloakSSO(config2) {
|
|
|
5005
5127
|
});
|
|
5006
5128
|
}, delayMs);
|
|
5007
5129
|
}, []);
|
|
5008
|
-
(0,
|
|
5130
|
+
(0, import_react23.useEffect)(() => {
|
|
5009
5131
|
scheduleRefreshRef.current = scheduleRefresh;
|
|
5010
5132
|
}, [scheduleRefresh]);
|
|
5011
|
-
(0,
|
|
5133
|
+
(0, import_react23.useEffect)(() => {
|
|
5012
5134
|
if (initRef.current || !enabled) return;
|
|
5013
5135
|
initRef.current = true;
|
|
5014
5136
|
const kc = new import_keycloak_js.default({ url, realm, clientId });
|
|
@@ -5058,16 +5180,17 @@ var isTokenExpired = (token) => {
|
|
|
5058
5180
|
};
|
|
5059
5181
|
|
|
5060
5182
|
// src/SpreePay.tsx
|
|
5061
|
-
var
|
|
5183
|
+
var import_jsx_runtime48 = require("react/jsx-runtime");
|
|
5184
|
+
var unauthenticatedFetcher = () => Promise.resolve(null);
|
|
5062
5185
|
var SpreePayInner = () => {
|
|
5063
|
-
const [portalEl, setPortalEl] = (0,
|
|
5064
|
-
const rootRef = (0,
|
|
5186
|
+
const [portalEl, setPortalEl] = (0, import_react24.useState)(null);
|
|
5187
|
+
const rootRef = (0, import_react24.useCallback)((node) => {
|
|
5065
5188
|
if (!node) return;
|
|
5066
5189
|
const el = node.querySelector(":scope > .sl-spreepay__portal");
|
|
5067
5190
|
setPortalEl(el ?? null);
|
|
5068
5191
|
}, []);
|
|
5069
5192
|
const { environment, tenantId, keycloakClientId, accessToken: envAccessToken, ssoPageURI } = useSpreePayEnv();
|
|
5070
|
-
(0,
|
|
5193
|
+
(0, import_react24.useEffect)(() => {
|
|
5071
5194
|
configureLogger({ environment });
|
|
5072
5195
|
logger.logVersion();
|
|
5073
5196
|
}, [environment]);
|
|
@@ -5081,8 +5204,7 @@ var SpreePayInner = () => {
|
|
|
5081
5204
|
enabled: !envTokenValid
|
|
5082
5205
|
});
|
|
5083
5206
|
const _accessToken = envTokenValid ? envAccessToken : accessToken;
|
|
5084
|
-
const
|
|
5085
|
-
const slapiFetcher = (0, import_react23.useMemo)(() => {
|
|
5207
|
+
const slapiFetcher = (0, import_react24.useMemo)(() => {
|
|
5086
5208
|
if (_accessToken) {
|
|
5087
5209
|
return registerApi({
|
|
5088
5210
|
accessToken: _accessToken,
|
|
@@ -5091,15 +5213,15 @@ var SpreePayInner = () => {
|
|
|
5091
5213
|
});
|
|
5092
5214
|
}
|
|
5093
5215
|
return unauthenticatedFetcher;
|
|
5094
|
-
}, [_accessToken, staticConfig, tenantId
|
|
5216
|
+
}, [_accessToken, staticConfig, tenantId]);
|
|
5095
5217
|
const getContent = () => {
|
|
5096
5218
|
if (isChecking) {
|
|
5097
|
-
return /* @__PURE__ */ (0,
|
|
5098
|
-
/* @__PURE__ */ (0,
|
|
5099
|
-
/* @__PURE__ */ (0,
|
|
5219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { className: "flex w-full flex-col", children: [
|
|
5220
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "mb-4 h-[315px] animate-pulse rounded-3xl bg-(--s-primary)" }),
|
|
5221
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "h-[135px] animate-pulse rounded-3xl bg-(--s-primary)" })
|
|
5100
5222
|
] });
|
|
5101
5223
|
}
|
|
5102
|
-
return /* @__PURE__ */ (0,
|
|
5224
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(
|
|
5103
5225
|
import_swr5.SWRConfig,
|
|
5104
5226
|
{
|
|
5105
5227
|
value: {
|
|
@@ -5108,40 +5230,46 @@ var SpreePayInner = () => {
|
|
|
5108
5230
|
revalidateOnFocus: false,
|
|
5109
5231
|
revalidateIfStale: false
|
|
5110
5232
|
},
|
|
5111
|
-
children: /* @__PURE__ */ (0,
|
|
5233
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(PortalContainerProvider, { container: portalEl, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(import_nice_modal_react9.default.Provider, { children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(LoginStatusProvider, { isLoggedIn: Boolean(_accessToken), children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SpreePayContent, {}) }) }) })
|
|
5112
5234
|
}
|
|
5113
5235
|
);
|
|
5114
5236
|
};
|
|
5115
|
-
return /* @__PURE__ */ (0,
|
|
5116
|
-
/* @__PURE__ */ (0,
|
|
5237
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsxs)("div", { ref: rootRef, className: cn("sl-spreepay", appProps.className), children: [
|
|
5238
|
+
/* @__PURE__ */ (0, import_jsx_runtime48.jsx)("div", { className: "sl-spreepay__portal" }),
|
|
5117
5239
|
getContent()
|
|
5118
5240
|
] });
|
|
5119
5241
|
};
|
|
5120
5242
|
var SpreePay = (props) => {
|
|
5121
|
-
return /* @__PURE__ */ (0,
|
|
5243
|
+
return /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(ErrorBoundary, { className: props.className, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(StaticConfigProvider, { props, children: /* @__PURE__ */ (0, import_jsx_runtime48.jsx)(SpreePayInner, {}) }) });
|
|
5122
5244
|
};
|
|
5123
5245
|
|
|
5124
5246
|
// src/hooks/useCapture3DS.ts
|
|
5125
|
-
var
|
|
5126
|
-
var useCapture3DS = (
|
|
5127
|
-
(0,
|
|
5128
|
-
if (typeof window !== "undefined" && window.parent &&
|
|
5129
|
-
window.parent.SP_EVENT_BUS?.emit("paymentIntent", { paymentIntent
|
|
5247
|
+
var import_react25 = require("react");
|
|
5248
|
+
var useCapture3DS = ({ paymentIntent }) => {
|
|
5249
|
+
(0, import_react25.useEffect)(() => {
|
|
5250
|
+
if (typeof window !== "undefined" && window.parent && paymentIntent) {
|
|
5251
|
+
window.parent.SP_EVENT_BUS?.emit("paymentIntent", { paymentIntent });
|
|
5130
5252
|
}
|
|
5131
|
-
}, [
|
|
5253
|
+
}, [paymentIntent]);
|
|
5132
5254
|
};
|
|
5133
5255
|
|
|
5134
5256
|
// src/index.ts
|
|
5135
5257
|
init_SpreePayActionsContext();
|
|
5136
5258
|
init_payments();
|
|
5259
|
+
init_errors();
|
|
5137
5260
|
init_logger();
|
|
5138
5261
|
// Annotate the CommonJS export names for ESM import in node:
|
|
5139
5262
|
0 && (module.exports = {
|
|
5140
5263
|
LogLevel,
|
|
5264
|
+
PaymentError,
|
|
5265
|
+
PaymentErrorCode,
|
|
5266
|
+
PaymentStatus,
|
|
5141
5267
|
PaymentType,
|
|
5142
5268
|
SpreePay,
|
|
5269
|
+
SpreePayHttpError,
|
|
5143
5270
|
SpreePayProvider,
|
|
5144
5271
|
configureLogger,
|
|
5272
|
+
isPaymentError,
|
|
5145
5273
|
logger,
|
|
5146
5274
|
useCapture3DS,
|
|
5147
5275
|
useSpreePay
|