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