@loczer/storefront-sdk 0.202.0 → 0.204.0
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/dist/index.d.ts +7 -1
- package/dist/lib/cart.d.ts +3 -0
- package/dist/lib/cart.d.ts.map +1 -1
- package/dist/lib/cart.js +114 -76
- package/dist/lib/checkoutPaymentSession.d.ts +1 -0
- package/dist/lib/checkoutPaymentSession.d.ts.map +1 -1
- package/dist/lib/checkoutPaymentSession.js +1 -0
- package/dist/lib/checkoutSubmit.d.ts +2 -0
- package/dist/lib/checkoutSubmit.d.ts.map +1 -1
- package/dist/lib/checkoutSubmit.js +1 -0
- package/dist/lib/storefrontImage.d.ts +2 -1
- package/dist/lib/storefrontImage.d.ts.map +1 -1
- package/dist/lib/storefrontImage.js +13 -7
- package/dist/pages/CheckoutPage.d.ts.map +1 -1
- package/dist/pages/CheckoutPage.js +222 -211
- package/dist/pages/CheckoutPaymentPage.d.ts.map +1 -1
- package/dist/pages/CheckoutPaymentPage.js +190 -159
- package/dist/pages/HomePage.d.ts.map +1 -1
- package/dist/pages/HomePage.js +227 -226
- package/dist/storefront.css +1 -1
- package/dist/ui/day-picker.js +1 -1
- package/package.json +1 -1
|
@@ -16,14 +16,14 @@ import { CheckoutPaymentSummaryCard as be } from "./checkout/components/Checkout
|
|
|
16
16
|
import { CheckoutInsuranceCard as xe } from "./checkout/components/CheckoutInsuranceCard.js";
|
|
17
17
|
import { CheckoutSummaryColumn as Se } from "./checkout/components/CheckoutSummaryColumn.js";
|
|
18
18
|
import { checkoutFormSchema as Ce } from "./checkout/types.js";
|
|
19
|
-
import { useEffect as s, useMemo as c, useState as l } from "react";
|
|
19
|
+
import { useEffect as s, useMemo as c, useRef as we, useState as l } from "react";
|
|
20
20
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
21
|
-
import { Link as
|
|
22
|
-
import { useTranslation as
|
|
23
|
-
import { ArrowLeft as
|
|
24
|
-
import { useForm as
|
|
21
|
+
import { Link as Te, useNavigate as Ee, useParams as De, useSearchParams as Oe } from "@rpcbase/router";
|
|
22
|
+
import { useTranslation as ke } from "react-i18next";
|
|
23
|
+
import { ArrowLeft as Ae } from "lucide-react";
|
|
24
|
+
import { useForm as je, zodResolver as Me } from "@rpcbase/form";
|
|
25
25
|
//#region src/pages/CheckoutPage.tsx
|
|
26
|
-
var
|
|
26
|
+
var Ne = .2, Pe = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), f = (e, t, n) => {
|
|
27
27
|
try {
|
|
28
28
|
return new Intl.NumberFormat(n, {
|
|
29
29
|
style: "currency",
|
|
@@ -32,7 +32,7 @@ var Me = .2, Ne = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), f = (e,
|
|
|
32
32
|
} catch {
|
|
33
33
|
return `${(e / 100).toFixed(2)} ${t.toUpperCase()}`;
|
|
34
34
|
}
|
|
35
|
-
},
|
|
35
|
+
}, Fe = (e, t) => {
|
|
36
36
|
try {
|
|
37
37
|
return new Intl.NumberFormat(t, {
|
|
38
38
|
style: "percent",
|
|
@@ -42,7 +42,7 @@ var Me = .2, Ne = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), f = (e,
|
|
|
42
42
|
} catch {
|
|
43
43
|
return `${Math.round(e * 100)}%`;
|
|
44
44
|
}
|
|
45
|
-
},
|
|
45
|
+
}, Ie = (e, t, n) => {
|
|
46
46
|
let r = {
|
|
47
47
|
dateStyle: "medium",
|
|
48
48
|
timeStyle: "short"
|
|
@@ -56,101 +56,111 @@ var Me = .2, Ne = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), f = (e,
|
|
|
56
56
|
return new Intl.DateTimeFormat(t, r).format(e);
|
|
57
57
|
};
|
|
58
58
|
function p() {
|
|
59
|
-
let { t: p, i18n: m } =
|
|
60
|
-
let e = r(
|
|
59
|
+
let { t: p, i18n: m } = ke(), { storefrontConfiguration: h } = me(), Le = h.workspace?.workspaceLanguage, { bikes: g, accessories: Re } = he(), { storeSlug: _ } = De(), [v, ze] = Oe(), Be = Ee(), { items: Ve, itemCount: He, checkoutSessionId: y, setQuantity: Ue, removeItem: We, ensureCheckoutSessionId: Ge, clearCheckoutSession: Ke, clear: qe } = te(), [b, Je] = l(!1), Ye = we(!1), [x, S] = l(null), [Xe, Ze] = l(!1), [Qe, C] = l(null), $e = v.get("coupon") ?? v.get("code") ?? "", [et, w] = l($e), [tt, nt] = l($e.trim()), [T, E] = l(null), [D, O] = l(null), [k, A] = l(!1), [rt, j] = l(null), [it, M] = l(null), [N, at] = l(!1), [P, ot] = l(!1), st = c(() => i(v, _), [v, _]), F = h.settings.fulfillmentModes.includes("delivery"), ct = h.settings.deliveryDisabledReason.trim(), lt = F || ct.length > 0, ut = h.shop.address?.trim() ?? "", I = c(() => {
|
|
60
|
+
let e = r(st, {
|
|
61
61
|
start_time: "",
|
|
62
62
|
end_time: ""
|
|
63
63
|
});
|
|
64
|
-
return e.fulfillment === "delivery" && !
|
|
64
|
+
return e.fulfillment === "delivery" && !F ? {
|
|
65
65
|
...e,
|
|
66
66
|
fulfillment: "pickup"
|
|
67
67
|
} : e;
|
|
68
|
-
}, [
|
|
68
|
+
}, [st, F]), L = c(() => ue(I), [I]), dt = c(() => t(I), [I]), ft = c(() => n(I), [I]), pt = c(() => Pe(ft), [ft]), R = c(() => ne({
|
|
69
69
|
items: Ve,
|
|
70
70
|
language: m.language,
|
|
71
|
-
fallbackLanguage:
|
|
71
|
+
fallbackLanguage: Le,
|
|
72
72
|
products: {
|
|
73
|
-
bikes:
|
|
73
|
+
bikes: g,
|
|
74
74
|
accessories: Re
|
|
75
75
|
},
|
|
76
|
-
estimatedDays:
|
|
76
|
+
estimatedDays: pt
|
|
77
77
|
}), [
|
|
78
78
|
Re,
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
g,
|
|
80
|
+
pt,
|
|
81
81
|
m.language,
|
|
82
82
|
Ve,
|
|
83
|
-
|
|
84
|
-
]),
|
|
83
|
+
Le
|
|
84
|
+
]), z = c(() => R.lines.map((e) => ({
|
|
85
85
|
productId: e.checkoutProductId,
|
|
86
86
|
productVariantId: e.productVariantId,
|
|
87
87
|
quantity: e.quantity
|
|
88
|
-
})), [
|
|
88
|
+
})), [R.lines]), [mt, B] = l([]), [ht, V] = l(!1);
|
|
89
89
|
s(() => {
|
|
90
|
-
if (!
|
|
91
|
-
|
|
90
|
+
if (!_ || z.length === 0) {
|
|
91
|
+
B([]), V(!1);
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
if (!
|
|
95
|
-
|
|
94
|
+
if (!L) {
|
|
95
|
+
B([]), V(!1);
|
|
96
96
|
return;
|
|
97
97
|
}
|
|
98
98
|
let e = !1;
|
|
99
|
-
return
|
|
99
|
+
return V(!0), B([]), (async () => {
|
|
100
100
|
try {
|
|
101
101
|
let t = await o(se, {
|
|
102
|
-
storeSlug:
|
|
103
|
-
schedule:
|
|
104
|
-
products:
|
|
102
|
+
storeSlug: _,
|
|
103
|
+
schedule: L,
|
|
104
|
+
products: z
|
|
105
105
|
}), n = de.parse(t);
|
|
106
106
|
if (e) return;
|
|
107
|
-
|
|
107
|
+
B(n.success ? n.availability ?? [] : []);
|
|
108
108
|
} catch (t) {
|
|
109
109
|
if (e) return;
|
|
110
|
-
console.error("Failed to load checkout cart availability", t),
|
|
110
|
+
console.error("Failed to load checkout cart availability", t), B([]);
|
|
111
111
|
} finally {
|
|
112
|
-
e ||
|
|
112
|
+
e || V(!1);
|
|
113
113
|
}
|
|
114
114
|
})(), () => {
|
|
115
115
|
e = !0;
|
|
116
116
|
};
|
|
117
117
|
}, [
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
118
|
+
I.end_date,
|
|
119
|
+
I.end_time,
|
|
120
|
+
I.start_date,
|
|
121
|
+
I.start_time,
|
|
122
|
+
L,
|
|
123
|
+
z,
|
|
124
|
+
_
|
|
125
125
|
]);
|
|
126
|
-
let
|
|
127
|
-
...
|
|
128
|
-
lines:
|
|
129
|
-
let t =
|
|
126
|
+
let gt = c(() => new Map(mt.map((e) => [ce(e.productId, e.productVariantId), e])), [mt]), H = c(() => ({
|
|
127
|
+
...R,
|
|
128
|
+
lines: R.lines.map((e) => {
|
|
129
|
+
let t = gt.get(ce(e.checkoutProductId, e.productVariantId)), n = t ? le(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
|
|
130
130
|
return {
|
|
131
131
|
...e,
|
|
132
|
-
insufficientCapacity: !
|
|
133
|
-
availabilityIssue:
|
|
132
|
+
insufficientCapacity: !ht && n !== void 0,
|
|
133
|
+
availabilityIssue: ht ? void 0 : n
|
|
134
134
|
};
|
|
135
135
|
})
|
|
136
136
|
}), [
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
]),
|
|
137
|
+
gt,
|
|
138
|
+
ht,
|
|
139
|
+
R
|
|
140
|
+
]), U = c(() => R.lines.map((e) => ({
|
|
141
141
|
kind: e.kind,
|
|
142
142
|
productId: e.checkoutProductId,
|
|
143
143
|
productVariantId: e.productVariantId,
|
|
144
144
|
quantity: e.quantity
|
|
145
|
-
})), [
|
|
146
|
-
let t =
|
|
145
|
+
})), [R.lines]), _t = new Map(g.map((e) => [e.checkoutProductId?.trim() || e.id, e])), W = R.lines.flatMap((e) => {
|
|
146
|
+
let t = _t.get(e.checkoutProductId);
|
|
147
147
|
return t?.insurance?.enabled ? [{
|
|
148
148
|
quantity: e.quantity,
|
|
149
149
|
pricePerDayMinor: t.insurance.pricePerDayMinor,
|
|
150
150
|
deductibleAmountMinor: t.insurance.deductibleAmountMinor
|
|
151
151
|
}] : [];
|
|
152
|
-
}),
|
|
153
|
-
|
|
152
|
+
}), G = h.modules?.insurance?.enabled === !0 && W.length > 0, K = G && P, vt = W.reduce((e, t) => e + t.pricePerDayMinor * t.quantity, 0), yt = W.reduce((e, t) => Math.max(e, t.deductibleAmountMinor), 0), bt = R.estimatedTotalMinor ?? R.totalPerDayMinor, q = D?.totalMinor ?? bt, J = T?.discountAmountMinor ?? 0, Y = e(new URLSearchParams(), I).toString(), xt = `/${_ ?? ""}/booking${Y ? `?${Y}` : ""}`, St = `/${_ ?? ""}/checkout${Y ? `?${Y}` : ""}`, Ct = new URLSearchParams(Y);
|
|
153
|
+
y && Ct.set("checkout_session_id", y);
|
|
154
|
+
let wt = y ? `/${_ ?? ""}/checkout/payment?${Ct.toString()}` : null;
|
|
155
|
+
s(() => {
|
|
156
|
+
!_ || !wt || Ye.current || Be(wt, { replace: !0 });
|
|
157
|
+
}, [
|
|
158
|
+
wt,
|
|
159
|
+
Be,
|
|
160
|
+
_
|
|
161
|
+
]);
|
|
162
|
+
let Tt = je({
|
|
163
|
+
resolver: Me(Ce),
|
|
154
164
|
defaultValues: {
|
|
155
165
|
first_name: "",
|
|
156
166
|
last_name: "",
|
|
@@ -160,157 +170,158 @@ function p() {
|
|
|
160
170
|
}
|
|
161
171
|
});
|
|
162
172
|
s(() => {
|
|
163
|
-
ee(
|
|
164
|
-
}, [
|
|
165
|
-
!
|
|
166
|
-
}, [
|
|
167
|
-
let
|
|
173
|
+
ee(_, I);
|
|
174
|
+
}, [I, _]), s(() => {
|
|
175
|
+
!G && P && ot(!1);
|
|
176
|
+
}, [P, G]);
|
|
177
|
+
let Et = (t) => {
|
|
168
178
|
let n = {
|
|
169
|
-
...
|
|
179
|
+
...I,
|
|
170
180
|
...t
|
|
171
|
-
}, r = e(
|
|
172
|
-
ze(r, { replace: !0 }), ee(
|
|
181
|
+
}, r = e(v, n);
|
|
182
|
+
ze(r, { replace: !0 }), ee(_, r);
|
|
173
183
|
};
|
|
174
184
|
s(() => {
|
|
175
|
-
if (!
|
|
176
|
-
|
|
185
|
+
if (!_ || U.length === 0 || !L) {
|
|
186
|
+
E(null), O(null), A(!1), j(null), M(null);
|
|
177
187
|
return;
|
|
178
188
|
}
|
|
179
|
-
let e =
|
|
180
|
-
return
|
|
189
|
+
let e = tt.trim(), t = e.length === 0 && !N, n = !1;
|
|
190
|
+
return A(!0), M(null), j(null), (async () => {
|
|
181
191
|
try {
|
|
182
192
|
let r = await o(_e, {
|
|
183
|
-
storeSlug:
|
|
184
|
-
schedule:
|
|
185
|
-
items:
|
|
193
|
+
storeSlug: _,
|
|
194
|
+
schedule: L,
|
|
195
|
+
items: U,
|
|
186
196
|
couponCode: e || void 0,
|
|
187
197
|
includeAutoApply: t,
|
|
188
|
-
insuranceAccepted:
|
|
198
|
+
insuranceAccepted: K
|
|
189
199
|
}), i = ve.parse(r);
|
|
190
200
|
if (n) return;
|
|
191
|
-
if (
|
|
201
|
+
if (O(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
|
|
192
202
|
subtotalMinor: i.subtotalMinor,
|
|
193
203
|
totalMinor: i.totalMinor,
|
|
194
204
|
lateReturnSurchargeMinor: i.lateReturnSurchargeMinor,
|
|
195
205
|
insuranceSubtotalMinor: i.insuranceSubtotalMinor,
|
|
196
206
|
insuranceBillableDays: i.insuranceBillableDays
|
|
197
207
|
} : null), !i.success) {
|
|
198
|
-
|
|
208
|
+
E(null), M(i.message || p("checkout_coupon_invalid"));
|
|
199
209
|
return;
|
|
200
210
|
}
|
|
201
|
-
|
|
211
|
+
E(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (w(i.coupon.code), j(p("checkout_coupon_auto_applied", { code: i.coupon.code }))) : j(p("checkout_coupon_manual_applied")));
|
|
202
212
|
} catch (e) {
|
|
203
213
|
if (n) return;
|
|
204
|
-
console.error("Failed to verify checkout coupon", e),
|
|
214
|
+
console.error("Failed to verify checkout coupon", e), E(null), O(null), M(p("checkout_coupon_error"));
|
|
205
215
|
} finally {
|
|
206
|
-
n ||
|
|
216
|
+
n || A(!1);
|
|
207
217
|
}
|
|
208
218
|
})(), () => {
|
|
209
219
|
n = !0;
|
|
210
220
|
};
|
|
211
221
|
}, [
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
+
N,
|
|
223
|
+
I.end_date,
|
|
224
|
+
I.end_time,
|
|
225
|
+
I.start_date,
|
|
226
|
+
I.start_time,
|
|
227
|
+
L,
|
|
228
|
+
U,
|
|
229
|
+
K,
|
|
230
|
+
_,
|
|
231
|
+
tt,
|
|
222
232
|
p
|
|
223
233
|
]), s(() => {
|
|
224
|
-
if (!
|
|
225
|
-
|
|
234
|
+
if (!_ || R.lines.length === 0 || !L) {
|
|
235
|
+
S(null), C(null), Ze(!1);
|
|
226
236
|
return;
|
|
227
237
|
}
|
|
228
238
|
let e = !1;
|
|
229
|
-
return
|
|
239
|
+
return Ze(!0), C(null), (async () => {
|
|
230
240
|
try {
|
|
231
241
|
let t = await o(re, {
|
|
232
|
-
storeSlug:
|
|
233
|
-
schedule:
|
|
234
|
-
estimatedTotalMinor:
|
|
242
|
+
storeSlug: _,
|
|
243
|
+
schedule: L,
|
|
244
|
+
estimatedTotalMinor: q
|
|
235
245
|
}), n = ie.parse(t);
|
|
236
246
|
if (e) return;
|
|
237
247
|
if (!n.success || !n.decision) {
|
|
238
|
-
|
|
248
|
+
S(null), C(n.errorCode === "online_payment_provider_missing" ? p("checkout_payment_error") : n.message || p("checkout_payment_error"));
|
|
239
249
|
return;
|
|
240
250
|
}
|
|
241
|
-
|
|
251
|
+
S(n.decision);
|
|
242
252
|
} catch (t) {
|
|
243
253
|
if (e) return;
|
|
244
|
-
console.error("Failed to load checkout payment decision", t),
|
|
254
|
+
console.error("Failed to load checkout payment decision", t), S(null), C(p("checkout_payment_error"));
|
|
245
255
|
} finally {
|
|
246
|
-
e ||
|
|
256
|
+
e || Ze(!1);
|
|
247
257
|
}
|
|
248
258
|
})(), () => {
|
|
249
259
|
e = !0;
|
|
250
260
|
};
|
|
251
261
|
}, [
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
262
|
+
I.end_date,
|
|
263
|
+
I.end_time,
|
|
264
|
+
I.start_date,
|
|
265
|
+
I.start_time,
|
|
266
|
+
L,
|
|
267
|
+
q,
|
|
268
|
+
R.lines.length,
|
|
269
|
+
_,
|
|
260
270
|
p
|
|
261
271
|
]);
|
|
262
|
-
let
|
|
263
|
-
if (!
|
|
264
|
-
let e = new Date(
|
|
265
|
-
return Number.isNaN(e.getTime()) ? null :
|
|
272
|
+
let X = x?.currency ?? "EUR", Dt = f(q, X, m.language), Ot = J > 0 ? `-${f(J, X, m.language)}` : null, Z = D?.insuranceSubtotalMinor ?? 0, kt = Math.max(0, q - Z), At = Math.round(kt / 1.2), jt = At + Z, Mt = Math.max(0, kt - At), Nt = f(jt, X, m.language), Pt = f(Mt, X, m.language), Ft = Fe(Ne, m.language), It = Z > 0 ? f(Z, X, m.language) : void 0, Q = x?.amountToCollectMinor ?? 0, Lt = f(Q, X, m.language), Rt = x?.paymentMode === "deposit" && Q > 0 ? f(Q, X, m.language) : null, zt = x?.shouldCollectOnlinePayment === !0 && Q > 0, Bt = h.shop.timeZone?.trim() || void 0, $ = c(() => x ? Fe(Math.max(0, Math.min(1, x.bookingDepositPercentage)), m.language) : null, [m.language, x]), Vt = c(() => {
|
|
273
|
+
if (!x?.depositRefundableUntilIso) return null;
|
|
274
|
+
let e = new Date(x.depositRefundableUntilIso);
|
|
275
|
+
return Number.isNaN(e.getTime()) ? null : Ie(e, m.language, Bt);
|
|
266
276
|
}, [
|
|
267
277
|
m.language,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
]),
|
|
271
|
-
percent:
|
|
272
|
-
date:
|
|
273
|
-
}) : p("checkout_payment_due_now_helper_deposit", { percent:
|
|
274
|
-
Z,
|
|
278
|
+
x?.depositRefundableUntilIso,
|
|
279
|
+
Bt
|
|
280
|
+
]), Ht = c(() => x ? x.paymentMode === "deposit" && Q > 0 && $ ? Vt ? p("checkout_payment_due_now_helper_deposit_refundable_until", {
|
|
281
|
+
percent: $,
|
|
282
|
+
date: Vt
|
|
283
|
+
}) : p("checkout_payment_due_now_helper_deposit", { percent: $ }) : x.paymentMode === "none" || Q <= 0 ? p("checkout_payment_due_now_helper_none") : null : null, [
|
|
275
284
|
Q,
|
|
276
285
|
$,
|
|
277
|
-
|
|
286
|
+
Vt,
|
|
287
|
+
x,
|
|
278
288
|
p
|
|
279
|
-
]),
|
|
280
|
-
if (!
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
} catch (e) {
|
|
307
|
-
console.error("Failed to submit storefront checkout", e), a.error(p("checkout_payment_error"));
|
|
308
|
-
} finally {
|
|
309
|
-
Ke(!1);
|
|
289
|
+
]), Ut = Tt.handleSubmit(async (e) => {
|
|
290
|
+
if (!_ || U.length === 0 || !L) return;
|
|
291
|
+
Je(!0), Ye.current = !0;
|
|
292
|
+
let t = Ge();
|
|
293
|
+
try {
|
|
294
|
+
let n = await o(ae, {
|
|
295
|
+
storeSlug: _,
|
|
296
|
+
checkoutSessionId: t,
|
|
297
|
+
schedule: L,
|
|
298
|
+
fulfillment: I.fulfillment,
|
|
299
|
+
startAddress: I.fulfillment === "delivery" ? I.start_address : void 0,
|
|
300
|
+
endAddress: I.fulfillment === "delivery" ? I.end_address : void 0,
|
|
301
|
+
couponCode: T?.code,
|
|
302
|
+
couponAutoApplied: !N && T?.autoApplied,
|
|
303
|
+
insuranceAccepted: K,
|
|
304
|
+
customer: {
|
|
305
|
+
firstName: e.first_name,
|
|
306
|
+
lastName: e.last_name,
|
|
307
|
+
email: e.email,
|
|
308
|
+
phone: e.phone,
|
|
309
|
+
notes: e.notes
|
|
310
|
+
},
|
|
311
|
+
items: U
|
|
312
|
+
}), r = oe.parse(n);
|
|
313
|
+
if (!r.success || !r.checkout) {
|
|
314
|
+
Ke(), a.error(r.errorCode === "online_payment_provider_missing" ? p("checkout_payment_error") : r.message || p("checkout_payment_error"));
|
|
315
|
+
return;
|
|
310
316
|
}
|
|
317
|
+
r.checkout.requiresPayment || a.success(p("checkout_success_toast")), await Be(r.checkout.nextPath), r.checkout.requiresPayment || qe();
|
|
318
|
+
} catch (e) {
|
|
319
|
+
console.error("Failed to submit storefront checkout", e), a.error(p("checkout_payment_error"));
|
|
320
|
+
} finally {
|
|
321
|
+
Ye.current = !1, Je(!1);
|
|
311
322
|
}
|
|
312
|
-
}),
|
|
313
|
-
return
|
|
323
|
+
}), Wt = p(zt ? "checkout_continue_to_payment" : "checkout_submit"), Gt = I.fulfillment === "delivery" && I.start_address.trim().length === 0, Kt = !b && !Xe && !Qe && !k && !it && !!x && !!L && !Gt && U.length > 0;
|
|
324
|
+
return R.lines.length === 0 ? /* @__PURE__ */ u("div", {
|
|
314
325
|
className: "mx-auto max-w-3xl px-4 py-10 sm:px-6",
|
|
315
326
|
children: /* @__PURE__ */ d("div", {
|
|
316
327
|
className: "rounded-xl border border-slate-200 bg-white p-4 shadow-sm",
|
|
@@ -325,11 +336,11 @@ function p() {
|
|
|
325
336
|
}),
|
|
326
337
|
/* @__PURE__ */ u("div", {
|
|
327
338
|
className: "mt-6",
|
|
328
|
-
children: /* @__PURE__ */ u(
|
|
329
|
-
to:
|
|
339
|
+
children: /* @__PURE__ */ u(Te, {
|
|
340
|
+
to: xt,
|
|
330
341
|
children: /* @__PURE__ */ d(fe, {
|
|
331
342
|
className: "gap-2",
|
|
332
|
-
children: [/* @__PURE__ */ u(
|
|
343
|
+
children: [/* @__PURE__ */ u(Ae, {
|
|
333
344
|
className: "h-4 w-4",
|
|
334
345
|
"aria-hidden": "true"
|
|
335
346
|
}), /* @__PURE__ */ u("span", { children: p("back_to_booking") })]
|
|
@@ -345,13 +356,13 @@ function p() {
|
|
|
345
356
|
children: [
|
|
346
357
|
/* @__PURE__ */ u(pe, {
|
|
347
358
|
currentStep: "checkout",
|
|
348
|
-
bookingPath:
|
|
349
|
-
checkoutPath:
|
|
359
|
+
bookingPath: xt,
|
|
360
|
+
checkoutPath: St
|
|
350
361
|
}),
|
|
351
|
-
/* @__PURE__ */ d(
|
|
352
|
-
to:
|
|
362
|
+
/* @__PURE__ */ d(Te, {
|
|
363
|
+
to: xt,
|
|
353
364
|
className: "inline-flex items-center gap-2 text-sm font-medium text-slate-700 hover:text-slate-950",
|
|
354
|
-
children: [/* @__PURE__ */ u(
|
|
365
|
+
children: [/* @__PURE__ */ u(Ae, {
|
|
355
366
|
className: "h-4 w-4",
|
|
356
367
|
"aria-hidden": "true"
|
|
357
368
|
}), /* @__PURE__ */ u("span", { children: p("back_to_booking") })]
|
|
@@ -365,7 +376,7 @@ function p() {
|
|
|
365
376
|
className: "text-xl font-semibold tracking-tight text-slate-950",
|
|
366
377
|
children: /* @__PURE__ */ u("span", { children: p("checkout_title") })
|
|
367
378
|
}),
|
|
368
|
-
|
|
379
|
+
L ? null : /* @__PURE__ */ u("p", {
|
|
369
380
|
role: "alert",
|
|
370
381
|
className: "mt-3 text-sm text-destructive",
|
|
371
382
|
children: /* @__PURE__ */ u("span", { children: p("booking_time_slots_required") })
|
|
@@ -373,63 +384,63 @@ function p() {
|
|
|
373
384
|
/* @__PURE__ */ d("div", {
|
|
374
385
|
className: "mt-5 grid gap-4",
|
|
375
386
|
children: [
|
|
376
|
-
|
|
387
|
+
lt ? /* @__PURE__ */ u("div", {
|
|
377
388
|
className: "rounded-xl border border-slate-200 bg-white p-3 shadow-sm",
|
|
378
389
|
children: /* @__PURE__ */ u(ge, {
|
|
379
|
-
value:
|
|
380
|
-
onValueChange: (e) =>
|
|
381
|
-
pickupAddress:
|
|
382
|
-
deliveryEnabled:
|
|
383
|
-
deliveryDisabledReason:
|
|
384
|
-
startAddress:
|
|
385
|
-
onStartAddressChange: (e) =>
|
|
386
|
-
endAddress:
|
|
387
|
-
onEndAddressChange: (e) =>
|
|
390
|
+
value: I.fulfillment,
|
|
391
|
+
onValueChange: (e) => Et({ fulfillment: e }),
|
|
392
|
+
pickupAddress: ut,
|
|
393
|
+
deliveryEnabled: F,
|
|
394
|
+
deliveryDisabledReason: ct,
|
|
395
|
+
startAddress: I.start_address,
|
|
396
|
+
onStartAddressChange: (e) => Et({ start_address: e }),
|
|
397
|
+
endAddress: I.end_address,
|
|
398
|
+
onEndAddressChange: (e) => Et({ end_address: e }),
|
|
388
399
|
showPickupAddressWhenPickupOnly: !1,
|
|
389
400
|
testIdPrefix: "storefront-checkout-fulfillment"
|
|
390
401
|
})
|
|
391
402
|
}) : null,
|
|
392
|
-
/* @__PURE__ */ u(ye, { form:
|
|
393
|
-
|
|
394
|
-
accepted:
|
|
395
|
-
disabled:
|
|
396
|
-
dailyAmountLabel: f(
|
|
397
|
-
totalAmountLabel:
|
|
398
|
-
billableDays:
|
|
399
|
-
deductibleLabel:
|
|
400
|
-
onAcceptedChange:
|
|
403
|
+
/* @__PURE__ */ u(ye, { form: Tt }),
|
|
404
|
+
G ? /* @__PURE__ */ u(xe, {
|
|
405
|
+
accepted: K,
|
|
406
|
+
disabled: b || k,
|
|
407
|
+
dailyAmountLabel: f(vt, X, m.language),
|
|
408
|
+
totalAmountLabel: It,
|
|
409
|
+
billableDays: D?.insuranceBillableDays,
|
|
410
|
+
deductibleLabel: yt > 0 ? f(yt, X, m.language) : void 0,
|
|
411
|
+
onAcceptedChange: ot
|
|
401
412
|
}) : null,
|
|
402
413
|
/* @__PURE__ */ u(be, {
|
|
403
|
-
estimatedTotalLabel:
|
|
404
|
-
couponCode:
|
|
405
|
-
discountAmountLabel:
|
|
406
|
-
totalExcludingTaxLabel:
|
|
407
|
-
vatAmountLabel:
|
|
408
|
-
vatRateLabel:
|
|
409
|
-
insuranceAmountLabel:
|
|
410
|
-
depositAmountLabel:
|
|
411
|
-
amountToCollectMinor:
|
|
412
|
-
amountToCollectLabel:
|
|
413
|
-
paymentSummaryHelper:
|
|
414
|
-
paymentDecisionLoading:
|
|
415
|
-
paymentDecisionError:
|
|
414
|
+
estimatedTotalLabel: Dt,
|
|
415
|
+
couponCode: T?.code,
|
|
416
|
+
discountAmountLabel: Ot,
|
|
417
|
+
totalExcludingTaxLabel: Nt,
|
|
418
|
+
vatAmountLabel: Pt,
|
|
419
|
+
vatRateLabel: Ft,
|
|
420
|
+
insuranceAmountLabel: It,
|
|
421
|
+
depositAmountLabel: Rt,
|
|
422
|
+
amountToCollectMinor: Q,
|
|
423
|
+
amountToCollectLabel: Lt,
|
|
424
|
+
paymentSummaryHelper: Ht,
|
|
425
|
+
paymentDecisionLoading: Xe,
|
|
426
|
+
paymentDecisionError: Qe,
|
|
416
427
|
canChoosePaymentMethod: !1,
|
|
417
428
|
showAmountDueNowRow: !0,
|
|
418
429
|
selectedPaymentMethod: "card",
|
|
419
|
-
submitting:
|
|
430
|
+
submitting: b,
|
|
420
431
|
onSelectPaymentMethod: () => {}
|
|
421
432
|
}),
|
|
422
433
|
/* @__PURE__ */ u(fe, {
|
|
423
434
|
type: "button",
|
|
424
435
|
size: "lg",
|
|
425
436
|
onClick: () => {
|
|
426
|
-
|
|
437
|
+
Ut();
|
|
427
438
|
},
|
|
428
|
-
disabled: !
|
|
439
|
+
disabled: !Kt,
|
|
429
440
|
className: "mt-4 w-fit",
|
|
430
|
-
children: /* @__PURE__ */ u("span", { children:
|
|
441
|
+
children: /* @__PURE__ */ u("span", { children: Wt })
|
|
431
442
|
}),
|
|
432
|
-
|
|
443
|
+
Gt ? /* @__PURE__ */ u("p", {
|
|
433
444
|
className: "text-sm text-slate-600",
|
|
434
445
|
children: /* @__PURE__ */ u("span", { children: p("checkout_delivery_address_required") })
|
|
435
446
|
}) : null
|
|
@@ -437,34 +448,34 @@ function p() {
|
|
|
437
448
|
})
|
|
438
449
|
]
|
|
439
450
|
}), /* @__PURE__ */ u(Se, {
|
|
440
|
-
lines:
|
|
451
|
+
lines: H.lines,
|
|
441
452
|
itemCount: He,
|
|
442
|
-
totalPerDayMinor:
|
|
443
|
-
estimatedDays:
|
|
444
|
-
estimatedTotalMinor:
|
|
445
|
-
discountedEstimatedTotalMinor:
|
|
446
|
-
discountAmountMinor:
|
|
447
|
-
lateReturnSurchargeMinor:
|
|
448
|
-
couponCode:
|
|
449
|
-
durationLabel:
|
|
453
|
+
totalPerDayMinor: H.totalPerDayMinor,
|
|
454
|
+
estimatedDays: H.estimatedDays,
|
|
455
|
+
estimatedTotalMinor: H.estimatedTotalMinor,
|
|
456
|
+
discountedEstimatedTotalMinor: q,
|
|
457
|
+
discountAmountMinor: J,
|
|
458
|
+
lateReturnSurchargeMinor: D?.lateReturnSurchargeMinor,
|
|
459
|
+
couponCode: T?.code,
|
|
460
|
+
durationLabel: dt.label,
|
|
450
461
|
onQuantityChange: Ue,
|
|
451
462
|
onRemove: We,
|
|
452
463
|
coupon: {
|
|
453
|
-
code:
|
|
454
|
-
appliedCode:
|
|
455
|
-
discountLabel:
|
|
456
|
-
message:
|
|
457
|
-
error:
|
|
458
|
-
loading:
|
|
459
|
-
disabled:
|
|
464
|
+
code: et,
|
|
465
|
+
appliedCode: T?.code,
|
|
466
|
+
discountLabel: T && J > 0 ? f(J, X, m.language) : null,
|
|
467
|
+
message: rt,
|
|
468
|
+
error: it,
|
|
469
|
+
loading: k,
|
|
470
|
+
disabled: b,
|
|
460
471
|
onCodeChange: (e) => {
|
|
461
|
-
|
|
472
|
+
w(e), M(null), j(null);
|
|
462
473
|
},
|
|
463
474
|
onApply: () => {
|
|
464
|
-
|
|
475
|
+
at(!1), nt(et.trim());
|
|
465
476
|
},
|
|
466
477
|
onRemove: () => {
|
|
467
|
-
|
|
478
|
+
w(""), nt(""), E(null), O(null), M(null), j(null), at(!0);
|
|
468
479
|
}
|
|
469
480
|
}
|
|
470
481
|
})]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckoutPaymentPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPaymentPage.tsx"],"names":[],"mappings":"AAmGA,MAAM,CAAC,OAAO,UAAU,mBAAmB,
|
|
1
|
+
{"version":3,"file":"CheckoutPaymentPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPaymentPage.tsx"],"names":[],"mappings":"AAmGA,MAAM,CAAC,OAAO,UAAU,mBAAmB,4CA+Y1C"}
|