@loczer/storefront-sdk 0.220.0 → 0.222.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.
Files changed (47) hide show
  1. package/dist/StorefrontContext.d.ts +2 -2
  2. package/dist/StorefrontProvider.d.ts +2 -2
  3. package/dist/components/Header/index.d.ts.map +1 -1
  4. package/dist/components/Header/index.js +118 -126
  5. package/dist/components/LanguageSelector/index.d.ts +7 -0
  6. package/dist/components/LanguageSelector/index.d.ts.map +1 -0
  7. package/dist/components/LanguageSelector/index.js +69 -0
  8. package/dist/components/StorefrontCartPanel/index.d.ts +3 -8
  9. package/dist/components/StorefrontCartPanel/index.d.ts.map +1 -1
  10. package/dist/components/StorefrontCartPanel/index.js +65 -108
  11. package/dist/i18n/I18nProvider.d.ts +3 -2
  12. package/dist/i18n/I18nProvider.d.ts.map +1 -1
  13. package/dist/i18n/I18nProvider.js +61 -64
  14. package/dist/i18n/en.d.ts +3 -2
  15. package/dist/i18n/en.d.ts.map +1 -1
  16. package/dist/i18n/en.js +6 -5
  17. package/dist/i18n/fr.d.ts +3 -2
  18. package/dist/i18n/fr.d.ts.map +1 -1
  19. package/dist/i18n/fr.js +6 -5
  20. package/dist/i18n/languages.d.ts +15 -0
  21. package/dist/i18n/languages.d.ts.map +1 -0
  22. package/dist/i18n/languages.js +26 -0
  23. package/dist/index.d.ts +36 -24
  24. package/dist/index.js +50 -49
  25. package/dist/lib/cartSummary.d.ts +2 -5
  26. package/dist/lib/cartSummary.d.ts.map +1 -1
  27. package/dist/lib/cartSummary.js +5 -11
  28. package/dist/pages/BookingPage.d.ts.map +1 -1
  29. package/dist/pages/BookingPage.js +150 -148
  30. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  31. package/dist/pages/CheckoutPage.js +236 -272
  32. package/dist/pages/ContractSaleDocumentPage.d.ts +2 -3
  33. package/dist/pages/ContractSaleDocumentPage.d.ts.map +1 -1
  34. package/dist/pages/ContractSaleDocumentPage.js +18 -17
  35. package/dist/pages/checkout/components/CheckoutDetailsCard.d.ts.map +1 -1
  36. package/dist/pages/checkout/components/CheckoutDetailsCard.js +38 -25
  37. package/dist/pages/checkout/components/CheckoutSummaryColumn.d.ts +6 -2
  38. package/dist/pages/checkout/components/CheckoutSummaryColumn.d.ts.map +1 -1
  39. package/dist/pages/checkout/components/CheckoutSummaryColumn.js +48 -19
  40. package/dist/storefront.css +1 -1
  41. package/dist/storefrontSchemas.d.ts +2 -2
  42. package/dist/storefrontSchemas.d.ts.map +1 -1
  43. package/dist/storefrontSchemas.js +95 -94
  44. package/package.json +1 -1
  45. package/dist/pages/checkout/components/CheckoutPaymentSummaryCard.d.ts +0 -24
  46. package/dist/pages/checkout/components/CheckoutPaymentSummaryCard.d.ts.map +0 -1
  47. package/dist/pages/checkout/components/CheckoutPaymentSummaryCard.js +0 -158
@@ -2,37 +2,37 @@ import { applyBookingParamsToSearch as e, createBookingPeriodConfigFromStorefron
2
2
  import { getLocalizedValue as o } from "../localization.js";
3
3
  import { getStorefrontCheckoutProductId as s, getStorefrontProductSelectionDisplayName as te } from "../lib/products.js";
4
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";
5
+ import { calculateBookingRentalUnitSummary as re, getPricingUnitLabel as ie } from "../lib/pricing.js";
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 ce, responseSchema as le } from "../lib/storefrontAvailability.js";
8
+ import { Badge as ue } from "../ui/badge.js";
9
+ import { Button as de } from "../ui/button.js";
10
+ import { useStorefront as fe, useStorefrontBookingProducts as pe, useStorefrontProducts as me } from "../StorefrontContext.js";
11
+ import { toast as he } from "../lib/toast.js";
12
+ import { BookingPeriodSelector as ge } from "../components/BookingPeriodSelector/index.js";
13
13
  import { StepSectionTitle as d } from "../components/StepSectionTitle/index.js";
