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