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