14
- import { Card as ge } from "../ui/card.js";
15
- import { ProductWarningNotice as _e } from "../components/ProductWarningNotice/index.js";
16
- import { StorefrontCartPanel as ve } from "../components/StorefrontCartPanel/index.js";
17
- import { ProductPriceBadge as ye } from "../components/ProductPriceBadge/index.js";
18
- import { resolveProductImageContainerStyle as be } from "../lib/productImageStyles.js";
19
- import { apiPost as xe } from "../lib/apiCall.js";
20
- import { createStorefrontTimeSlotsFetcher as Se } from "../lib/fetchStorefrontTimeSlots.js";
21
- import { FulfillmentSection as Ce } from "../components/FulfillmentSection/index.js";
22
- import { BookingFlowPageLayout as we } from "../components/BookingFlowPageLayout/index.js";
23
- import { BookingBikeQuickAddCard as Te } from "../components/BookingBikeQuickAddCard/index.js";
24
- import { BookingBikeVariantDialog as Ee } from "../components/BookingBikeVariantDialog/index.js";
25
- import { useEffect as f, useLayoutEffect as De, useMemo as p, useRef as m, useState as h } from "react";
26
- import { Fragment as Oe, jsx as g, jsxs as _ } from "react/jsx-runtime";
27
- import { Link as ke, useLocation as Ae, useParams as je, useSearchParams as Me } from "@rpcbase/router";
28
- import { useTranslation as Ne } from "react-i18next";
29
- import { cn as Pe } from "@rpcbase/ui";
30
- import { Bike as Fe, Plus as Ie } from "lucide-react";
14
+ import { Card as _e } from "../ui/card.js";
15
+ import { ProductWarningNotice as ve } from "../components/ProductWarningNotice/index.js";
16
+ import { StorefrontCartPanel as ye } from "../components/StorefrontCartPanel/index.js";
17
+ import { ProductPriceBadge as be } from "../components/ProductPriceBadge/index.js";
18
+ import { resolveProductImageContainerStyle as xe } from "../lib/productImageStyles.js";
19
+ import { apiPost as Se } from "../lib/apiCall.js";
20
+ import { createStorefrontTimeSlotsFetcher as Ce } from "../lib/fetchStorefrontTimeSlots.js";
21
+ import { FulfillmentSection as we } from "../components/FulfillmentSection/index.js";
22
+ import { BookingFlowPageLayout as Te } from "../components/BookingFlowPageLayout/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 f, useLayoutEffect as Oe, useMemo as p, useRef as m, useState as h } from "react";
26
+ import { Fragment as ke, jsx as g, jsxs as _ } from "react/jsx-runtime";
27
+ import { Link as Ae, useLocation as je, useParams as Me, useSearchParams as Ne } from "@rpcbase/router";
28
+ import { useTranslation as Pe } from "react-i18next";
29
+ import { cn as Fe } from "@rpcbase/ui";
30
+ import { Bike as Ie, Plus as Le } from "lucide-react";
31
31
  //#region src/pages/BookingPage.tsx
