@loczer/storefront-sdk 0.209.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/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/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/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/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 +11 -7
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +13 -9
- package/dist/i18n/fr.d.ts +11 -7
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +13 -9
- package/dist/index.d.ts +62 -39
- package/dist/index.js +68 -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/floatingButtonCollision.d.ts +20 -0
- package/dist/lib/floatingButtonCollision.d.ts.map +1 -0
- package/dist/lib/floatingButtonCollision.js +72 -0
- 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/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/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 +195 -191
- 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/dist/storefront.css +1 -1
- package/dist/ui/day-picker.js +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckoutPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPage.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"CheckoutPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPage.tsx"],"names":[],"mappings":"AAuGA,MAAM,CAAC,OAAO,UAAU,YAAY,4CAutBnC"}
|
|
@@ -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 {
|
|
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";
|
|
9
10
|
import { toast as a } from "../lib/toast.js";
|
|
10
|
-
import { BookingFlowSteps as
|
|
11
|
+
import { BookingFlowSteps as ge } from "../components/BookingFlowSteps/index.js";
|
|
11
12
|
import { apiPost as o } from "../lib/apiCall.js";
|
|
12
|
-
import { FulfillmentSection as
|
|
13
|
-
import { ROUTE as
|
|
14
|
-
import { CheckoutDetailsCard as
|
|
15
|
-
import { CheckoutPaymentSummaryCard as
|
|
16
|
-
import { CheckoutInsuranceCard as
|
|
17
|
-
import { CheckoutSummaryColumn as
|
|
18
|
-
import { checkoutFormSchema as
|
|
19
|
-
import { useEffect as s, useMemo as c, useRef as
|
|
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";
|
|
20
21
|
import { jsx as u, jsxs as d } from "react/jsx-runtime";
|
|
21
|
-
import { Link as
|
|
22
|
-
import { useTranslation as
|
|
23
|
-
import { ArrowLeft as
|
|
24
|
-
import { useForm as
|
|
22
|
+
import { Link as Ee, useLocation 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, f = (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"
|
|
@@ -56,8 +57,8 @@ var Ne = .2, Pe = (e) => e <= 0 ? 1 : Math.max(1, Math.ceil(e / 1440)), f = (e,
|
|
|
56
57
|
return new Intl.DateTimeFormat(t, r).format(e);
|
|
57
58
|
};
|
|
58
59
|
function p() {
|
|
59
|
-
let { t: p, i18n: m } =
|
|
60
|
-
let e =
|
|
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, {
|
|
61
62
|
start_time: "",
|
|
62
63
|
end_time: ""
|
|
63
64
|
});
|
|
@@ -65,51 +66,53 @@ function p() {
|
|
|
65
66
|
...e,
|
|
66
67
|
fulfillment: "pickup"
|
|
67
68
|
} : e;
|
|
68
|
-
}, [
|
|
69
|
-
items:
|
|
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,
|
|
70
71
|
language: m.language,
|
|
71
|
-
fallbackLanguage:
|
|
72
|
+
fallbackLanguage: Re,
|
|
72
73
|
products: {
|
|
73
74
|
bikes: g,
|
|
74
|
-
accessories:
|
|
75
|
+
accessories: ze
|
|
75
76
|
},
|
|
76
|
-
|
|
77
|
+
priceUnit: R.baseUnit,
|
|
78
|
+
billableUnitCount: ht
|
|
77
79
|
}), [
|
|
78
|
-
|
|
80
|
+
ze,
|
|
79
81
|
g,
|
|
80
|
-
|
|
82
|
+
ht,
|
|
81
83
|
m.language,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
84
|
+
He,
|
|
85
|
+
R.baseUnit,
|
|
86
|
+
Re
|
|
87
|
+
]), gt = c(() => B.lines.map((e) => ({
|
|
85
88
|
productId: e.checkoutProductId,
|
|
86
89
|
productVariantId: e.productVariantId,
|
|
87
90
|
quantity: e.quantity
|
|
88
|
-
})), [
|
|
91
|
+
})), [B.lines]), [_t, V] = l([]), [vt, H] = l(!1);
|
|
89
92
|
s(() => {
|
|
90
|
-
if (!_ ||
|
|
91
|
-
|
|
93
|
+
if (!_ || gt.length === 0) {
|
|
94
|
+
V([]), H(!1);
|
|
92
95
|
return;
|
|
93
96
|
}
|
|
94
97
|
if (!L) {
|
|
95
|
-
|
|
98
|
+
V([]), H(!1);
|
|
96
99
|
return;
|
|
97
100
|
}
|
|
98
101
|
let e = !1;
|
|
99
|
-
return
|
|
102
|
+
return H(!0), V([]), (async () => {
|
|
100
103
|
try {
|
|
101
|
-
let t = await o(
|
|
104
|
+
let t = await o(ce, {
|
|
102
105
|
storeSlug: _,
|
|
103
106
|
schedule: L,
|
|
104
|
-
products:
|
|
105
|
-
}), n =
|
|
107
|
+
products: gt
|
|
108
|
+
}), n = fe.parse(t);
|
|
106
109
|
if (e) return;
|
|
107
|
-
|
|
110
|
+
V(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), V([]);
|
|
111
114
|
} finally {
|
|
112
|
-
e ||
|
|
115
|
+
e || H(!1);
|
|
113
116
|
}
|
|
114
117
|
})(), () => {
|
|
115
118
|
e = !0;
|
|
@@ -120,47 +123,48 @@ function p() {
|
|
|
120
123
|
I.start_date,
|
|
121
124
|
I.start_time,
|
|
122
125
|
L,
|
|
123
|
-
|
|
126
|
+
gt,
|
|
124
127
|
_
|
|
125
128
|
]);
|
|
126
|
-
let
|
|
127
|
-
...
|
|
128
|
-
lines:
|
|
129
|
-
let t =
|
|
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
|
+
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: !vt && n !== void 0,
|
|
136
|
+
availabilityIssue: vt ? void 0 : n
|
|
134
137
|
};
|
|
135
138
|
})
|
|
136
139
|
}), [
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
]), U = c(() =>
|
|
140
|
+
yt,
|
|
141
|
+
vt,
|
|
142
|
+
B
|
|
143
|
+
]), U = c(() => B.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
|
+
})), [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);
|
|
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
|
+
}), 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;
|
|
155
158
|
s(() => {
|
|
156
|
-
!_ || !
|
|
159
|
+
!_ || !kt || At || S.current || y(kt, { replace: !0 });
|
|
157
160
|
}, [
|
|
158
|
-
|
|
159
|
-
|
|
161
|
+
kt,
|
|
162
|
+
y,
|
|
163
|
+
At,
|
|
160
164
|
_
|
|
161
165
|
]);
|
|
162
|
-
let
|
|
163
|
-
resolver:
|
|
166
|
+
let jt = Ne({
|
|
167
|
+
resolver: Pe(we),
|
|
164
168
|
defaultValues: {
|
|
165
169
|
first_name: "",
|
|
166
170
|
last_name: "",
|
|
@@ -170,90 +174,90 @@ function p() {
|
|
|
170
174
|
}
|
|
171
175
|
});
|
|
172
176
|
s(() => {
|
|
173
|
-
|
|
177
|
+
r(_, I);
|
|
174
178
|
}, [I, _]), s(() => {
|
|
175
|
-
!
|
|
176
|
-
}, [
|
|
177
|
-
let
|
|
179
|
+
!W && st && ct(!1);
|
|
180
|
+
}, [st, W]);
|
|
181
|
+
let Mt = (t) => {
|
|
178
182
|
let n = {
|
|
179
183
|
...I,
|
|
180
184
|
...t
|
|
181
|
-
},
|
|
182
|
-
|
|
185
|
+
}, i = e(v, n);
|
|
186
|
+
Be(i, { replace: !0 }), r(_, i);
|
|
183
187
|
};
|
|
184
188
|
s(() => {
|
|
185
189
|
if (!_ || U.length === 0 || !L) {
|
|
186
|
-
|
|
190
|
+
k(null), j(null), nt(!1), N(null), P(null);
|
|
187
191
|
return;
|
|
188
192
|
}
|
|
189
|
-
let e =
|
|
190
|
-
return
|
|
193
|
+
let e = et.trim(), t = e.length === 0 && !at, n = !1;
|
|
194
|
+
return nt(!0), P(null), N(null), (async () => {
|
|
191
195
|
try {
|
|
192
|
-
let r = await o(
|
|
196
|
+
let r = await o(ve, {
|
|
193
197
|
storeSlug: _,
|
|
194
198
|
schedule: L,
|
|
195
199
|
items: U,
|
|
196
200
|
couponCode: e || void 0,
|
|
197
201
|
includeAutoApply: t,
|
|
198
|
-
insuranceAccepted:
|
|
199
|
-
}), i =
|
|
202
|
+
insuranceAccepted: G
|
|
203
|
+
}), i = ye.parse(r);
|
|
200
204
|
if (n) return;
|
|
201
|
-
if (
|
|
205
|
+
if (j(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
|
|
202
206
|
subtotalMinor: i.subtotalMinor,
|
|
203
207
|
totalMinor: i.totalMinor,
|
|
204
208
|
lateReturnSurchargeMinor: i.lateReturnSurchargeMinor,
|
|
205
209
|
insuranceSubtotalMinor: i.insuranceSubtotalMinor,
|
|
206
210
|
insuranceBillableDays: i.insuranceBillableDays
|
|
207
211
|
} : null), !i.success) {
|
|
208
|
-
|
|
212
|
+
k(null), P(i.message || p("checkout_coupon_invalid"));
|
|
209
213
|
return;
|
|
210
214
|
}
|
|
211
|
-
|
|
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")));
|
|
212
216
|
} catch (e) {
|
|
213
217
|
if (n) return;
|
|
214
|
-
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"));
|
|
215
219
|
} finally {
|
|
216
|
-
n ||
|
|
220
|
+
n || nt(!1);
|
|
217
221
|
}
|
|
218
222
|
})(), () => {
|
|
219
223
|
n = !0;
|
|
220
224
|
};
|
|
221
225
|
}, [
|
|
222
|
-
|
|
226
|
+
at,
|
|
223
227
|
I.end_date,
|
|
224
228
|
I.end_time,
|
|
225
229
|
I.start_date,
|
|
226
230
|
I.start_time,
|
|
227
231
|
L,
|
|
228
232
|
U,
|
|
229
|
-
|
|
233
|
+
G,
|
|
230
234
|
_,
|
|
231
|
-
|
|
235
|
+
et,
|
|
232
236
|
p
|
|
233
237
|
]), s(() => {
|
|
234
|
-
if (!_ ||
|
|
235
|
-
|
|
238
|
+
if (!_ || B.lines.length === 0 || !L) {
|
|
239
|
+
w(null), E(null), T(!1);
|
|
236
240
|
return;
|
|
237
241
|
}
|
|
238
242
|
let e = !1;
|
|
239
|
-
return
|
|
243
|
+
return T(!0), E(null), (async () => {
|
|
240
244
|
try {
|
|
241
|
-
let t = await o(
|
|
245
|
+
let t = await o(ie, {
|
|
242
246
|
storeSlug: _,
|
|
243
247
|
schedule: L,
|
|
244
|
-
estimatedTotalMinor:
|
|
245
|
-
}), n =
|
|
248
|
+
estimatedTotalMinor: K
|
|
249
|
+
}), n = ae.parse(t);
|
|
246
250
|
if (e) return;
|
|
247
251
|
if (!n.success || !n.decision) {
|
|
248
|
-
|
|
252
|
+
w(null), E(n.errorCode === "online_payment_provider_missing" ? p("checkout_payment_error") : n.message || p("checkout_payment_error"));
|
|
249
253
|
return;
|
|
250
254
|
}
|
|
251
|
-
|
|
255
|
+
w(n.decision);
|
|
252
256
|
} catch (t) {
|
|
253
257
|
if (e) return;
|
|
254
|
-
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"));
|
|
255
259
|
} finally {
|
|
256
|
-
e ||
|
|
260
|
+
e || T(!1);
|
|
257
261
|
}
|
|
258
262
|
})(), () => {
|
|
259
263
|
e = !0;
|
|
@@ -264,43 +268,43 @@ function p() {
|
|
|
264
268
|
I.start_date,
|
|
265
269
|
I.start_time,
|
|
266
270
|
L,
|
|
267
|
-
|
|
268
|
-
|
|
271
|
+
K,
|
|
272
|
+
B.lines.length,
|
|
269
273
|
_,
|
|
270
274
|
p
|
|
271
275
|
]);
|
|
272
|
-
let
|
|
273
|
-
if (!
|
|
274
|
-
let e = new Date(
|
|
275
|
-
return Number.isNaN(e.getTime()) ? null :
|
|
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);
|
|
276
280
|
}, [
|
|
277
281
|
m.language,
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
]),
|
|
281
|
-
percent:
|
|
282
|
-
date:
|
|
283
|
-
}) : p("checkout_payment_due_now_helper_deposit", { percent:
|
|
282
|
+
C?.depositRefundableUntilIso,
|
|
283
|
+
Kt
|
|
284
|
+
]), qt = c(() => C ? C.paymentMode === "deposit" && Z > 0 && Q ? $ ? p("checkout_payment_due_now_helper_deposit_refundable_until", {
|
|
285
|
+
percent: Q,
|
|
286
|
+
date: $
|
|
287
|
+
}) : p("checkout_payment_due_now_helper_deposit", { percent: Q }) : C.paymentMode === "none" || Z <= 0 ? p("checkout_payment_due_now_helper_none") : null : null, [
|
|
288
|
+
Z,
|
|
284
289
|
Q,
|
|
285
290
|
$,
|
|
286
|
-
|
|
287
|
-
x,
|
|
291
|
+
C,
|
|
288
292
|
p
|
|
289
|
-
]),
|
|
293
|
+
]), Jt = jt.handleSubmit(async (e) => {
|
|
290
294
|
if (!_ || U.length === 0 || !L) return;
|
|
291
|
-
|
|
292
|
-
let t =
|
|
295
|
+
Ye(!0), S.current = !0;
|
|
296
|
+
let t = Ke();
|
|
293
297
|
try {
|
|
294
|
-
let n = await o(
|
|
298
|
+
let n = await o(oe, {
|
|
295
299
|
storeSlug: _,
|
|
296
300
|
checkoutSessionId: t,
|
|
297
301
|
schedule: L,
|
|
298
302
|
fulfillment: I.fulfillment,
|
|
299
303
|
startAddress: I.fulfillment === "delivery" ? I.start_address : void 0,
|
|
300
304
|
endAddress: I.fulfillment === "delivery" ? I.end_address : void 0,
|
|
301
|
-
couponCode:
|
|
302
|
-
couponAutoApplied: !
|
|
303
|
-
insuranceAccepted:
|
|
305
|
+
couponCode: O?.code,
|
|
306
|
+
couponAutoApplied: !at && O?.autoApplied,
|
|
307
|
+
insuranceAccepted: G,
|
|
304
308
|
customer: {
|
|
305
309
|
firstName: e.first_name,
|
|
306
310
|
lastName: e.last_name,
|
|
@@ -309,19 +313,19 @@ function p() {
|
|
|
309
313
|
notes: e.notes
|
|
310
314
|
},
|
|
311
315
|
items: U
|
|
312
|
-
}), r =
|
|
316
|
+
}), r = se.parse(n);
|
|
313
317
|
if (!r.success || !r.checkout) {
|
|
314
|
-
|
|
318
|
+
qe(), a.error(r.errorCode === "online_payment_provider_missing" ? p("checkout_payment_error") : r.message || p("checkout_payment_error"));
|
|
315
319
|
return;
|
|
316
320
|
}
|
|
317
|
-
r.checkout.requiresPayment || a.success(p("checkout_success_toast")), await
|
|
321
|
+
r.checkout.requiresPayment || a.success(p("checkout_success_toast")), await y(r.checkout.nextPath), r.checkout.requiresPayment || Je();
|
|
318
322
|
} catch (e) {
|
|
319
323
|
console.error("Failed to submit storefront checkout", e), a.error(p("checkout_payment_error"));
|
|
320
324
|
} finally {
|
|
321
|
-
|
|
325
|
+
S.current = !1, Ye(!1);
|
|
322
326
|
}
|
|
323
|
-
}),
|
|
324
|
-
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", {
|
|
325
329
|
className: "mx-auto max-w-3xl px-4 py-10 sm:px-6",
|
|
326
330
|
children: /* @__PURE__ */ d("div", {
|
|
327
331
|
className: "rounded-xl border border-slate-200 bg-white p-4 shadow-sm",
|
|
@@ -336,11 +340,11 @@ function p() {
|
|
|
336
340
|
}),
|
|
337
341
|
/* @__PURE__ */ u("div", {
|
|
338
342
|
className: "mt-6",
|
|
339
|
-
children: /* @__PURE__ */ u(
|
|
340
|
-
to:
|
|
341
|
-
children: /* @__PURE__ */ d(
|
|
343
|
+
children: /* @__PURE__ */ u(Ee, {
|
|
344
|
+
to: Et,
|
|
345
|
+
children: /* @__PURE__ */ d(pe, {
|
|
342
346
|
className: "gap-2",
|
|
343
|
-
children: [/* @__PURE__ */ u(
|
|
347
|
+
children: [/* @__PURE__ */ u(Me, {
|
|
344
348
|
className: "h-4 w-4",
|
|
345
349
|
"aria-hidden": "true"
|
|
346
350
|
}), /* @__PURE__ */ u("span", { children: p("back_to_booking") })]
|
|
@@ -354,15 +358,15 @@ function p() {
|
|
|
354
358
|
children: /* @__PURE__ */ d("div", {
|
|
355
359
|
className: "flex flex-col gap-6",
|
|
356
360
|
children: [
|
|
357
|
-
/* @__PURE__ */ u(
|
|
361
|
+
/* @__PURE__ */ u(ge, {
|
|
358
362
|
currentStep: "checkout",
|
|
359
|
-
bookingPath:
|
|
360
|
-
checkoutPath:
|
|
363
|
+
bookingPath: Et,
|
|
364
|
+
checkoutPath: Dt
|
|
361
365
|
}),
|
|
362
|
-
/* @__PURE__ */ d(
|
|
363
|
-
to:
|
|
366
|
+
/* @__PURE__ */ d(Ee, {
|
|
367
|
+
to: Et,
|
|
364
368
|
className: "inline-flex items-center gap-2 text-sm font-medium text-slate-700 hover:text-slate-950",
|
|
365
|
-
children: [/* @__PURE__ */ u(
|
|
369
|
+
children: [/* @__PURE__ */ u(Me, {
|
|
366
370
|
className: "h-4 w-4",
|
|
367
371
|
"aria-hidden": "true"
|
|
368
372
|
}), /* @__PURE__ */ u("span", { children: p("back_to_booking") })]
|
|
@@ -384,98 +388,98 @@ function p() {
|
|
|
384
388
|
/* @__PURE__ */ d("div", {
|
|
385
389
|
className: "mt-5 grid gap-4",
|
|
386
390
|
children: [
|
|
387
|
-
|
|
391
|
+
dt ? /* @__PURE__ */ u("div", {
|
|
388
392
|
className: "rounded-xl border border-slate-200 bg-white p-3 shadow-sm",
|
|
389
|
-
children: /* @__PURE__ */ u(
|
|
393
|
+
children: /* @__PURE__ */ u(_e, {
|
|
390
394
|
value: I.fulfillment,
|
|
391
|
-
onValueChange: (e) =>
|
|
392
|
-
pickupAddress:
|
|
395
|
+
onValueChange: (e) => Mt({ fulfillment: e }),
|
|
396
|
+
pickupAddress: ft,
|
|
393
397
|
deliveryEnabled: F,
|
|
394
|
-
deliveryDisabledReason:
|
|
398
|
+
deliveryDisabledReason: ut,
|
|
395
399
|
startAddress: I.start_address,
|
|
396
|
-
onStartAddressChange: (e) =>
|
|
400
|
+
onStartAddressChange: (e) => Mt({ start_address: e }),
|
|
397
401
|
endAddress: I.end_address,
|
|
398
|
-
onEndAddressChange: (e) =>
|
|
402
|
+
onEndAddressChange: (e) => Mt({ end_address: e }),
|
|
399
403
|
showPickupAddressWhenPickupOnly: !1,
|
|
400
404
|
testIdPrefix: "storefront-checkout-fulfillment"
|
|
401
405
|
})
|
|
402
406
|
}) : null,
|
|
403
|
-
/* @__PURE__ */ u(
|
|
404
|
-
|
|
405
|
-
accepted:
|
|
406
|
-
disabled:
|
|
407
|
-
dailyAmountLabel: f(
|
|
408
|
-
totalAmountLabel:
|
|
409
|
-
billableDays:
|
|
410
|
-
deductibleLabel:
|
|
411
|
-
onAcceptedChange:
|
|
407
|
+
/* @__PURE__ */ u(be, { form: jt }),
|
|
408
|
+
W ? /* @__PURE__ */ u(Se, {
|
|
409
|
+
accepted: G,
|
|
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
|
|
412
416
|
}) : null,
|
|
413
|
-
/* @__PURE__ */ u(
|
|
414
|
-
estimatedTotalLabel:
|
|
415
|
-
couponCode:
|
|
416
|
-
discountAmountLabel:
|
|
417
|
-
totalExcludingTaxLabel:
|
|
418
|
-
vatAmountLabel:
|
|
419
|
-
vatRateLabel:
|
|
420
|
-
insuranceAmountLabel:
|
|
421
|
-
depositAmountLabel:
|
|
422
|
-
amountToCollectMinor:
|
|
423
|
-
amountToCollectLabel:
|
|
424
|
-
paymentSummaryHelper:
|
|
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,
|
|
426
|
+
amountToCollectMinor: Z,
|
|
427
|
+
amountToCollectLabel: Ut,
|
|
428
|
+
paymentSummaryHelper: qt,
|
|
425
429
|
paymentDecisionLoading: Xe,
|
|
426
|
-
paymentDecisionError:
|
|
430
|
+
paymentDecisionError: Ze,
|
|
427
431
|
canChoosePaymentMethod: !1,
|
|
428
432
|
showAmountDueNowRow: !0,
|
|
429
433
|
selectedPaymentMethod: "card",
|
|
430
|
-
submitting:
|
|
434
|
+
submitting: x,
|
|
431
435
|
onSelectPaymentMethod: () => {}
|
|
432
436
|
}),
|
|
433
|
-
/* @__PURE__ */ u(
|
|
437
|
+
/* @__PURE__ */ u(pe, {
|
|
434
438
|
type: "button",
|
|
435
439
|
size: "lg",
|
|
436
440
|
onClick: () => {
|
|
437
|
-
|
|
441
|
+
Jt();
|
|
438
442
|
},
|
|
439
|
-
disabled: !
|
|
443
|
+
disabled: !Zt,
|
|
440
444
|
className: "mt-4 w-fit",
|
|
441
|
-
children: /* @__PURE__ */ u("span", { children:
|
|
445
|
+
children: /* @__PURE__ */ u("span", { children: Yt })
|
|
442
446
|
}),
|
|
443
|
-
|
|
447
|
+
Xt ? /* @__PURE__ */ u("p", {
|
|
444
448
|
className: "text-sm text-slate-600",
|
|
445
449
|
children: /* @__PURE__ */ u("span", { children: p("checkout_delivery_address_required") })
|
|
446
450
|
}) : null
|
|
447
451
|
]
|
|
448
452
|
})
|
|
449
453
|
]
|
|
450
|
-
}), /* @__PURE__ */ u(
|
|
451
|
-
lines:
|
|
452
|
-
itemCount:
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
estimatedTotalMinor:
|
|
456
|
-
discountedEstimatedTotalMinor:
|
|
457
|
-
discountAmountMinor:
|
|
458
|
-
lateReturnSurchargeMinor:
|
|
459
|
-
couponCode:
|
|
460
|
-
|
|
461
|
-
onQuantityChange:
|
|
462
|
-
onRemove:
|
|
454
|
+
}), /* @__PURE__ */ u(Ce, {
|
|
455
|
+
lines: bt.lines,
|
|
456
|
+
itemCount: Ue,
|
|
457
|
+
totalPerBaseUnitMinor: bt.totalPerBaseUnitMinor,
|
|
458
|
+
baseUnitLabel: pt,
|
|
459
|
+
estimatedTotalMinor: bt.estimatedTotalMinor,
|
|
460
|
+
discountedEstimatedTotalMinor: K,
|
|
461
|
+
discountAmountMinor: q,
|
|
462
|
+
lateReturnSurchargeMinor: A?.lateReturnSurchargeMinor,
|
|
463
|
+
couponCode: O?.code,
|
|
464
|
+
durationInBaseUnitLabel: mt,
|
|
465
|
+
onQuantityChange: We,
|
|
466
|
+
onRemove: Ge,
|
|
463
467
|
coupon: {
|
|
464
|
-
code:
|
|
465
|
-
appliedCode:
|
|
466
|
-
discountLabel:
|
|
468
|
+
code: $e,
|
|
469
|
+
appliedCode: O?.code,
|
|
470
|
+
discountLabel: O && q > 0 ? f(q, Y, m.language) : null,
|
|
467
471
|
message: rt,
|
|
468
472
|
error: it,
|
|
469
|
-
loading:
|
|
470
|
-
disabled:
|
|
473
|
+
loading: M,
|
|
474
|
+
disabled: x,
|
|
471
475
|
onCodeChange: (e) => {
|
|
472
|
-
|
|
476
|
+
D(e), P(null), N(null);
|
|
473
477
|
},
|
|
474
478
|
onApply: () => {
|
|
475
|
-
|
|
479
|
+
ot(!1), tt($e.trim());
|
|
476
480
|
},
|
|
477
481
|
onRemove: () => {
|
|
478
|
-
|
|
482
|
+
D(""), tt(""), k(null), j(null), P(null), N(null), ot(!0);
|
|
479
483
|
}
|
|
480
484
|
}
|
|
481
485
|
})]
|