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