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