@loczer/storefront-sdk 0.230.0 → 0.232.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/StorefrontContext.d.ts +0 -2
- package/dist/StorefrontContext.d.ts.map +1 -1
- package/dist/StorefrontProvider.d.ts +0 -1
- package/dist/StorefrontProvider.d.ts.map +1 -1
- package/dist/chunks/pkg/booking-engine/dist/schemas/{base-booking-C9kJFMIu.js → base-booking-BJXFzDM5.js} +0 -2
- package/dist/chunks/pkg/booking-engine/dist/schemas/{cart-inputs-epi7FXIk.js → cart-inputs-3lBblkB0.js} +0 -10
- package/dist/chunks/pkg/booking-engine/dist/{schemas-DW5gdDYz.js → schemas-JjiUWFIv.js} +2 -2
- package/dist/chunks/pkg/ui/dist/LanguagePicker/index-D7_3voTe.js +83 -0
- package/dist/components/BookingBikeQuickAddCard/index.d.ts +3 -1
- package/dist/components/BookingBikeQuickAddCard/index.d.ts.map +1 -1
- package/dist/components/BookingBikeQuickAddCard/index.js +94 -85
- package/dist/components/BookingPeriodSelector/components/BookingEndDateField.js +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.js +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingStartDateField.js +1 -1
- package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.js +1 -1
- package/dist/components/ContractSaleDocument/InvoiceDetails.d.ts.map +1 -1
- package/dist/components/ContractSaleDocument/InvoiceDetails.js +62 -56
- package/dist/components/Footer/businessHoursStatus.js +1 -1
- package/dist/components/Header/index.d.ts.map +1 -1
- package/dist/components/Header/index.js +56 -56
- package/dist/components/LanguageSelector/index.d.ts.map +1 -1
- package/dist/components/LanguageSelector/index.js +19 -64
- package/dist/components/StorefrontCartPanel/index.js +1 -1
- package/dist/i18n/en.d.ts +2 -4
- package/dist/i18n/en.d.ts.map +1 -1
- package/dist/i18n/en.js +3 -5
- package/dist/i18n/fr.d.ts +2 -4
- package/dist/i18n/fr.d.ts.map +1 -1
- package/dist/i18n/fr.js +4 -6
- package/dist/index.d.ts +17 -35
- package/dist/index.js +3 -3
- package/dist/lib/booking-period.js +1 -1
- package/dist/lib/booking.d.ts +6 -6
- package/dist/lib/booking.d.ts.map +1 -1
- package/dist/lib/booking.js +21 -21
- package/dist/lib/cart.d.ts +1 -0
- package/dist/lib/cart.d.ts.map +1 -1
- package/dist/lib/cart.js +2 -0
- package/dist/lib/checkoutSubmit.d.ts +2 -6
- package/dist/lib/checkoutSubmit.d.ts.map +1 -1
- package/dist/lib/checkoutSubmit.js +3 -11
- package/dist/lib/pricing.js +1 -1
- package/dist/lib/storefrontAvailability.d.ts +12 -8
- package/dist/lib/storefrontAvailability.d.ts.map +1 -1
- package/dist/lib/storefrontAvailability.js +17 -7
- package/dist/pages/BookingPage.d.ts.map +1 -1
- package/dist/pages/BookingPage.js +236 -238
- package/dist/pages/CheckoutPage.d.ts.map +1 -1
- package/dist/pages/CheckoutPage.js +127 -125
- package/dist/pages/ContractSaleDocumentPage.d.ts.map +1 -1
- package/dist/pages/ContractSaleDocumentPage.js +117 -171
- package/dist/pages/HomePage.js +8 -8
- package/dist/pages/ProductPage.d.ts.map +1 -1
- package/dist/pages/ProductPage.js +187 -181
- package/dist/pages/checkout/components/CheckoutDetailsCard.d.ts.map +1 -1
- package/dist/pages/checkout/components/CheckoutDetailsCard.js +4 -17
- package/dist/pages/checkout/components/CheckoutLoadingSkeleton.d.ts +7 -0
- package/dist/pages/checkout/components/CheckoutLoadingSkeleton.d.ts.map +1 -0
- package/dist/pages/checkout/components/CheckoutLoadingSkeleton.js +105 -0
- package/dist/pages/checkout/types.d.ts +1 -2
- package/dist/pages/checkout/types.d.ts.map +1 -1
- package/dist/pages/checkout/types.js +1 -2
- package/dist/storefront.css +1 -1
- package/dist/storefrontSchemas.d.ts +0 -2
- package/dist/storefrontSchemas.d.ts.map +1 -1
- package/dist/storefrontSchemas.js +1 -2
- package/package.json +1 -1
- package/dist/chunks/pkg/ui/dist/{MorphingModalWizard-j1CgFGLe.js → MorphingModalWizard-Q8O5Rjfq.js} +1 -1
|
@@ -4,58 +4,60 @@ import { getStorefrontCheckoutProductId as s, getStorefrontProductSelectionDispl
|
|
|
4
4
|
import { useStorefrontCart as ne } from "../lib/cart.js";
|
|
5
5
|
import { calculateBookingRentalUnitSummary as re, getPricingUnitLabel as ie } from "../lib/pricing.js";
|
|
6
6
|
import { buildStorefrontCartSummary as ae } from "../lib/cartSummary.js";
|
|
7
|
-
import { ROUTE as oe, buildStorefrontAvailabilityKey as c, getStorefrontAvailabilityIssue as se, getStorefrontAvailabilityStatus as l, getValidStorefrontAvailabilitySchedule as u, isStorefrontAvailabilityInsufficient as
|
|
8
|
-
import { Badge as
|
|
9
|
-
import { Button as
|
|
10
|
-
import { useStorefront as
|
|
11
|
-
import { toast as
|
|
12
|
-
import { BookingPeriodSelector as
|
|
7
|
+
import { ROUTE as oe, buildStorefrontAvailabilityKey as c, getStorefrontAvailabilityIssue as se, getStorefrontAvailabilityStatus as ce, getStorefrontProductAvailabilityStatus as l, getValidStorefrontAvailabilitySchedule as u, isStorefrontAvailabilityInsufficient as le, responseSchema as ue } from "../lib/storefrontAvailability.js";
|
|
8
|
+
import { Badge as de } from "../ui/badge.js";
|
|
9
|
+
import { Button as fe } from "../ui/button.js";
|
|
10
|
+
import { useStorefront as pe, useStorefrontBookingProducts as me, useStorefrontProducts as he } from "../StorefrontContext.js";
|
|
11
|
+
import { toast as ge } from "../lib/toast.js";
|
|
12
|
+
import { BookingPeriodSelector as _e } from "../components/BookingPeriodSelector/index.js";
|
|
13
13
|
import { StepSectionTitle as d } from "../components/StepSectionTitle/index.js";
|
|
14
|
-
import { Card as
|
|
15
|
-
import { ProductWarningNotice as
|
|
16
|
-
import { StorefrontCartPanel as
|
|
17
|
-
import { ProductPriceBadge as
|
|
18
|
-
import { resolveProductImageContainerStyle as
|
|
19
|
-
import { apiPost as
|
|
20
|
-
import { createStorefrontTimeSlotsFetcher as
|
|
21
|
-
import { FulfillmentSection as
|
|
22
|
-
import { BookingFlowPageLayout as
|
|
23
|
-
import { BookingBikeQuickAddCard as
|
|
24
|
-
import { BookingBikeVariantDialog as
|
|
25
|
-
import { useEffect as f, useLayoutEffect as
|
|
26
|
-
import { Fragment as
|
|
27
|
-
import { Link as
|
|
28
|
-
import { useTranslation as
|
|
29
|
-
import { cn as
|
|
30
|
-
import { Bike as
|
|
14
|
+
import { Card as ve } from "../ui/card.js";
|
|
15
|
+
import { ProductWarningNotice as ye } from "../components/ProductWarningNotice/index.js";
|
|
16
|
+
import { StorefrontCartPanel as be } from "../components/StorefrontCartPanel/index.js";
|
|
17
|
+
import { ProductPriceBadge as xe } from "../components/ProductPriceBadge/index.js";
|
|
18
|
+
import { resolveProductImageContainerStyle as Se } from "../lib/productImageStyles.js";
|
|
19
|
+
import { apiPost as Ce } from "../lib/apiCall.js";
|
|
20
|
+
import { createStorefrontTimeSlotsFetcher as we } from "../lib/fetchStorefrontTimeSlots.js";
|
|
21
|
+
import { FulfillmentSection as Te } from "../components/FulfillmentSection/index.js";
|
|
22
|
+
import { BookingFlowPageLayout as Ee } from "../components/BookingFlowPageLayout/index.js";
|
|
23
|
+
import { BookingBikeQuickAddCard as De } from "../components/BookingBikeQuickAddCard/index.js";
|
|
24
|
+
import { BookingBikeVariantDialog as Oe } from "../components/BookingBikeVariantDialog/index.js";
|
|
25
|
+
import { useEffect as f, useLayoutEffect as ke, useMemo as p, useRef as m, useState as h } from "react";
|
|
26
|
+
import { Fragment as Ae, jsx as g, jsxs as _ } from "react/jsx-runtime";
|
|
27
|
+
import { Link as je, useLocation as Me, useParams as Ne, useSearchParams as Pe } from "@rpcbase/router";
|
|
28
|
+
import { useTranslation as Fe } from "react-i18next";
|
|
29
|
+
import { cn as Ie } from "@rpcbase/ui";
|
|
30
|
+
import { Bike as Le, Plus as Re } from "lucide-react";
|
|
31
31
|
//#region src/pages/BookingPage.tsx
|
|
32
|
-
var v = (e) => String(e).padStart(2, "0"), y = "product_modal",
|
|
32
|
+
var v = (e) => String(e).padStart(2, "0"), y = "product_modal", ze = (e, t) => {
|
|
33
33
|
let n = t - e;
|
|
34
34
|
return e >= 0 && (n === 1 || n === 2) ? n : null;
|
|
35
|
-
},
|
|
35
|
+
}, Be = (e) => `${e.getFullYear()}-${v(e.getMonth() + 1)}-${v(e.getDate())}`, Ve = (e) => {
|
|
36
36
|
if (!e) return;
|
|
37
37
|
let t = e.match(/^(\d{4})-(\d{2})-(\d{2})$/);
|
|
38
38
|
if (!t) return;
|
|
39
39
|
let n = Number(t[1]), r = Number(t[2]), i = Number(t[3]), a = new Date(n, r - 1, i);
|
|
40
40
|
if (!(Number.isNaN(a.getTime()) || a.getFullYear() !== n || a.getMonth() !== r - 1 || a.getDate() !== i)) return a;
|
|
41
|
-
}, b = (e, t) => e.fulfillment === t.fulfillment && e.
|
|
41
|
+
}, b = (e, t) => e.fulfillment === t.fulfillment && e.startDate === t.startDate && e.startTime === t.startTime && e.endDate === t.endDate && e.endTime === t.endTime && e.startAddress === t.startAddress && e.endAddress === t.endAddress, x = (e, t = () => !0) => {
|
|
42
42
|
if (e.representedVariantId?.trim()) return e.representedVariantId.trim();
|
|
43
43
|
let n = e.productVariants ?? [], r = n.find((e) => t(e.id))?.id ?? n[0]?.id;
|
|
44
44
|
return typeof r == "string" && r.trim().length > 0 ? r : null;
|
|
45
|
-
},
|
|
45
|
+
}, He = (e, t) => e.fulfillment === "delivery" && !t ? {
|
|
46
46
|
...e,
|
|
47
47
|
fulfillment: "pickup"
|
|
48
|
-
} : e,
|
|
49
|
-
let n = s(e)
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
48
|
+
} : e, Ue = (e, t) => {
|
|
49
|
+
let n = s(e);
|
|
50
|
+
return l({
|
|
51
|
+
availabilityByKey: t,
|
|
52
|
+
fallbackStatus: e.availabilityStatus ?? "AVAILABLE",
|
|
53
|
+
productId: n,
|
|
54
|
+
productVariantIds: (e.productVariants ?? []).map((e) => e.id),
|
|
55
|
+
representedVariantId: e.representedVariantId
|
|
56
|
+
});
|
|
57
|
+
}, We = (e, t, n) => n.get(c(s(e), t)), Ge = (e, t, n) => {
|
|
56
58
|
let r = se(t);
|
|
57
|
-
return r === "
|
|
58
|
-
},
|
|
59
|
+
return r === "quantityUnavailable" ? e("availability_quantity_unavailable") : r === "unavailable" || n === "OUT_OF_STOCK" ? e("availability_out_of_stock") : t?.remaining === void 0 ? t?.fewRemaining || n === "LOW_STOCK" ? e("availability_low_stock") : e("availability_in_stock") : e("availability_remaining_count", { count: t.remaining });
|
|
60
|
+
}, Ke = (e) => {
|
|
59
61
|
let t = /* @__PURE__ */ new Map();
|
|
60
62
|
for (let n of e) {
|
|
61
63
|
let e = s(n);
|
|
@@ -73,93 +75,93 @@ var v = (e) => String(e).padStart(2, "0"), y = "product_modal", Re = (e, t) => {
|
|
|
73
75
|
return Array.from(t.values());
|
|
74
76
|
};
|
|
75
77
|
function S() {
|
|
76
|
-
let { t:
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
}, [
|
|
80
|
-
let
|
|
81
|
-
booking:
|
|
78
|
+
let { t: l, i18n: v } = Fe(), { storeSlug: S } = Ne(), C = Me(), qe = m(null), { storefrontConfiguration: w } = pe(), T = w.workspace?.workspaceLanguage, { bikes: Je, accessories: Ye } = he(), { bikes: E, accessories: D } = me(), [O, k] = Pe(), { items: Xe, itemCount: Ze, addItem: Qe, removeItem: $e, setQuantity: et } = ne();
|
|
79
|
+
ke(() => {
|
|
80
|
+
C.hash === "#booking-products" && qe.current?.scrollIntoView({ block: "start" });
|
|
81
|
+
}, [C.hash]);
|
|
82
|
+
let tt = p(() => t(w), [w]), A = p(() => r(w), [w]), j = w.settings.fulfillmentModes.includes("delivery"), nt = w.settings.deliveryDisabledReason.trim(), rt = w.shop.address?.trim() ?? "", M = w.bookingEngine.pricing.baseUnit, it = ie(M, l), at = i(O).toString(), N = p(() => a(new URLSearchParams(at), S), [at, S]), [P, F] = h(() => ({
|
|
83
|
+
booking: He(n(N, A), j),
|
|
82
84
|
shouldWriteToUrl: !0
|
|
83
|
-
})),
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
85
|
+
})), I = P.booking, L = p(() => Ve(I.startDate), [I.startDate]), ot = p(() => Ve(I.endDate) ?? L, [I.endDate, L]), [st, ct] = h(void 0), lt = m(void 0), ut = m(""), dt = [
|
|
86
|
+
I.startDate,
|
|
87
|
+
I.startTime,
|
|
88
|
+
I.endDate,
|
|
89
|
+
I.endTime
|
|
88
90
|
].join(":");
|
|
89
|
-
|
|
90
|
-
let
|
|
91
|
+
ut.current = dt;
|
|
92
|
+
let R = st === dt, z = R ? I.startTime : "", B = R ? I.endTime : "", V = !R && O.get("start_date") === I.startDate && O.get("start_time") === I.startTime && O.get("end_date") === I.endDate && O.get("end_time") === I.endTime;
|
|
91
93
|
f(() => {
|
|
92
|
-
|
|
94
|
+
F((e) => {
|
|
93
95
|
if (e.shouldWriteToUrl) return e;
|
|
94
96
|
let t = {
|
|
95
|
-
...
|
|
97
|
+
...A,
|
|
96
98
|
...e.booking
|
|
97
|
-
}, r =
|
|
99
|
+
}, r = He(n(N, t), j);
|
|
98
100
|
return {
|
|
99
101
|
booking: b(e.booking, r) ? e.booking : r,
|
|
100
102
|
shouldWriteToUrl: !0
|
|
101
103
|
};
|
|
102
104
|
});
|
|
103
105
|
}, [
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
106
|
+
N,
|
|
107
|
+
A,
|
|
108
|
+
j
|
|
107
109
|
]), f(() => {
|
|
108
|
-
if (!
|
|
109
|
-
let t = e(
|
|
110
|
-
...
|
|
111
|
-
|
|
112
|
-
|
|
110
|
+
if (!P.shouldWriteToUrl) return;
|
|
111
|
+
let t = e(O, {
|
|
112
|
+
...I,
|
|
113
|
+
startTime: V ? I.startTime : z,
|
|
114
|
+
endTime: V ? I.endTime : B
|
|
113
115
|
});
|
|
114
|
-
if (t.toString() ===
|
|
115
|
-
|
|
116
|
+
if (t.toString() === O.toString()) {
|
|
117
|
+
F((e) => e.shouldWriteToUrl ? {
|
|
116
118
|
...e,
|
|
117
119
|
shouldWriteToUrl: !1
|
|
118
120
|
} : e);
|
|
119
121
|
return;
|
|
120
122
|
}
|
|
121
|
-
|
|
123
|
+
k(t, { replace: !0 });
|
|
122
124
|
}, [
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
H,
|
|
125
|
+
I,
|
|
126
|
+
P.shouldWriteToUrl,
|
|
126
127
|
V,
|
|
127
128
|
B,
|
|
128
|
-
|
|
129
|
-
|
|
129
|
+
z,
|
|
130
|
+
O,
|
|
131
|
+
k
|
|
130
132
|
]), f(() => {
|
|
131
|
-
ee(
|
|
132
|
-
...
|
|
133
|
-
|
|
134
|
-
|
|
133
|
+
ee(S, {
|
|
134
|
+
...I,
|
|
135
|
+
startTime: z,
|
|
136
|
+
endTime: B
|
|
135
137
|
});
|
|
136
138
|
}, [
|
|
137
|
-
|
|
138
|
-
V,
|
|
139
|
+
I,
|
|
139
140
|
B,
|
|
140
|
-
|
|
141
|
+
z,
|
|
142
|
+
S
|
|
141
143
|
]);
|
|
142
|
-
let
|
|
144
|
+
let H = p(() => Ke([...E, ...D]), [D, E]), [ft, U] = h([]);
|
|
143
145
|
f(() => {
|
|
144
|
-
if (!
|
|
145
|
-
|
|
146
|
+
if (!S || H.length === 0) {
|
|
147
|
+
U([]);
|
|
146
148
|
return;
|
|
147
149
|
}
|
|
148
|
-
let e =
|
|
150
|
+
let e = R ? u(I) : null;
|
|
149
151
|
if (!e) {
|
|
150
|
-
|
|
152
|
+
U([]);
|
|
151
153
|
return;
|
|
152
154
|
}
|
|
153
155
|
let t = !1;
|
|
154
156
|
return (async () => {
|
|
155
157
|
try {
|
|
156
|
-
let n = await
|
|
157
|
-
storeSlug:
|
|
158
|
+
let n = await Ce(oe, {
|
|
159
|
+
storeSlug: S,
|
|
158
160
|
schedule: e,
|
|
159
|
-
products:
|
|
160
|
-
}), r =
|
|
161
|
+
products: H
|
|
162
|
+
}), r = ue.parse(n);
|
|
161
163
|
if (t) return;
|
|
162
|
-
|
|
164
|
+
U(r.success ? r.availability ?? [] : []);
|
|
163
165
|
} catch (e) {
|
|
164
166
|
if (t) return;
|
|
165
167
|
console.error("Failed to load storefront availability", e);
|
|
@@ -168,53 +170,47 @@ function S() {
|
|
|
168
170
|
t = !0;
|
|
169
171
|
};
|
|
170
172
|
}, [
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
173
|
+
H,
|
|
174
|
+
I.endDate,
|
|
175
|
+
I.endTime,
|
|
176
|
+
I.startDate,
|
|
177
|
+
I.startTime,
|
|
178
|
+
R,
|
|
179
|
+
S
|
|
178
180
|
]);
|
|
179
|
-
let
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
}), [
|
|
186
|
-
let
|
|
187
|
-
return
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
closeDrawer: v("booking_date_drawer_close"),
|
|
208
|
-
timeSlotsLoading: v("booking_time_slots_loading"),
|
|
209
|
-
timeSlotsUnavailable: v("booking_time_slots_unavailable"),
|
|
210
|
-
timeSlotsLoadError: v("booking_time_slots_load_error"),
|
|
211
|
-
retryTimeSlots: v("booking_time_slots_retry")
|
|
212
|
-
}), [S.language, v]), q = (e) => {
|
|
181
|
+
let W = p(() => new Map(ft.map((e) => [c(e.productId, e.productVariantId), e])), [ft]), G = p(() => E.map((e) => ({
|
|
182
|
+
...e,
|
|
183
|
+
availabilityStatus: Ue(e, W)
|
|
184
|
+
})), [W, E]), pt = p(() => D.map((e) => ({
|
|
185
|
+
...e,
|
|
186
|
+
availabilityStatus: Ue(e, W)
|
|
187
|
+
})), [D, W]), mt = (e, t) => {
|
|
188
|
+
let n = We(e, t, W);
|
|
189
|
+
return n ? le(n) : e.availabilityStatus === "OUT_OF_STOCK";
|
|
190
|
+
}, ht = (e) => (e.productVariants ?? []).length > 0, gt = (e, t) => {
|
|
191
|
+
let n = We(e, t, W);
|
|
192
|
+
return n ? Ge(l, n, ce(n)) : e.availabilityStatus === "OUT_OF_STOCK" ? l("availability_out_of_stock") : null;
|
|
193
|
+
}, _t = we(S), vt = p(() => ({
|
|
194
|
+
startDate: l("booking_start_date"),
|
|
195
|
+
pickStartDate: l("booking_start_date"),
|
|
196
|
+
startTime: l("booking_start_time"),
|
|
197
|
+
endDate: l("booking_end_date"),
|
|
198
|
+
pickEndDate: l("booking_end_date"),
|
|
199
|
+
endTime: l("booking_end_time"),
|
|
200
|
+
selectedDaysTooltip: ({ count: e }) => l("booking_selected_days_tooltip", { count: e }),
|
|
201
|
+
rentalPeriod: l("booking_rental_period"),
|
|
202
|
+
dateDrawerNext: l("booking_date_drawer_continue"),
|
|
203
|
+
closeDrawer: l("booking_date_drawer_close"),
|
|
204
|
+
timeSlotsLoading: l("booking_time_slots_loading"),
|
|
205
|
+
timeSlotsUnavailable: l("booking_time_slots_unavailable"),
|
|
206
|
+
timeSlotsLoadError: l("booking_time_slots_load_error"),
|
|
207
|
+
retryTimeSlots: l("booking_time_slots_retry")
|
|
208
|
+
}), [v.language, l]), K = (e) => {
|
|
213
209
|
let t = {
|
|
214
|
-
...
|
|
210
|
+
...I,
|
|
215
211
|
...e
|
|
216
212
|
};
|
|
217
|
-
b(
|
|
213
|
+
b(I, t) || F((t) => {
|
|
218
214
|
let n = {
|
|
219
215
|
...t.booking,
|
|
220
216
|
...e
|
|
@@ -224,74 +220,74 @@ function S() {
|
|
|
224
220
|
shouldWriteToUrl: !0
|
|
225
221
|
};
|
|
226
222
|
});
|
|
227
|
-
},
|
|
228
|
-
startDate:
|
|
223
|
+
}, yt = {
|
|
224
|
+
startDate: L,
|
|
229
225
|
onStartDateChange: (e) => {
|
|
230
|
-
e &&
|
|
226
|
+
e && K({ startDate: Be(e) });
|
|
231
227
|
},
|
|
232
|
-
startTime:
|
|
233
|
-
onStartTimeChange: (e) =>
|
|
234
|
-
endDate:
|
|
228
|
+
startTime: I.startTime,
|
|
229
|
+
onStartTimeChange: (e) => K({ startTime: e }),
|
|
230
|
+
endDate: ot,
|
|
235
231
|
onEndDateChange: (e) => {
|
|
236
|
-
e &&
|
|
232
|
+
e && K({ endDate: Be(e) });
|
|
237
233
|
},
|
|
238
|
-
endTime:
|
|
239
|
-
onEndTimeChange: (e) =>
|
|
240
|
-
bookingPeriodConfig:
|
|
234
|
+
endTime: I.endTime,
|
|
235
|
+
onEndTimeChange: (e) => K({ endTime: e }),
|
|
236
|
+
bookingPeriodConfig: tt,
|
|
241
237
|
withMobileDateDrawer: !0,
|
|
242
|
-
fetchTimeSlots:
|
|
238
|
+
fetchTimeSlots: _t,
|
|
243
239
|
onTimeSlotsConfirmationChange: (e) => {
|
|
244
|
-
let t = e ?
|
|
245
|
-
|
|
240
|
+
let t = e ? ut.current : void 0;
|
|
241
|
+
lt.current !== t && (lt.current = t, F((e) => e.shouldWriteToUrl ? e : {
|
|
246
242
|
...e,
|
|
247
243
|
shouldWriteToUrl: !0
|
|
248
|
-
}),
|
|
244
|
+
}), ct(t));
|
|
249
245
|
},
|
|
250
|
-
labels:
|
|
251
|
-
localeCode:
|
|
252
|
-
},
|
|
253
|
-
items:
|
|
254
|
-
language:
|
|
255
|
-
fallbackLanguage:
|
|
246
|
+
labels: vt,
|
|
247
|
+
localeCode: v.language
|
|
248
|
+
}, bt = re(I, w.bookingEngine.pricing, w.bookingEngine.shop.timeZone)?.billableUnitCount, q = p(() => ae({
|
|
249
|
+
items: Xe,
|
|
250
|
+
language: v.language,
|
|
251
|
+
fallbackLanguage: T,
|
|
256
252
|
products: {
|
|
257
|
-
bikes:
|
|
258
|
-
accessories:
|
|
253
|
+
bikes: Je,
|
|
254
|
+
accessories: Ye
|
|
259
255
|
},
|
|
260
|
-
priceUnit:
|
|
261
|
-
billableUnitCount:
|
|
256
|
+
priceUnit: M,
|
|
257
|
+
billableUnitCount: bt
|
|
262
258
|
}), [
|
|
263
|
-
|
|
264
|
-
Je,
|
|
265
|
-
qe,
|
|
266
|
-
S.language,
|
|
259
|
+
bt,
|
|
267
260
|
Ye,
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
261
|
+
Je,
|
|
262
|
+
v.language,
|
|
263
|
+
Xe,
|
|
264
|
+
M,
|
|
265
|
+
T
|
|
266
|
+
]), J = p(() => q.lines.map((e) => ({
|
|
271
267
|
productId: e.checkoutProductId,
|
|
272
268
|
productVariantId: e.productVariantId,
|
|
273
269
|
quantity: e.quantity
|
|
274
|
-
})), [
|
|
270
|
+
})), [q.lines]), [xt, Y] = h([]);
|
|
275
271
|
f(() => {
|
|
276
|
-
if (!
|
|
277
|
-
|
|
272
|
+
if (!S || J.length === 0) {
|
|
273
|
+
Y([]);
|
|
278
274
|
return;
|
|
279
275
|
}
|
|
280
|
-
let e =
|
|
276
|
+
let e = R ? u(I) : null;
|
|
281
277
|
if (!e) {
|
|
282
|
-
|
|
278
|
+
Y([]);
|
|
283
279
|
return;
|
|
284
280
|
}
|
|
285
281
|
let t = !1;
|
|
286
282
|
return (async () => {
|
|
287
283
|
try {
|
|
288
|
-
let n = await
|
|
289
|
-
storeSlug:
|
|
284
|
+
let n = await Ce(oe, {
|
|
285
|
+
storeSlug: S,
|
|
290
286
|
schedule: e,
|
|
291
|
-
products:
|
|
292
|
-
}), r =
|
|
287
|
+
products: J
|
|
288
|
+
}), r = ue.parse(n);
|
|
293
289
|
if (t) return;
|
|
294
|
-
|
|
290
|
+
Y(r.success ? r.availability ?? [] : []);
|
|
295
291
|
} catch (e) {
|
|
296
292
|
if (t) return;
|
|
297
293
|
console.error("Failed to load storefront cart availability", e);
|
|
@@ -300,17 +296,17 @@ function S() {
|
|
|
300
296
|
t = !0;
|
|
301
297
|
};
|
|
302
298
|
}, [
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
299
|
+
I.endDate,
|
|
300
|
+
I.endTime,
|
|
301
|
+
I.startDate,
|
|
302
|
+
I.startTime,
|
|
303
|
+
R,
|
|
304
|
+
J,
|
|
305
|
+
S
|
|
310
306
|
]);
|
|
311
|
-
let St = p(() => new Map(
|
|
312
|
-
...
|
|
313
|
-
lines:
|
|
307
|
+
let St = p(() => new Map(xt.map((e) => [c(e.productId, e.productVariantId), e])), [xt]), Ct = p(() => ({
|
|
308
|
+
...q,
|
|
309
|
+
lines: q.lines.map((e) => {
|
|
314
310
|
let t = St.get(c(e.checkoutProductId, e.productVariantId)), n = t ? se(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
|
|
315
311
|
return {
|
|
316
312
|
...e,
|
|
@@ -318,30 +314,30 @@ function S() {
|
|
|
318
314
|
availabilityIssue: n
|
|
319
315
|
};
|
|
320
316
|
})
|
|
321
|
-
}), [St,
|
|
322
|
-
...
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
}).toString(), Z =
|
|
326
|
-
let t = new URLSearchParams(
|
|
327
|
-
e?.trim() ? t.set(y, e) : t.delete(y),
|
|
317
|
+
}), [St, q]), X = e(new URLSearchParams(), {
|
|
318
|
+
...I,
|
|
319
|
+
startTime: z,
|
|
320
|
+
endTime: B
|
|
321
|
+
}).toString(), Z = R && u(I) !== null, wt = `/${S ?? ""}${X ? `?${X}` : ""}`, Tt = `/${S ?? ""}/booking${X ? `?${X}` : ""}`, Et = `/${S ?? ""}/checkout${X ? `?${X}` : ""}`, Dt = { backTo: `${C.pathname}${C.search}${C.hash}` }, [Ot, kt] = h(null), At = G.findIndex((e) => e.id === Ot), jt = O.get(y)?.trim() ?? "", Q = jt ? G.find((e) => e.id === jt) ?? pt.find((e) => e.id === jt) ?? null : null, $ = (e) => {
|
|
322
|
+
let t = new URLSearchParams(O);
|
|
323
|
+
e?.trim() ? t.set(y, e) : t.delete(y), k(t, { replace: !0 });
|
|
328
324
|
}, Mt = (e) => {
|
|
329
325
|
x(e) && $(e.id);
|
|
330
326
|
}, Nt = (e, t, n = 1) => {
|
|
331
327
|
if (!Z) return;
|
|
332
328
|
let r = Math.max(1, Math.floor(n));
|
|
333
|
-
|
|
329
|
+
Qe({
|
|
334
330
|
kind: e.kind,
|
|
335
331
|
productId: s(e),
|
|
336
332
|
...t ? { productVariantId: t } : {},
|
|
337
333
|
quantity: r
|
|
338
|
-
}),
|
|
334
|
+
}), ge.success(l("product_added_to_cart_successfully", {
|
|
339
335
|
quantity: r,
|
|
340
336
|
productName: te({
|
|
341
337
|
product: e,
|
|
342
338
|
productVariantId: t,
|
|
343
|
-
language:
|
|
344
|
-
fallbackLanguage:
|
|
339
|
+
language: v.language,
|
|
340
|
+
fallbackLanguage: T
|
|
345
341
|
})
|
|
346
342
|
}));
|
|
347
343
|
}, Pt = (e) => {
|
|
@@ -356,13 +352,13 @@ function S() {
|
|
|
356
352
|
Nt(e, n);
|
|
357
353
|
}
|
|
358
354
|
};
|
|
359
|
-
return /* @__PURE__ */ _(
|
|
355
|
+
return /* @__PURE__ */ _(Ae, { children: [/* @__PURE__ */ g(Ee, {
|
|
360
356
|
currentStep: "booking",
|
|
361
357
|
bookingPath: Tt,
|
|
362
358
|
checkoutPath: Et,
|
|
363
|
-
checkoutEnabled:
|
|
359
|
+
checkoutEnabled: Ze > 0 && Z,
|
|
364
360
|
backPath: wt,
|
|
365
|
-
backLabel:
|
|
361
|
+
backLabel: l("back_to_home"),
|
|
366
362
|
children: /* @__PURE__ */ _("div", {
|
|
367
363
|
className: "grid gap-6 lg:grid-cols-12",
|
|
368
364
|
children: [/* @__PURE__ */ g("div", {
|
|
@@ -375,53 +371,55 @@ function S() {
|
|
|
375
371
|
children: [
|
|
376
372
|
/* @__PURE__ */ g(d, {
|
|
377
373
|
stepNumber: 1,
|
|
378
|
-
title:
|
|
374
|
+
title: l("booking_summary_title")
|
|
379
375
|
}),
|
|
380
|
-
/* @__PURE__ */ g(
|
|
381
|
-
...
|
|
376
|
+
/* @__PURE__ */ g(_e, {
|
|
377
|
+
...yt,
|
|
382
378
|
className: "gap-3",
|
|
383
379
|
labelClassName: "text-xs font-medium text-slate-700",
|
|
384
380
|
inputClassName: "h-10"
|
|
385
381
|
}),
|
|
386
|
-
/* @__PURE__ */ g(
|
|
387
|
-
value:
|
|
388
|
-
onValueChange: (e) =>
|
|
389
|
-
pickupAddress:
|
|
390
|
-
deliveryEnabled:
|
|
391
|
-
deliveryDisabledReason:
|
|
392
|
-
startAddress:
|
|
393
|
-
onStartAddressChange: (e) =>
|
|
394
|
-
endAddress:
|
|
395
|
-
onEndAddressChange: (e) =>
|
|
382
|
+
/* @__PURE__ */ g(Te, {
|
|
383
|
+
value: I.fulfillment,
|
|
384
|
+
onValueChange: (e) => K({ fulfillment: e }),
|
|
385
|
+
pickupAddress: rt,
|
|
386
|
+
deliveryEnabled: j,
|
|
387
|
+
deliveryDisabledReason: nt,
|
|
388
|
+
startAddress: I.startAddress,
|
|
389
|
+
onStartAddressChange: (e) => K({ startAddress: e }),
|
|
390
|
+
endAddress: I.endAddress,
|
|
391
|
+
onEndAddressChange: (e) => K({ endAddress: e }),
|
|
396
392
|
showPickupAddressWhenPickupOnly: !1,
|
|
397
393
|
testIdPrefix: "storefront-booking-fulfillment"
|
|
398
394
|
})
|
|
399
395
|
]
|
|
400
396
|
}),
|
|
401
397
|
/* @__PURE__ */ _("div", {
|
|
402
|
-
ref:
|
|
398
|
+
ref: qe,
|
|
403
399
|
id: "booking-products",
|
|
404
400
|
className: "space-y-2 scroll-mt-32",
|
|
405
401
|
children: [/* @__PURE__ */ g(d, {
|
|
406
402
|
stepNumber: 2,
|
|
407
|
-
title:
|
|
403
|
+
title: l("products_title")
|
|
408
404
|
}), /* @__PURE__ */ g("p", {
|
|
409
405
|
className: "text-sm text-slate-600",
|
|
410
|
-
children: /* @__PURE__ */ g("span", { children:
|
|
406
|
+
children: /* @__PURE__ */ g("span", { children: l("products_description") })
|
|
411
407
|
})]
|
|
412
408
|
}),
|
|
413
409
|
/* @__PURE__ */ g("div", {
|
|
414
410
|
className: "grid gap-4 md:grid-cols-2",
|
|
415
|
-
children:
|
|
416
|
-
let n = `/${
|
|
417
|
-
return /* @__PURE__ */ g(
|
|
411
|
+
children: G.map((e, t) => {
|
|
412
|
+
let n = `/${S ?? ""}/products/${e.slug}`, r = !!x(e) || ht(e);
|
|
413
|
+
return /* @__PURE__ */ g(De, {
|
|
418
414
|
bike: e,
|
|
419
415
|
detailsPath: n,
|
|
420
416
|
productDetailsLinkState: Dt,
|
|
421
417
|
onAction: () => Pt(e),
|
|
422
418
|
actionDisabled: !r || !Z,
|
|
423
|
-
fallbackLanguage:
|
|
424
|
-
|
|
419
|
+
fallbackLanguage: T,
|
|
420
|
+
getVariantAvailabilityLabel: (t) => gt(e, t),
|
|
421
|
+
isVariantOutOfCapacity: (t) => mt(e, t),
|
|
422
|
+
dimOnColumnCount: ze(At, t),
|
|
425
423
|
onQuickAdd: (t, n) => Nt(e, t, n),
|
|
426
424
|
onHoverStart: () => kt(e.id),
|
|
427
425
|
onHoverEnd: () => {
|
|
@@ -435,24 +433,24 @@ function S() {
|
|
|
435
433
|
className: "space-y-2 pt-4",
|
|
436
434
|
children: [/* @__PURE__ */ g(d, {
|
|
437
435
|
stepNumber: 3,
|
|
438
|
-
title:
|
|
436
|
+
title: l("accessories_title")
|
|
439
437
|
}), /* @__PURE__ */ g("p", {
|
|
440
438
|
className: "text-sm text-slate-600",
|
|
441
|
-
children: /* @__PURE__ */ g("span", { children:
|
|
439
|
+
children: /* @__PURE__ */ g("span", { children: l("accessories_description") })
|
|
442
440
|
})]
|
|
443
441
|
}),
|
|
444
442
|
/* @__PURE__ */ g("div", {
|
|
445
443
|
className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
|
|
446
|
-
children:
|
|
447
|
-
let t = o(e.name,
|
|
448
|
-
return /* @__PURE__ */ g(
|
|
444
|
+
children: pt.map((e) => {
|
|
445
|
+
let t = o(e.name, v.language, T), n = o(e.description, v.language, T), r = o(e.warning, v.language, T), i = typeof e.images?.[0] == "string" ? e.images[0].trim() : "", a = Se(e.primaryImageStyle), ee = `/${S ?? ""}/products/${e.slug}`, s = x(e), te = e.availabilityStatus === "OUT_OF_STOCK", ne = !!s || ht(e);
|
|
446
|
+
return /* @__PURE__ */ g(ve, {
|
|
449
447
|
"data-testid": `storefront-booking-accessory-card-${e.id}`.toLowerCase(),
|
|
450
448
|
className: "h-full border-slate-200 bg-white shadow-sm transition-[border-color,box-shadow] duration-200 hover:border-primary/20 hover:shadow-md",
|
|
451
449
|
children: /* @__PURE__ */ _("div", {
|
|
452
450
|
className: "flex h-full flex-col gap-2 p-3",
|
|
453
451
|
children: [
|
|
454
452
|
/* @__PURE__ */ _("div", {
|
|
455
|
-
className:
|
|
453
|
+
className: Ie("relative aspect-[1618/1000] overflow-hidden rounded-xl", a.className),
|
|
456
454
|
style: a.style,
|
|
457
455
|
children: [i ? /* @__PURE__ */ g("img", {
|
|
458
456
|
src: i,
|
|
@@ -461,14 +459,14 @@ function S() {
|
|
|
461
459
|
loading: "lazy"
|
|
462
460
|
}) : /* @__PURE__ */ g("div", {
|
|
463
461
|
className: "absolute inset-0 flex items-center justify-center text-slate-400",
|
|
464
|
-
children: /* @__PURE__ */ g(
|
|
462
|
+
children: /* @__PURE__ */ g(Le, {
|
|
465
463
|
className: "h-8 w-8",
|
|
466
464
|
"aria-hidden": "true"
|
|
467
465
|
})
|
|
468
|
-
}), te ? /* @__PURE__ */ g(
|
|
466
|
+
}), te ? /* @__PURE__ */ g(de, {
|
|
469
467
|
variant: "destructive",
|
|
470
468
|
className: "pointer-events-none absolute right-2 top-2 shadow-sm",
|
|
471
|
-
children: /* @__PURE__ */ g("span", { children:
|
|
469
|
+
children: /* @__PURE__ */ g("span", { children: l("availability_out_of_stock") })
|
|
472
470
|
}) : null]
|
|
473
471
|
}),
|
|
474
472
|
/* @__PURE__ */ _("div", {
|
|
@@ -479,7 +477,7 @@ function S() {
|
|
|
479
477
|
children: [/* @__PURE__ */ g("p", {
|
|
480
478
|
className: "min-w-0 text-sm font-semibold text-slate-950",
|
|
481
479
|
children: /* @__PURE__ */ g("span", { children: t })
|
|
482
|
-
}), /* @__PURE__ */ g(
|
|
480
|
+
}), /* @__PURE__ */ g(xe, {
|
|
483
481
|
prices: e.prices,
|
|
484
482
|
className: "shrink-0",
|
|
485
483
|
openOnHover: !1
|
|
@@ -489,7 +487,7 @@ function S() {
|
|
|
489
487
|
className: "line-clamp-2 text-xs text-slate-600",
|
|
490
488
|
children: /* @__PURE__ */ g("span", { children: n })
|
|
491
489
|
}),
|
|
492
|
-
/* @__PURE__ */ g(
|
|
490
|
+
/* @__PURE__ */ g(ye, {
|
|
493
491
|
warning: r,
|
|
494
492
|
className: "mt-1"
|
|
495
493
|
})
|
|
@@ -497,18 +495,18 @@ function S() {
|
|
|
497
495
|
}),
|
|
498
496
|
/* @__PURE__ */ _("div", {
|
|
499
497
|
className: "mt-auto flex items-center gap-2",
|
|
500
|
-
children: [/* @__PURE__ */ g(
|
|
498
|
+
children: [/* @__PURE__ */ g(je, {
|
|
501
499
|
to: ee,
|
|
502
500
|
state: Dt,
|
|
503
501
|
className: "text-xs font-medium text-slate-700 hover:text-slate-950",
|
|
504
|
-
children: /* @__PURE__ */ g("span", { children:
|
|
505
|
-
}), /* @__PURE__ */ _(
|
|
502
|
+
children: /* @__PURE__ */ g("span", { children: l("product_details_link") })
|
|
503
|
+
}), /* @__PURE__ */ _(fe, {
|
|
506
504
|
type: "button",
|
|
507
505
|
size: "sm",
|
|
508
506
|
className: "ml-auto gap-2",
|
|
509
507
|
onClick: () => Ft(e),
|
|
510
508
|
disabled: !ne || !Z,
|
|
511
|
-
children: [/* @__PURE__ */ g("span", { children:
|
|
509
|
+
children: [/* @__PURE__ */ g("span", { children: l("add_to_cart") }), /* @__PURE__ */ g(Re, {
|
|
512
510
|
className: "h-4 w-4",
|
|
513
511
|
"aria-hidden": "true"
|
|
514
512
|
})]
|
|
@@ -523,28 +521,28 @@ function S() {
|
|
|
523
521
|
})
|
|
524
522
|
}), /* @__PURE__ */ g("div", {
|
|
525
523
|
className: "min-w-0 lg:col-span-4",
|
|
526
|
-
children: /* @__PURE__ */ g(
|
|
524
|
+
children: /* @__PURE__ */ g(be, {
|
|
527
525
|
lines: Ct.lines,
|
|
528
|
-
itemCount:
|
|
529
|
-
baseUnitLabel:
|
|
526
|
+
itemCount: Ze,
|
|
527
|
+
baseUnitLabel: it,
|
|
530
528
|
totalMinor: Ct.totalMinor,
|
|
531
529
|
checkoutPath: Et,
|
|
532
530
|
showCheckoutAction: Z,
|
|
533
531
|
editable: !0,
|
|
534
532
|
stickyTopClassName: "top-32",
|
|
535
|
-
onQuantityChange:
|
|
536
|
-
onRemove:
|
|
533
|
+
onQuantityChange: et,
|
|
534
|
+
onRemove: $e
|
|
537
535
|
})
|
|
538
536
|
})]
|
|
539
537
|
})
|
|
540
|
-
}), /* @__PURE__ */ g(
|
|
538
|
+
}), /* @__PURE__ */ g(Oe, {
|
|
541
539
|
open: !!Q,
|
|
542
540
|
product: Q,
|
|
543
541
|
onOpenChange: (e) => {
|
|
544
542
|
e || $(null);
|
|
545
543
|
},
|
|
546
|
-
getVariantAvailabilityLabel: (e) => Q ?
|
|
547
|
-
isVariantOutOfCapacity: (e) => Q ?
|
|
544
|
+
getVariantAvailabilityLabel: (e) => Q ? gt(Q, e) : null,
|
|
545
|
+
isVariantOutOfCapacity: (e) => Q ? mt(Q, e) : !1,
|
|
548
546
|
addDisabled: !Z,
|
|
549
547
|
onAddVariant: (e, t) => {
|
|
550
548
|
Q && (Nt(Q, e, t), $(null));
|