32
- var v = (e) => String(e).padStart(2, "0"), y = "product_modal", Le = (e, t) => {
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
- }, Re = (e) => `${e.getFullYear()}-${v(e.getMonth() + 1)}-${v(e.getDate())}`, ze = (e) => {
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;
@@ -42,20 +42,20 @@ var v = (e) => String(e).padStart(2, "0"), y = "product_modal", Le = (e, t) => {
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
- }, Be = (e, t) => e.fulfillment === "delivery" && !t ? {
45
+ }, Ve = (e, t) => e.fulfillment === "delivery" && !t ? {
46
46
  ...e,
47
47
  fulfillment: "pickup"
48
- } : e, Ve = (e, t) => {
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
- }, He = (e, t, n) => n.get(c(s(e), t)), Ue = (e, t, n) => {
56
- let r = oe(t);
55
+ }, Ue = (e, t, n) => n.get(c(s(e), t)), We = (e, t, n) => {
56
+ let r = se(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
- }, We = (e) => {
58
+ }, Ge = (e) => {
59
59
  let t = /* @__PURE__ */ new Map();
60
60
  for (let n of e) {
61
61
  let e = s(n);
@@ -73,28 +73,28 @@ 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 } = Ne(), { storeSlug: C } = je(), w = Ae(), Ge = m(null), { storefrontConfiguration: T } = de(), E = T.workspace?.workspaceLanguage, { bikes: Ke, accessories: qe } = pe(), { bikes: D, accessories: O } = fe(), [k, A] = Me(), { items: Je, itemCount: Ye, addItem: Xe, removeItem: Ze, setQuantity: Qe } = ne();
77
- De(() => {
78
- w.hash === "#booking-products" && Ge.current?.scrollIntoView({ block: "start" });
76
+ let { t: v, i18n: S } = Pe(), { storeSlug: C } = Me(), w = je(), Ke = m(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 } = ne();
77
+ Oe(() => {
78
+ w.hash === "#booking-products" && Ke.current?.scrollIntoView({ block: "start" });
79
79
  }, [w.hash]);
80
- let $e = p(() => t(T), [T]), j = p(() => r(T), [T]), M = T.settings.fulfillmentModes.includes("delivery"), et = T.settings.deliveryDisabledReason.trim(), tt = T.shop.address?.trim() ?? "", N = T.bookingEngine.pricing.baseUnit, nt = re(N, v), rt = i(k).toString(), P = p(() => a(new URLSearchParams(rt), C), [rt, C]), [F, I] = h(() => ({
81
- booking: Be(n(P, j), M),
80
+ let et = p(() => t(T), [T]), j = p(() => 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 = ie(N, v), it = i(k).toString(), P = p(() => a(new URLSearchParams(it), C), [it, C]), [F, I] = h(() => ({
81
+ booking: Ve(n(P, j), M),
82
82
  shouldWriteToUrl: !0
83
- })), L = F.booking, R = p(() => ze(L.start_date), [L.start_date]), it = p(() => ze(L.end_date) ?? R, [L.end_date, R]), [at, ot] = h(void 0), st = m(void 0), ct = m(""), lt = [
83
+ })), L = F.booking, R = p(() => Be(L.start_date), [L.start_date]), at = p(() => Be(L.end_date) ?? R, [L.end_date, R]), [ot, st] = h(void 0), ct = m(void 0), lt = m(""), ut = [
84
84
  L.start_date,
85
85
  L.start_time,
86
86
  L.end_date,
87
87
  L.end_time
88
88
  ].join(":");
89
- ct.current = lt;
90
- let z = at === lt, B = z ? L.start_time : "", V = z ? L.end_time : "", H = !z && k.get("start_date") === L.start_date && k.get("start_time") === L.start_time && k.get("end_date") === L.end_date && k.get("end_time") === L.end_time;
89
+ lt.current = ut;
90
+ let z = ot === ut, B = z ? L.start_time : "", V = z ? L.end_time : "", H = !z && k.get("start_date") === L.start_date && k.get("start_time") === L.start_time && k.get("end_date") === L.end_date && k.get("end_time") === L.end_time;
91
91
  f(() => {
92
92
  I((e) => {
93
93
  if (e.shouldWriteToUrl) return e;
94
94
  let t = {
95
95
  ...j,
96
96
  ...e.booking
97
- }, r = Be(n(P, t), M);
97
+ }, r = Ve(n(P, t), M);
98
98
  return {
99
99
  booking: b(e.booking, r) ? e.booking : r,
100
100
  shouldWriteToUrl: !0
@@ -139,7 +139,7 @@ function S() {
139
139
  B,
140
140
  C
141
141
  ]);
142
- let U = p(() => We([...D, ...O]), [O, D]), [ut, W] = h([]);
142
+ let U = p(() => Ge([...D, ...O]), [O, D]), [dt, W] = h([]);
143
143
  f(() => {
144
144
  if (!C || U.length === 0) {
145
145
  W([]);
@@ -153,11 +153,11 @@ function S() {
153
153
  let t = !1;
154
154
  return (async () => {
155
155
  try {
156
- let n = await xe(ae, {
156
+ let n = await Se(oe, {
157
157
  storeSlug: C,
158
158
  schedule: e,
159
159
  products: U
160
- }), r = ce.parse(n);
160
+ }), r = le.parse(n);
161
161
  if (t) return;
162
162
  W(r.success ? r.availability ?? [] : []);
163
163
  } catch (e) {
@@ -176,25 +176,25 @@ function S() {
176
176
  z,
177
177
  C
178
178
  ]);
179
- let G = p(() => new Map(ut.map((e) => [c(e.productId, e.productVariantId), e])), [ut]), K = p(() => D.map((e) => {
180
- let t = Ve(e, G);
179
+ let G = p(() => new Map(dt.map((e) => [c(e.productId, e.productVariantId), e])), [dt]), K = p(() => D.map((e) => {
180
+ let t = He(e, G);
181
181
  return {
182
182
  ...e,
183
183
  availabilityStatus: t ? l(t) : e.availabilityStatus ?? "AVAILABLE"
184
184
  };
185
- }), [G, D]), dt = p(() => O.map((e) => {
186
- let t = Ve(e, G);
185
+ }), [G, D]), ft = p(() => O.map((e) => {
186
+ let t = He(e, G);
187
187
  return {
188
188
  ...e,
189
189
  availabilityStatus: t ? l(t) : "AVAILABLE"
190
190
  };
191
- }), [O, G]), ft = (e, t) => {
192
- let n = He(e, t, G);
193
- return n ? se(n) : e.availabilityStatus === "OUT_OF_STOCK";
194
- }, pt = (e) => (e.productVariants ?? []).length > 0, mt = (e, t) => {
195
- let n = He(e, t, G);
196
- return n ? Ue(v, n, l(n)) : e.availabilityStatus === "OUT_OF_STOCK" ? v("availability_out_of_stock") : null;
197
- }, ht = Se(C), gt = p(() => ({
191
+ }), [O, G]), pt = (e, t) => {
192
+ let n = Ue(e, t, G);
193
+ return n ? ce(n) : e.availabilityStatus === "OUT_OF_STOCK";
194
+ }, mt = (e) => (e.productVariants ?? []).length > 0, ht = (e, t) => {
195
+ let n = Ue(e, t, G);
196
+ return n ? We(v, n, l(n)) : e.availabilityStatus === "OUT_OF_STOCK" ? v("availability_out_of_stock") : null;
197
+ }, gt = Ce(C), _t = p(() => ({
198
198
  startDate: v("booking_start_date"),
199
199
  pickStartDate: v("booking_start_date"),
200
200
  startTime: v("booking_start_time"),
@@ -224,72 +224,74 @@ function S() {
224
224
  shouldWriteToUrl: !0
225
225
  };
226
226
  });
227
- }, _t = {
227
+ }, vt = {
228
228
  startDate: R,
229
229
  onStartDateChange: (e) => {
230
- e && q({ start_date: Re(e) });
230
+ e && q({ start_date: ze(e) });
231
231
  },
232
232
  startTime: L.start_time,
233
233
  onStartTimeChange: (e) => q({ start_time: e }),
234
- endDate: it,
234
+ endDate: at,
235
235
  onEndDateChange: (e) => {
236
- e && q({ end_date: Re(e) });
236
+ e && q({ end_date: ze(e) });
237
237
  },
238
238
  endTime: L.end_time,
239
239
  onEndTimeChange: (e) => q({ end_time: e }),
240
- bookingPeriodConfig: $e,
240
+ bookingPeriodConfig: et,
241
241
  withMobileDateDrawer: !0,
242
- fetchTimeSlots: ht,
242
+ fetchTimeSlots: gt,
243
243
  onTimeSlotsConfirmationChange: (e) => {
244
- let t = e ? ct.current : void 0;
245
- st.current !== t && (st.current = t, I((e) => e.shouldWriteToUrl ? e : {
244
+ let t = e ? lt.current : void 0;
245
+ ct.current !== t && (ct.current = t, I((e) => e.shouldWriteToUrl ? e : {
246
246
  ...e,
247
247
  shouldWriteToUrl: !0
248
- }), ot(t));
248
+ }), st(t));
249
249
  },
250
- labels: gt,
250
+ labels: _t,
251
251
  localeCode: S.language
252
- }, J = p(() => ie({
253
- items: Je,
252
+ }, yt = re(L, T.bookingEngine.pricing, T.bookingEngine.shop.timeZone)?.billableUnitCount, J = p(() => ae({
253
+ items: Ye,
254
254
  language: S.language,
255
255
  fallbackLanguage: E,
256
256
  products: {
257
- bikes: Ke,
258
- accessories: qe
257
+ bikes: qe,
258
+ accessories: Je
259
259
  },
260
- priceUnit: N
260
+ priceUnit: N,
261
+ billableUnitCount: yt
261
262
  }), [
263
+ yt,
264
+ Je,
262
265
  qe,
263
- Ke,
264
266
  S.language,
265
- Je,
267
+ Ye,
266
268
  N,
267
269
  E
268
- ]), vt = p(() => J.lines.map((e) => ({
270
+ ]), Y = p(() => J.lines.map((e) => ({
269
271
  productId: e.checkoutProductId,
270
272
  productVariantId: e.productVariantId,
271
273
  quantity: e.quantity
272
- })), [J.lines]), [yt, bt] = h([]);
274
+ })), [J.lines]), [bt, xt] = h([]);
273
275
  f(() => {
274
- if (!C || vt.length === 0) {
275
- bt([]);
276
+ if (!C || Y.length === 0) {
277
+ xt([]);
276
278
  return;
277
279
  }
278
280
  let e = z ? u(L) : null;
279
281
  if (!e) {
280
- bt([]);
282
+ xt([]);
281
283
  return;
282
284
  }
283
285
  let t = !1;
284
286
  return (async () => {
285
287
  try {
286
- let n = await xe(ae, {
288
+ let n = await Se(oe, {
287
289
  storeSlug: C,
288
290
  schedule: e,
289
- products: vt
290
- }), r = ce.parse(n);
291
+ products: Y
292
+ }), r = le.parse(n);
291
293
  if (t) return;
292
- bt(r.success ? r.availability ?? [] : []);
294
+ xt(r.success ? r.availability ?? [] : []);
293
295
  } catch (e) {
294
296
  if (t) return;
295
297
  console.error("Failed to load storefront cart availability", e);
@@ -303,37 +305,37 @@ function S() {
303
305
  L.start_date,
304
306
  L.start_time,
305
307
  z,
306
- vt,
308
+ Y,
307
309
  C
308
310
  ]);
309
- let xt = p(() => new Map(yt.map((e) => [c(e.productId, e.productVariantId), e])), [yt]), St = p(() => ({
311
+ let St = p(() => new Map(bt.map((e) => [c(e.productId, e.productVariantId), e])), [bt]), Ct = p(() => ({
310
312
  ...J,
311
313
  lines: J.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;
314
+ let t = St.get(c(e.checkoutProductId, e.productVariantId)), n = t ? se(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
313
315
  return {
314
316
  ...e,
315
317
  insufficientCapacity: n !== void 0,
316
318
  availabilityIssue: n
317
319
  };
318
320
  })
319
- }), [xt, J]), Y = e(new URLSearchParams(), {
321
+ }), [St, J]), X = e(new URLSearchParams(), {
320
322
  ...L,
321
323
  start_time: B,
322
324
  end_time: V
323
- }).toString(), X = z && u(L) !== null, Ct = `/${C ?? ""}${Y ? `?${Y}` : ""}`, wt = `/${C ?? ""}/booking${Y ? `?${Y}` : ""}`, Tt = `/${C ?? ""}/checkout${Y ? `?${Y}` : ""}`, Et = { backTo: `${w.pathname}${w.search}${w.hash}` }, [Dt, Ot] = h(null), kt = K.findIndex((e) => e.id === Dt), At = k.get(y)?.trim() ?? "", Z = At ? K.find((e) => e.id === At) ?? dt.find((e) => e.id === At) ?? null : null, Q = (e) => {
325
+ }).toString(), Z = z && u(L) !== null, wt = `/${C ?? ""}${X ? `?${X}` : ""}`, Tt = `/${C ?? ""}/booking${X ? `?${X}` : ""}`, Et = `/${C ?? ""}/checkout${X ? `?${X}` : ""}`, Dt = { backTo: `${w.pathname}${w.search}${w.hash}` }, [Ot, kt] = h(null), At = K.findIndex((e) => e.id === Ot), jt = k.get(y)?.trim() ?? "", Q = jt ? K.find((e) => e.id === jt) ?? ft.find((e) => e.id === jt) ?? null : null, $ = (e) => {
324
326
  let t = new URLSearchParams(k);
325
327
  e?.trim() ? t.set(y, e) : t.delete(y), A(t, { replace: !0 });
326
- }, jt = (e) => {
327
- x(e) && Q(e.id);
328
- }, $ = (e, t, n = 1) => {
329
- if (!X) return;
328
+ }, Mt = (e) => {
329
+ x(e) && $(e.id);
330
+ }, Nt = (e, t, n = 1) => {
331
+ if (!Z) return;
330
332
  let r = Math.max(1, Math.floor(n));
331
- Xe({
333
+ Ze({
332
334
  kind: e.kind,
333
335
  productId: s(e),
334
336
  ...t ? { productVariantId: t } : {},
335
337
  quantity: r
336
- }), me.success(v("product_added_to_cart_successfully", {
338
+ }), he.success(v("product_added_to_cart_successfully", {
337
339
  quantity: r,
338
340
  productName: te({
339
341
  product: e,
@@ -342,24 +344,24 @@ function S() {
342
344
  fallbackLanguage: E
343
345
  })
344
346
  }));
345
- }, Mt = (e) => {
346
- jt(e);
347
- }, Nt = (e) => {
347
+ }, Pt = (e) => {
348
+ Mt(e);
349
+ }, Ft = (e) => {
348
350
  let t = e.productVariants ?? [], n = x(e);
349
351
  if (n) {
350
352
  if (t.length > 1) {
351
- jt(e);
353
+ Mt(e);
352
354
  return;
353
355
  }
354
- $(e, n);
356
+ Nt(e, n);
355
357
  }
356
358
  };
357
- return /* @__PURE__ */ _(Oe, { children: [/* @__PURE__ */ g(we, {
359
+ return /* @__PURE__ */ _(ke, { children: [/* @__PURE__ */ g(Te, {
358
360
  currentStep: "booking",
359
- bookingPath: wt,
360
- checkoutPath: Tt,
361
- checkoutEnabled: Ye > 0 && X,
362
- backPath: Ct,
361
+ bookingPath: Tt,
362
+ checkoutPath: Et,
363
+ checkoutEnabled: Xe > 0 && Z,
364
+ backPath: wt,
363
365
  backLabel: v("back_to_home"),
364
366
  children: /* @__PURE__ */ _("div", {
365
367
  className: "grid gap-6 lg:grid-cols-12",
@@ -375,18 +377,18 @@ function S() {
375
377
  stepNumber: 1,
376
378
  title: v("booking_summary_title")
377
379
  }),
378
- /* @__PURE__ */ g(he, {
379
- ..._t,
380
+ /* @__PURE__ */ g(ge, {
381
+ ...vt,
380
382
  className: "gap-3",
381
383
  labelClassName: "text-xs font-medium text-slate-700",
382
384
  inputClassName: "h-10"
383
385
  }),
384
- /* @__PURE__ */ g(Ce, {
386
+ /* @__PURE__ */ g(we, {
385
387
  value: L.fulfillment,
386
388
  onValueChange: (e) => q({ fulfillment: e }),
387
- pickupAddress: tt,
389
+ pickupAddress: nt,
388
390
  deliveryEnabled: M,
389
- deliveryDisabledReason: et,
391
+ deliveryDisabledReason: tt,
390
392
  startAddress: L.start_address,
391
393
  onStartAddressChange: (e) => q({ start_address: e }),
392
394
  endAddress: L.end_address,
@@ -397,7 +399,7 @@ function S() {
397
399
  ]
398
400
  }),
399
401
  /* @__PURE__ */ _("div", {
400
- ref: Ge,
402
+ ref: Ke,
401
403
  id: "booking-products",
402
404
  className: "space-y-2 scroll-mt-32",
403
405
  children: [/* @__PURE__ */ g(d, {
@@ -411,19 +413,19 @@ function S() {
411
413
  /* @__PURE__ */ g("div", {
412
414
  className: "grid gap-4 md:grid-cols-2",
413
415
  children: K.map((e, t) => {
414
- let n = `/${C ?? ""}/products/${e.slug}`, r = !!x(e) || pt(e);
415
- return /* @__PURE__ */ g(Te, {
416
+ let n = `/${C ?? ""}/products/${e.slug}`, r = !!x(e) || mt(e);
417
+ return /* @__PURE__ */ g(Ee, {
416
418
  bike: e,
417
419
  detailsPath: n,
418
- productDetailsLinkState: Et,
419
- onAction: () => Mt(e),
420
- actionDisabled: !r || !X,
420
+ productDetailsLinkState: Dt,
421
+ onAction: () => Pt(e),
422
+ actionDisabled: !r || !Z,
421
423
  fallbackLanguage: E,
422
- dimOnColumnCount: Le(kt, t),
423
- onQuickAdd: (t, n) => $(e, t, n),
424
- onHoverStart: () => Ot(e.id),
424
+ dimOnColumnCount: Re(At, t),
425
+ onQuickAdd: (t, n) => Nt(e, t, n),
426
+ onHoverStart: () => kt(e.id),
425
427
  onHoverEnd: () => {
426
- Ot((t) => t === e.id ? null : t);
428
+ kt((t) => t === e.id ? null : t);
427
429
  },
428
430
  testId: `storefront-booking-bike-card-${e.id}`.toLowerCase()
429
431
  }, e.id);
@@ -441,16 +443,16 @@ function S() {
441
443
  }),
442
444
  /* @__PURE__ */ g("div", {
443
445
  className: "grid gap-4 sm:grid-cols-2 lg:grid-cols-3",
444
- children: dt.map((e) => {
445
- 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 = be(e.primaryImageStyle), ee = `/${C ?? ""}/products/${e.slug}`, s = x(e), te = e.availabilityStatus === "OUT_OF_STOCK", ne = !!s || pt(e);
446
- return /* @__PURE__ */ g(ge, {
446
+ children: ft.map((e) => {
447
+ 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 = xe(e.primaryImageStyle), ee = `/${C ?? ""}/products/${e.slug}`, s = x(e), te = e.availabilityStatus === "OUT_OF_STOCK", ne = !!s || mt(e);
448
+ return /* @__PURE__ */ g(_e, {
447
449
  "data-testid": `storefront-booking-accessory-card-${e.id}`.toLowerCase(),
448
450
  className: "h-full border-slate-200 bg-white shadow-sm transition-[border-color,box-shadow] duration-200 hover:border-primary/20 hover:shadow-md",
449
451
  children: /* @__PURE__ */ _("div", {
450
452
  className: "flex h-full flex-col gap-2 p-3",
451
453
  children: [
452
454
  /* @__PURE__ */ _("div", {
453
- className: Pe("relative aspect-[1618/1000] overflow-hidden rounded-xl", a.className),
455
+ className: Fe("relative aspect-[1618/1000] overflow-hidden rounded-xl", a.className),
454
456
  style: a.style,
455
457
  children: [i ? /* @__PURE__ */ g("img", {
456
458
  src: i,
@@ -459,11 +461,11 @@ function S() {
459
461
  loading: "lazy"
460
462
  }) : /* @__PURE__ */ g("div", {
461
463
  className: "absolute inset-0 flex items-center justify-center text-slate-400",
462
- children: /* @__PURE__ */ g(Fe, {
464
+ children: /* @__PURE__ */ g(Ie, {
463
465
  className: "h-8 w-8",
464
466
  "aria-hidden": "true"
465
467
  })
466
- }), te ? /* @__PURE__ */ g(le, {
468
+ }), te ? /* @__PURE__ */ g(ue, {
467
469
  variant: "destructive",
468
470
  className: "pointer-events-none absolute right-2 top-2 shadow-sm",
469
471
  children: /* @__PURE__ */ g("span", { children: v("availability_out_of_stock") })
@@ -477,7 +479,7 @@ function S() {
477
479
  children: [/* @__PURE__ */ g("p", {
478
480
  className: "min-w-0 text-sm font-semibold text-slate-950",
479
481
  children: /* @__PURE__ */ g("span", { children: t })
480
- }), /* @__PURE__ */ g(ye, {
482
+ }), /* @__PURE__ */ g(be, {
481
483
  prices: e.prices,
482
484
  className: "shrink-0",
483
485
  openOnHover: !1
@@ -487,7 +489,7 @@ function S() {
487
489
  className: "line-clamp-2 text-xs text-slate-600",
488
490
  children: /* @__PURE__ */ g("span", { children: n })
489
491
  }),
490
- /* @__PURE__ */ g(_e, {
492
+ /* @__PURE__ */ g(ve, {
491
493
  warning: r,
492
494
  className: "mt-1"
493
495
  })
@@ -495,18 +497,18 @@ function S() {
495
497
  }),
496
498
  /* @__PURE__ */ _("div", {
497
499
  className: "mt-auto flex items-center gap-2",
498
- children: [/* @__PURE__ */ g(ke, {
500
+ children: [/* @__PURE__ */ g(Ae, {
499
501
  to: ee,
500
- state: Et,
502
+ state: Dt,
501
503
  className: "text-xs font-medium text-slate-700 hover:text-slate-950",
502
504
  children: /* @__PURE__ */ g("span", { children: v("product_details_link") })
503
- }), /* @__PURE__ */ _(ue, {
505
+ }), /* @__PURE__ */ _(de, {
504
506
  type: "button",
505
507
  size: "sm",
506
508
  className: "ml-auto gap-2",
507
- onClick: () => Nt(e),
508
- disabled: !ne || !X,
509
- children: [/* @__PURE__ */ g("span", { children: v("add_to_cart") }), /* @__PURE__ */ g(Ie, {
509
+ onClick: () => Ft(e),
510
+ disabled: !ne || !Z,
511
+ children: [/* @__PURE__ */ g("span", { children: v("add_to_cart") }), /* @__PURE__ */ g(Le, {
510
512
  className: "h-4 w-4",
511
513
  "aria-hidden": "true"
512
514
  })]
@@ -521,31 +523,31 @@ function S() {
521
523
  })
522
524
  }), /* @__PURE__ */ g("div", {
523
525
  className: "min-w-0 lg:col-span-4",
524
- children: /* @__PURE__ */ g(ve, {
525
- lines: St.lines,
526
- itemCount: Ye,
527
- totalPerBaseUnitMinor: St.totalPerBaseUnitMinor,
528
- baseUnitLabel: nt,
529
- checkoutPath: Tt,
530
- showCheckoutAction: X,
526
+ children: /* @__PURE__ */ g(ye, {
527
+ lines: Ct.lines,
528
+ itemCount: Xe,
529
+ baseUnitLabel: rt,
530
+ totalMinor: Ct.totalMinor,
531
+ checkoutPath: Et,
532
+ showCheckoutAction: Z,
531
533
  editable: !0,
532
534
  stickyTopClassName: "top-32",
533
- onQuantityChange: Qe,
534
- onRemove: Ze
535
+ onQuantityChange: $e,
536
+ onRemove: Qe
535
537
  })
536
538
  })]
537
539
  })
538
- }), /* @__PURE__ */ g(Ee, {
539
- open: !!Z,
540
- product: Z,
540
+ }), /* @__PURE__ */ g(De, {
541
+ open: !!Q,
542
+ product: Q,
541
543
  onOpenChange: (e) => {
542
- e || Q(null);
544
+ e || $(null);
543
545
  },
544
- getVariantAvailabilityLabel: (e) => Z ? mt(Z, e) : null,
545
- isVariantOutOfCapacity: (e) => Z ? ft(Z, e) : !1,
546
- addDisabled: !X,
546
+ getVariantAvailabilityLabel: (e) => Q ? ht(Q, e) : null,
547
+ isVariantOutOfCapacity: (e) => Q ? pt(Q, e) : !1,
548
+ addDisabled: !Z,
547
549
  onAddVariant: (e, t) => {
548
- Z && ($(Z, e, t), Q(null));
550
+ Q && (Nt(Q, e, t), $(null));
549
551
  }
550
552
  })] });
551
553
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPage.tsx"],"names":[],"mappings":"AAuGA,MAAM,CAAC,OAAO,UAAU,YAAY,4CAysBnC"}
1
+ {"version":3,"file":"CheckoutPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPage.tsx"],"names":[],"mappings":"AAoFA,MAAM,CAAC,OAAO,UAAU,YAAY,4CAooBnC"}