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