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