@loczer/storefront-sdk 0.241.0 → 0.243.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 (33) hide show
  1. package/dist/chunks/pkg/booking-engine/dist/models/{Product.shared-VisFafx-.js → Product.shared-JIXwUVrg.js} +1 -1
  2. package/dist/chunks/pkg/booking-engine/dist/schemas/{base-asset-BuqI-BM_.js → base-asset-DtBfhenO.js} +1 -1
  3. package/dist/chunks/pkg/booking-engine/dist/schemas/{base-booking-gCY-ZP5p.js → base-booking-D9S-zS-D.js} +2 -2
  4. package/dist/chunks/pkg/booking-engine/dist/schemas/{base-product-r04ZJglB.js → base-product-Dj-bv0QD.js} +1 -1
  5. package/dist/chunks/pkg/booking-engine/dist/schemas/{cart-inputs-ps94yuAR.js → cart-inputs-CIeuiTzp.js} +1 -1
  6. package/dist/chunks/pkg/booking-engine/dist/schemas/{insurance-XwIj1m3Z.js → insurance-v2GZHSVq.js} +1 -1
  7. package/dist/chunks/pkg/booking-engine/dist/{schemas-7yx45S2o.js → schemas-B82mPOxs.js} +6 -6
  8. package/dist/components/Footer/businessHoursStatus.js +1 -1
  9. package/dist/i18n/en.d.ts +1 -0
  10. package/dist/i18n/en.d.ts.map +1 -1
  11. package/dist/i18n/en.js +2 -1
  12. package/dist/i18n/fr.d.ts +1 -0
  13. package/dist/i18n/fr.d.ts.map +1 -1
  14. package/dist/i18n/fr.js +2 -1
  15. package/dist/index.d.ts +2 -0
  16. package/dist/index.js +6 -6
  17. package/dist/lib/booking-period.js +1 -1
  18. package/dist/lib/booking.js +2 -2
  19. package/dist/lib/checkoutSubmit.d.ts +4 -0
  20. package/dist/lib/checkoutSubmit.d.ts.map +1 -1
  21. package/dist/lib/checkoutSubmit.js +19 -11
  22. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  23. package/dist/pages/CheckoutPage.js +199 -199
  24. package/dist/pages/CheckoutPaymentPage.d.ts.map +1 -1
  25. package/dist/pages/CheckoutPaymentPage.js +168 -167
  26. package/dist/pages/CheckoutSuccessPage.d.ts.map +1 -1
  27. package/dist/pages/CheckoutSuccessPage.js +37 -25
  28. package/dist/storefront.css +1 -1
  29. package/dist/storefrontSchemas.js +1 -1
  30. package/dist/ui/drawer.d.ts +12 -13
  31. package/dist/ui/drawer.d.ts.map +1 -1
  32. package/dist/ui/drawer.js +119 -143
  33. package/package.json +1 -1
@@ -2,31 +2,31 @@ import { applyBookingParamsToSearch as e, getBookingParamsFromSearch as t, pickB
2
2
  import { useStorefrontCart as ee } from "../lib/cart.js";
3
3
  import { calculateBookingRentalUnitSummary as te, getPricingUnitLabel as ne } from "../lib/pricing.js";
4
4
  import { buildStorefrontCartSummary as re } from "../lib/cartSummary.js";
5
- import { ROUTE as ie, responseSchema as ae } from "../lib/checkoutSubmit.js";
6
- import { ROUTE as oe, buildStorefrontAvailabilityKey as se, getStorefrontAvailabilityIssue as ce, getValidStorefrontAvailabilitySchedule as le, responseSchema as ue } from "../lib/storefrontAvailability.js";
7
- import { Button as de } from "../ui/button.js";
8
- import { useStorefront as fe, useStorefrontProducts as pe } from "../StorefrontContext.js";
5
+ import { ROUTE as ie, addCheckoutBookingNumberToPath as ae, responseSchema as oe } from "../lib/checkoutSubmit.js";
6
+ import { ROUTE as se, buildStorefrontAvailabilityKey as ce, getStorefrontAvailabilityIssue as le, getValidStorefrontAvailabilitySchedule as ue, responseSchema as de } from "../lib/storefrontAvailability.js";
7
+ import { Button as fe } from "../ui/button.js";
8
+ import { useStorefront as pe, useStorefrontProducts as me } from "../StorefrontContext.js";
9
9
  import { toast as a } from "../lib/toast.js";
10
10
  import { apiPost as o } from "../lib/apiCall.js";
11
- import { FulfillmentSection as me } from "../components/FulfillmentSection/index.js";
12
- import { BookingFlowPageLayout as he } from "../components/BookingFlowPageLayout/index.js";
13
- import { Spinner as ge } from "../chunks/pkg/ui/dist/Spinner/index-Cgi70z_E.js";
14
- import { ROUTE as _e, responseSchema as ve } from "../lib/checkoutPaymentDecision.js";
15
- import { ROUTE as ye, responseSchema as be } from "../lib/checkoutVerifyCoupon.js";
16
- import { CheckoutDetailsCard as xe } from "./checkout/components/CheckoutDetailsCard.js";
17
- import { CheckoutInsuranceCard as Se } from "./checkout/components/CheckoutInsuranceCard.js";
18
- import { CheckoutLoadingSkeleton as Ce } from "./checkout/components/CheckoutLoadingSkeleton.js";
19
- import { CheckoutMobileSummaryDrawer as we } from "./checkout/components/CheckoutMobileSummaryDrawer.js";
20
- import { CheckoutSummaryColumn as Te } from "./checkout/components/CheckoutSummaryColumn.js";
21
- import { checkoutFormSchema as Ee } from "./checkout/types.js";
22
- import { useEffect as s, useMemo as c, useRef as De, useState as l } from "react";
11
+ import { FulfillmentSection as he } from "../components/FulfillmentSection/index.js";
12
+ import { BookingFlowPageLayout as ge } from "../components/BookingFlowPageLayout/index.js";
13
+ import { Spinner as _e } from "../chunks/pkg/ui/dist/Spinner/index-Cgi70z_E.js";
14
+ import { ROUTE as ve, responseSchema as ye } from "../lib/checkoutPaymentDecision.js";
15
+ import { ROUTE as be, responseSchema as xe } from "../lib/checkoutVerifyCoupon.js";
16
+ import { CheckoutDetailsCard as Se } from "./checkout/components/CheckoutDetailsCard.js";
17
+ import { CheckoutInsuranceCard as Ce } from "./checkout/components/CheckoutInsuranceCard.js";
18
+ import { CheckoutLoadingSkeleton as we } from "./checkout/components/CheckoutLoadingSkeleton.js";
19
+ import { CheckoutMobileSummaryDrawer as Te } from "./checkout/components/CheckoutMobileSummaryDrawer.js";
20
+ import { CheckoutSummaryColumn as Ee } from "./checkout/components/CheckoutSummaryColumn.js";
21
+ import { checkoutFormSchema as De } from "./checkout/types.js";
22
+ import { useEffect as s, useMemo as c, useRef as Oe, useState as l } from "react";
23
23
  import { jsx as u, jsxs as d } from "react/jsx-runtime";
24
- import { Link as Oe, useNavigate as ke, useParams as Ae, useSearchParams as je } from "@rpcbase/router";
25
- import { useTranslation as Me } from "react-i18next";
26
- import { AlertTriangle as Ne, ArrowLeft as Pe } from "lucide-react";
27
- import { useForm as Fe, zodResolver as Ie } from "@rpcbase/form";
24
+ import { Link as ke, useNavigate as Ae, useParams as je, useSearchParams as Me } from "@rpcbase/router";
25
+ import { useTranslation as Ne } from "react-i18next";
26
+ import { AlertTriangle as Pe, ArrowLeft as Fe } from "lucide-react";
27
+ import { useForm as Ie, zodResolver as Le } from "@rpcbase/form";
28
28
  //#region src/pages/CheckoutPage.tsx
29
- var Le = .2, f = (e, t, n) => {
29
+ var Re = .2, f = (e, t, n) => {
30
30
  try {
31
31
  return new Intl.NumberFormat(n, {
32
32
  style: "currency",
@@ -35,7 +35,7 @@ var Le = .2, f = (e, t, n) => {
35
35
  } catch {
36
36
  return `${(e / 100).toFixed(2)} ${t.toUpperCase()}`;
37
37
  }
38
- }, Re = (e, t) => {
38
+ }, ze = (e, t) => {
39
39
  try {
40
40
  return new Intl.NumberFormat(t, {
41
41
  style: "percent",
@@ -47,103 +47,103 @@ var Le = .2, f = (e, t, n) => {
47
47
  }
48
48
  };
49
49
  function p() {
50
- let { t: p, i18n: m } = Me(), { storefrontConfiguration: h } = fe(), ze = h.workspace?.workspaceLanguage, { bikes: g, accessories: Be } = pe(), { storeSlug: _ } = Ae(), [v, Ve] = je(), He = ke(), { items: Ue, itemCount: We, isReady: Ge, setQuantity: Ke, removeItem: qe, beginCheckoutSubmission: Je, confirmCheckoutPaymentSession: Ye, clearCheckoutSession: Xe, clear: Ze } = ee(), [Qe, $e] = l(!1), et = De(!1), [y, b] = l(null), [tt, x] = l(!1), [S, C] = l(null), nt = v.get("coupon") ?? v.get("code") ?? "", [rt, w] = l(nt), [it, at] = l(nt.trim()), [T, E] = l(null), [D, O] = l(null), [k, A] = l(!1), [ot, j] = l(null), [st, M] = l(null), [N, ct] = l(!1), [P, lt] = l(!1), ut = n(v).toString(), dt = c(() => r(new URLSearchParams(ut), _), [ut, _]), F = h.settings.fulfillmentModes.includes("delivery"), ft = h.settings.deliveryDisabledReason.trim(), pt = F || ft.length > 0, mt = h.shop.address?.trim() ?? "", I = c(() => {
50
+ let { t: p, i18n: m } = Ne(), { storefrontConfiguration: h } = pe(), Be = h.workspace?.workspaceLanguage, { bikes: g, accessories: Ve } = me(), { storeSlug: _ } = je(), [v, He] = Me(), Ue = Ae(), { items: We, itemCount: Ge, isReady: Ke, setQuantity: qe, removeItem: Je, beginCheckoutSubmission: Ye, confirmCheckoutPaymentSession: Xe, clearCheckoutSession: Ze, clear: Qe } = ee(), [y, $e] = l(!1), b = Oe(!1), [x, S] = l(null), [et, C] = l(!1), [w, T] = l(null), tt = v.get("coupon") ?? v.get("code") ?? "", [nt, E] = l(tt), [rt, it] = l(tt.trim()), [D, O] = l(null), [at, k] = l(null), [A, j] = l(!1), [ot, M] = l(null), [st, N] = l(null), [P, ct] = l(!1), [F, lt] = l(!1), ut = n(v).toString(), dt = c(() => r(new URLSearchParams(ut), _), [ut, _]), I = h.settings.fulfillmentModes.includes("delivery"), ft = h.settings.deliveryDisabledReason.trim(), pt = I || ft.length > 0, mt = h.shop.address?.trim() ?? "", L = c(() => {
51
51
  let e = t(dt, {
52
52
  startTime: "",
53
53
  endTime: ""
54
54
  });
55
- return e.fulfillment === "delivery" && !F ? {
55
+ return e.fulfillment === "delivery" && !I ? {
56
56
  ...e,
57
57
  fulfillment: "pickup"
58
58
  } : e;
59
- }, [dt, F]), L = c(() => le(I), [I]), R = h.bookingEngine.pricing, ht = te(I, R, h.bookingEngine.shop.timeZone), gt = ne(R.baseUnit, p), _t = ht?.billableUnitCount, z = c(() => re({
60
- items: Ue,
59
+ }, [dt, I]), R = c(() => ue(L), [L]), z = h.bookingEngine.pricing, ht = te(L, z, h.bookingEngine.shop.timeZone), gt = ne(z.baseUnit, p), _t = ht?.billableUnitCount, B = c(() => re({
60
+ items: We,
61
61
  language: m.language,
62
- fallbackLanguage: ze,
62
+ fallbackLanguage: Be,
63
63
  products: {
64
64
  bikes: g,
65
- accessories: Be
65
+ accessories: Ve
66
66
  },
67
- priceUnit: R.baseUnit,
67
+ priceUnit: z.baseUnit,
68
68
  billableUnitCount: _t
69
69
  }), [
70
- Be,
70
+ Ve,
71
71
  g,
72
72
  _t,
73
73
  m.language,
74
- Ue,
75
- R.baseUnit,
76
- ze
77
- ]), B = c(() => z.lines.map((e) => ({
74
+ We,
75
+ z.baseUnit,
76
+ Be
77
+ ]), V = c(() => B.lines.map((e) => ({
78
78
  productId: e.checkoutProductId,
79
79
  productVariantId: e.productVariantId,
80
80
  quantity: e.quantity
81
- })), [z.lines]), [vt, V] = l([]), [H, U] = l(!1);
81
+ })), [B.lines]), [vt, H] = l([]), [U, W] = l(!1);
82
82
  s(() => {
83
- if (!_ || B.length === 0) {
84
- V([]), U(!1);
83
+ if (!_ || V.length === 0) {
84
+ H([]), W(!1);
85
85
  return;
86
86
  }
87
- if (!L) {
88
- V([]), U(!1);
87
+ if (!R) {
88
+ H([]), W(!1);
89
89
  return;
90
90
  }
91
91
  let e = !1;
92
- return U(!0), V([]), (async () => {
92
+ return W(!0), H([]), (async () => {
93
93
  try {
94
- let t = await o(oe, {
94
+ let t = await o(se, {
95
95
  storeSlug: _,
96
- schedule: L,
97
- products: B
98
- }), n = ue.parse(t);
96
+ schedule: R,
97
+ products: V
98
+ }), n = de.parse(t);
99
99
  if (e) return;
100
- V(n.success ? n.availability ?? [] : []);
100
+ H(n.success ? n.availability ?? [] : []);
101
101
  } catch (t) {
102
102
  if (e) return;
103
- console.error("Failed to load checkout cart availability", t), V([]);
103
+ console.error("Failed to load checkout cart availability", t), H([]);
104
104
  } finally {
105
- e || U(!1);
105
+ e || W(!1);
106
106
  }
107
107
  })(), () => {
108
108
  e = !0;
109
109
  };
110
110
  }, [
111
- I.endDate,
112
- I.endTime,
113
- I.startDate,
114
- I.startTime,
115
- L,
116
- B,
111
+ L.endDate,
112
+ L.endTime,
113
+ L.startDate,
114
+ L.startTime,
115
+ R,
116
+ V,
117
117
  _
118
118
  ]);
119
- let yt = c(() => new Map(vt.map((e) => [se(e.productId, e.productVariantId), e])), [vt]), bt = c(() => ({
120
- ...z,
121
- lines: z.lines.map((e) => {
122
- let t = yt.get(se(e.checkoutProductId, e.productVariantId)), n = t ? ce(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
119
+ let yt = c(() => new Map(vt.map((e) => [ce(e.productId, e.productVariantId), e])), [vt]), bt = c(() => ({
120
+ ...B,
121
+ lines: B.lines.map((e) => {
122
+ let t = yt.get(ce(e.checkoutProductId, e.productVariantId)), n = t ? le(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
123
123
  return {
124
124
  ...e,
125
- insufficientCapacity: !H && n !== void 0,
126
- availabilityIssue: H ? void 0 : n
125
+ insufficientCapacity: !U && n !== void 0,
126
+ availabilityIssue: U ? void 0 : n
127
127
  };
128
128
  })
129
129
  }), [
130
130
  yt,
131
- H,
132
- z
133
- ]), W = c(() => z.lines.map((e) => ({
131
+ U,
132
+ B
133
+ ]), G = c(() => B.lines.map((e) => ({
134
134
  kind: e.kind,
135
135
  productId: e.checkoutProductId,
136
136
  productVariantId: e.productVariantId,
137
137
  quantity: e.quantity
138
- })), [z.lines]), xt = new Map(g.map((e) => [e.checkoutProductId?.trim() || e.id, e])), G = z.lines.flatMap((e) => {
138
+ })), [B.lines]), xt = new Map(g.map((e) => [e.checkoutProductId?.trim() || e.id, e])), K = B.lines.flatMap((e) => {
139
139
  let t = xt.get(e.checkoutProductId);
140
140
  return t?.insurance?.enabled ? [{
141
141
  quantity: e.quantity,
142
142
  pricePerDayMinor: t.insurance.pricePerDayMinor,
143
143
  deductibleAmountMinor: t.insurance.deductibleAmountMinor
144
144
  }] : [];
145
- }), K = h.modules?.insurance?.enabled === !0 && G.length > 0, q = K && P, St = G.reduce((e, t) => e + t.pricePerDayMinor * t.quantity, 0), Ct = G.reduce((e, t) => Math.max(e, t.deductibleAmountMinor), 0), wt = z.totalMinor ?? 0, J = D?.totalMinor ?? wt, Y = D?.insuranceSubtotalMinor ?? 0, Tt = T?.discountAmountMinor ?? 0, X = e(new URLSearchParams(), I).toString(), Z = `/${_ ?? ""}/booking${X ? `?${X}` : ""}`, Et = `/${_ ?? ""}/checkout${X ? `?${X}` : ""}`, Dt = Fe({
146
- resolver: Ie(Ee),
145
+ }), q = h.modules?.insurance?.enabled === !0 && K.length > 0, J = q && F, St = K.reduce((e, t) => e + t.pricePerDayMinor * t.quantity, 0), Ct = K.reduce((e, t) => Math.max(e, t.deductibleAmountMinor), 0), wt = B.totalMinor ?? 0, Y = at?.totalMinor ?? wt, X = at?.insuranceSubtotalMinor ?? 0, Tt = D?.discountAmountMinor ?? 0, Z = e(new URLSearchParams(), L).toString(), Q = `/${_ ?? ""}/booking${Z ? `?${Z}` : ""}`, Et = `/${_ ?? ""}/checkout${Z ? `?${Z}` : ""}`, Dt = Ie({
146
+ resolver: Le(De),
147
147
  defaultValues: {
148
148
  fullName: "",
149
149
  email: "",
@@ -152,183 +152,183 @@ function p() {
152
152
  }
153
153
  });
154
154
  s(() => {
155
- i(_, I);
156
- }, [I, _]), s(() => {
157
- !K && P && lt(!1);
158
- }, [P, K]);
159
- let Q = (t) => {
155
+ i(_, L);
156
+ }, [L, _]), s(() => {
157
+ !q && F && lt(!1);
158
+ }, [F, q]);
159
+ let Ot = (t) => {
160
160
  let n = {
161
- ...I,
161
+ ...L,
162
162
  ...t
163
163
  }, r = e(v, n);
164
- r.toString() !== v.toString() && (Ve(r, { replace: !0 }), i(_, r));
164
+ r.toString() !== v.toString() && (He(r, { replace: !0 }), i(_, r));
165
165
  };
166
166
  s(() => {
167
- if (!_ || W.length === 0 || !L) {
168
- E(null), O(null), A(!1), j(null), M(null);
167
+ if (!_ || G.length === 0 || !R) {
168
+ O(null), k(null), j(!1), M(null), N(null);
169
169
  return;
170
170
  }
171
- let e = it.trim(), t = e.length === 0 && !N, n = !1;
172
- return A(!0), M(null), j(null), (async () => {
171
+ let e = rt.trim(), t = e.length === 0 && !P, n = !1;
172
+ return j(!0), N(null), M(null), (async () => {
173
173
  try {
174
- let r = await o(ye, {
174
+ let r = await o(be, {
175
175
  storeSlug: _,
176
- schedule: L,
177
- items: W,
176
+ schedule: R,
177
+ items: G,
178
178
  couponCode: e || void 0,
179
179
  includeAutoApply: t,
180
- insuranceAccepted: q
181
- }), i = be.parse(r);
180
+ insuranceAccepted: J
181
+ }), i = xe.parse(r);
182
182
  if (n) return;
183
- if (O(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
183
+ if (k(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
184
184
  subtotalMinor: i.subtotalMinor,
185
185
  totalMinor: i.totalMinor,
186
186
  lateReturnSurchargeMinor: i.lateReturnSurchargeMinor,
187
187
  insuranceSubtotalMinor: i.insuranceSubtotalMinor,
188
188
  insuranceBillableDays: i.insuranceBillableDays
189
189
  } : null), !i.success) {
190
- E(null), M(i.message || p("checkout_coupon_invalid"));
190
+ O(null), N(i.message || p("checkout_coupon_invalid"));
191
191
  return;
192
192
  }
193
- E(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (w(i.coupon.code), j(p("checkout_coupon_auto_applied", { code: i.coupon.code }))) : j(p("checkout_coupon_manual_applied")));
193
+ O(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (E(i.coupon.code), M(p("checkout_coupon_auto_applied", { code: i.coupon.code }))) : M(p("checkout_coupon_manual_applied")));
194
194
  } catch (e) {
195
195
  if (n) return;
196
- console.error("Failed to verify checkout coupon", e), E(null), O(null), M(p("checkout_coupon_error"));
196
+ console.error("Failed to verify checkout coupon", e), O(null), k(null), N(p("checkout_coupon_error"));
197
197
  } finally {
198
- n || A(!1);
198
+ n || j(!1);
199
199
  }
200
200
  })(), () => {
201
201
  n = !0;
202
202
  };
203
203
  }, [
204
- N,
205
- I.endDate,
206
- I.endTime,
207
- I.startDate,
208
- I.startTime,
209
- L,
210
- W,
211
- q,
204
+ P,
205
+ L.endDate,
206
+ L.endTime,
207
+ L.startDate,
208
+ L.startTime,
209
+ R,
210
+ G,
211
+ J,
212
212
  _,
213
- it,
213
+ rt,
214
214
  p
215
215
  ]), s(() => {
216
- if (!_ || z.lines.length === 0 || !L) {
217
- b(null), C(null), x(!1);
216
+ if (!_ || B.lines.length === 0 || !R) {
217
+ S(null), T(null), C(!1);
218
218
  return;
219
219
  }
220
220
  let e = !1;
221
- return x(!0), C(null), (async () => {
221
+ return C(!0), T(null), (async () => {
222
222
  try {
223
- let t = await o(_e, {
223
+ let t = await o(ve, {
224
224
  storeSlug: _,
225
- schedule: L,
226
- estimatedTotalMinor: J,
227
- insuranceAmountMinor: Y
228
- }), n = ve.parse(t);
225
+ schedule: R,
226
+ estimatedTotalMinor: Y,
227
+ insuranceAmountMinor: X
228
+ }), n = ye.parse(t);
229
229
  if (e) return;
230
230
  if (!n.success || !n.decision) {
231
- b(null), C(n.message || p("checkout_payment_error"));
231
+ S(null), T(n.message || p("checkout_payment_error"));
232
232
  return;
233
233
  }
234
- b(n.decision);
234
+ S(n.decision);
235
235
  } catch (t) {
236
236
  if (e) return;
237
- console.error("Failed to load checkout payment decision", t), b(null), C(p("checkout_payment_error"));
237
+ console.error("Failed to load checkout payment decision", t), S(null), T(p("checkout_payment_error"));
238
238
  } finally {
239
- e || x(!1);
239
+ e || C(!1);
240
240
  }
241
241
  })(), () => {
242
242
  e = !0;
243
243
  };
244
244
  }, [
245
- I.endDate,
246
- I.endTime,
247
- I.startDate,
248
- I.startTime,
249
- L,
250
- J,
251
- z.lines.length,
245
+ L.endDate,
246
+ L.endTime,
247
+ L.startDate,
248
+ L.startTime,
249
+ R,
252
250
  Y,
251
+ B.lines.length,
252
+ X,
253
253
  _,
254
254
  p
255
255
  ]);
256
- let $ = y?.currency ?? "EUR", Ot = f(J, $, m.language), kt = Math.max(0, J - Y), At = Math.round(kt / 1.2), jt = At + Y, Mt = Math.max(0, kt - At), Nt = f(jt, $, m.language), Pt = f(Mt, $, m.language), Ft = Re(Le, m.language), It = Y > 0 ? f(Y, $, m.language) : void 0, Lt = y?.amountToCollectMinor ?? 0, Rt = y?.shouldCollectOnlinePayment === !0 && Lt > 0, zt = Dt.handleSubmit(async (e) => {
257
- if (!_ || W.length === 0 || !L || et.current) return;
258
- $e(!0), et.current = !0;
259
- let t = Je();
256
+ let $ = x?.currency ?? "EUR", kt = f(Y, $, m.language), At = Math.max(0, Y - X), jt = Math.round(At / 1.2), Mt = jt + X, Nt = Math.max(0, At - jt), Pt = f(Mt, $, m.language), Ft = f(Nt, $, m.language), It = ze(Re, m.language), Lt = X > 0 ? f(X, $, m.language) : void 0, Rt = x?.amountToCollectMinor ?? 0, zt = x?.shouldCollectOnlinePayment === !0 && Rt > 0, Bt = Dt.handleSubmit(async (e) => {
257
+ if (!_ || G.length === 0 || !R || b.current) return;
258
+ $e(!0), b.current = !0;
259
+ let t = Ye();
260
260
  try {
261
261
  let n = await o(ie, {
262
262
  storeSlug: _,
263
263
  checkoutSessionId: t.checkoutSessionId,
264
264
  replacesCheckoutSessionId: t.replacesCheckoutSessionId,
265
- schedule: L,
266
- fulfillment: I.fulfillment,
267
- startAddress: I.fulfillment === "delivery" ? I.startAddress : void 0,
268
- endAddress: I.fulfillment === "delivery" ? I.endAddress : void 0,
269
- couponCode: T?.code,
270
- couponAutoApplied: !N && T?.autoApplied,
271
- insuranceAccepted: q,
265
+ schedule: R,
266
+ fulfillment: L.fulfillment,
267
+ startAddress: L.fulfillment === "delivery" ? L.startAddress : void 0,
268
+ endAddress: L.fulfillment === "delivery" ? L.endAddress : void 0,
269
+ couponCode: D?.code,
270
+ couponAutoApplied: !P && D?.autoApplied,
271
+ insuranceAccepted: J,
272
272
  customer: {
273
273
  name: e.fullName,
274
274
  email: e.email,
275
275
  phone: e.phone,
276
276
  notes: e.notes
277
277
  },
278
- items: W
279
- }), r = ae.parse(n);
278
+ items: G
279
+ }), r = oe.parse(n);
280
280
  if (!r.success || !r.checkout) {
281
- Xe(), a.error(r.message || p("checkout_payment_error"));
281
+ Ze(), a.error(r.message || p("checkout_payment_error"));
282
282
  return;
283
283
  }
284
- r.checkout.requiresPayment ? Ye(r.checkout.checkoutSessionId ?? t.checkoutSessionId) : a.success(p("checkout_success_toast")), await He(r.checkout.nextPath), r.checkout.requiresPayment || Ze();
284
+ r.checkout.requiresPayment ? Xe(r.checkout.checkoutSessionId ?? t.checkoutSessionId) : a.success(p("checkout_success_toast")), await Ue(ae(r.checkout.nextPath, r.checkout.bookingExternalId)), r.checkout.requiresPayment || Qe();
285
285
  } catch (e) {
286
286
  console.error("Failed to submit storefront checkout", e), a.error(p("checkout_payment_error"));
287
287
  } finally {
288
- et.current = !1, $e(!1);
288
+ b.current = !1, $e(!1);
289
289
  }
290
- }), Bt = p(Rt ? "checkout_continue_to_payment" : "checkout_submit"), Vt = p(Rt ? "checkout_mobile_continue_to_payment" : "checkout_mobile_submit"), Ht = I.fulfillment === "delivery" && I.startAddress.trim().length === 0, Ut = !Qe && !tt && !S && !H && !k && !st && !!y && !!L && !Ht && W.length > 0, Wt = () => {
291
- Ut && zt();
292
- }, Gt = ({ className: e, presentation: t, stickyTopClassName: n } = {}) => /* @__PURE__ */ u(Te, {
290
+ }), Vt = p(zt ? "checkout_continue_to_payment" : "checkout_submit"), Ht = p(zt ? "checkout_mobile_continue_to_payment" : "checkout_mobile_submit"), Ut = L.fulfillment === "delivery" && L.startAddress.trim().length === 0, Wt = !y && !et && !w && !U && !A && !st && !!x && !!R && !Ut && G.length > 0, Gt = () => {
291
+ Wt && Bt();
292
+ }, Kt = ({ className: e, presentation: t, stickyTopClassName: n } = {}) => /* @__PURE__ */ u(Ee, {
293
293
  className: e,
294
294
  lines: bt.lines,
295
- itemCount: We,
295
+ itemCount: Ge,
296
296
  baseUnitLabel: gt,
297
- bookingSubtotalLabel: Nt,
298
- vatAmountLabel: Pt,
299
- vatRateLabel: Ft,
300
- bookingTotalLabel: Ot,
301
- bookingPeriod: L ? {
302
- bookingPath: Z,
303
- startDate: L.startDate,
304
- startTime: L.startTime,
305
- endDate: L.endDate,
306
- endTime: L.endTime
297
+ bookingSubtotalLabel: Pt,
298
+ vatAmountLabel: Ft,
299
+ vatRateLabel: It,
300
+ bookingTotalLabel: kt,
301
+ bookingPeriod: R ? {
302
+ bookingPath: Q,
303
+ startDate: R.startDate,
304
+ startTime: R.startTime,
305
+ endDate: R.endDate,
306
+ endTime: R.endTime
307
307
  } : void 0,
308
308
  presentation: t,
309
309
  stickyTopClassName: n,
310
- onQuantityChange: Ke,
311
- onRemove: qe,
310
+ onQuantityChange: qe,
311
+ onRemove: Je,
312
312
  coupon: {
313
- code: rt,
314
- appliedCode: T?.code,
315
- discountLabel: T && Tt > 0 ? f(Tt, $, m.language) : null,
313
+ code: nt,
314
+ appliedCode: D?.code,
315
+ discountLabel: D && Tt > 0 ? f(Tt, $, m.language) : null,
316
316
  message: ot,
317
317
  error: st,
318
- loading: k,
319
- disabled: Qe,
318
+ loading: A,
319
+ disabled: y,
320
320
  onCodeChange: (e) => {
321
- w(e), M(null), j(null);
321
+ E(e), N(null), M(null);
322
322
  },
323
323
  onApply: () => {
324
- ct(!1), at(rt.trim());
324
+ ct(!1), it(nt.trim());
325
325
  },
326
326
  onRemove: () => {
327
- w(""), at(""), E(null), O(null), M(null), j(null), ct(!0);
327
+ E(""), it(""), O(null), k(null), N(null), M(null), ct(!0);
328
328
  }
329
329
  }
330
330
  });
331
- return Ge ? z.lines.length === 0 ? /* @__PURE__ */ u("div", {
331
+ return Ke ? B.lines.length === 0 ? /* @__PURE__ */ u("div", {
332
332
  className: "mx-auto max-w-3xl px-4 py-10 sm:px-6",
333
333
  children: /* @__PURE__ */ d("div", {
334
334
  className: "rounded-xl border border-slate-200 bg-white p-4 shadow-sm",
@@ -343,11 +343,11 @@ function p() {
343
343
  }),
344
344
  /* @__PURE__ */ u("div", {
345
345
  className: "mt-6",
346
- children: /* @__PURE__ */ u(Oe, {
347
- to: Z,
348
- children: /* @__PURE__ */ d(de, {
346
+ children: /* @__PURE__ */ u(ke, {
347
+ to: Q,
348
+ children: /* @__PURE__ */ d(fe, {
349
349
  className: "gap-2",
350
- children: [/* @__PURE__ */ u(Pe, {
350
+ children: [/* @__PURE__ */ u(Fe, {
351
351
  className: "h-4 w-4",
352
352
  "aria-hidden": "true"
353
353
  }), /* @__PURE__ */ u("span", { children: p("back_to_booking") })]
@@ -356,11 +356,11 @@ function p() {
356
356
  })
357
357
  ]
358
358
  })
359
- }) : /* @__PURE__ */ d(he, {
359
+ }) : /* @__PURE__ */ d(ge, {
360
360
  currentStep: "checkout",
361
- bookingPath: Z,
361
+ bookingPath: Q,
362
362
  checkoutPath: Et,
363
- backPath: Z,
363
+ backPath: Q,
364
364
  backLabel: p("back_to_booking"),
365
365
  children: [/* @__PURE__ */ d("div", {
366
366
  className: "grid gap-6 pb-24 lg:grid-cols-12 lg:pb-0",
@@ -371,7 +371,7 @@ function p() {
371
371
  className: "text-xl font-semibold tracking-tight text-slate-950",
372
372
  children: /* @__PURE__ */ u("span", { children: p("checkout_title") })
373
373
  }),
374
- L ? null : /* @__PURE__ */ u("p", {
374
+ R ? null : /* @__PURE__ */ u("p", {
375
375
  role: "alert",
376
376
  className: "mt-3 text-sm text-destructive",
377
377
  children: /* @__PURE__ */ u("span", { children: p("booking_time_slots_required") })
@@ -381,76 +381,76 @@ function p() {
381
381
  children: [
382
382
  pt ? /* @__PURE__ */ u("div", {
383
383
  className: "rounded-xl border border-slate-200 bg-white p-3 shadow-sm",
384
- children: /* @__PURE__ */ u(me, {
385
- value: I.fulfillment,
386
- onValueChange: (e) => Q({ fulfillment: e }),
384
+ children: /* @__PURE__ */ u(he, {
385
+ value: L.fulfillment,
386
+ onValueChange: (e) => Ot({ fulfillment: e }),
387
387
  pickupAddress: mt,
388
- deliveryEnabled: F,
388
+ deliveryEnabled: I,
389
389
  deliveryDisabledReason: ft,
390
- startAddress: I.startAddress,
391
- onStartAddressChange: (e) => Q({ startAddress: e }),
392
- endAddress: I.endAddress,
393
- onEndAddressChange: (e) => Q({ endAddress: e }),
390
+ startAddress: L.startAddress,
391
+ onStartAddressChange: (e) => Ot({ startAddress: e }),
392
+ endAddress: L.endAddress,
393
+ onEndAddressChange: (e) => Ot({ endAddress: e }),
394
394
  showPickupAddressWhenPickupOnly: !1,
395
395
  testIdPrefix: "storefront-checkout-fulfillment"
396
396
  })
397
397
  }) : null,
398
- /* @__PURE__ */ u(xe, {
398
+ /* @__PURE__ */ u(Se, {
399
399
  form: Dt,
400
- onSubmit: Wt
400
+ onSubmit: Gt
401
401
  }),
402
- K ? /* @__PURE__ */ u(Se, {
403
- accepted: q,
404
- disabled: Qe || k,
402
+ q ? /* @__PURE__ */ u(Ce, {
403
+ accepted: J,
404
+ disabled: y || A,
405
405
  dailyAmountLabel: f(St, $, m.language),
406
- totalAmountLabel: It,
407
- billableDays: D?.insuranceBillableDays,
406
+ totalAmountLabel: Lt,
407
+ billableDays: at?.insuranceBillableDays,
408
408
  deductibleLabel: Ct > 0 ? f(Ct, $, m.language) : void 0,
409
409
  onAcceptedChange: lt
410
410
  }) : null,
411
- tt ? /* @__PURE__ */ d("div", {
411
+ et ? /* @__PURE__ */ d("div", {
412
412
  className: "flex items-center gap-2 text-sm text-slate-600",
413
413
  role: "status",
414
- children: [/* @__PURE__ */ u(ge, {
414
+ children: [/* @__PURE__ */ u(_e, {
415
415
  className: "size-4",
416
416
  "aria-hidden": "true"
417
417
  }), /* @__PURE__ */ u("span", { children: p("checkout_payment_loading") })]
418
418
  }) : null,
419
- S ? /* @__PURE__ */ d("div", {
419
+ w ? /* @__PURE__ */ d("div", {
420
420
  className: "flex items-start gap-2 rounded-md bg-destructive p-3 text-sm text-destructive-foreground shadow-sm",
421
421
  role: "alert",
422
- children: [/* @__PURE__ */ u(Ne, {
422
+ children: [/* @__PURE__ */ u(Pe, {
423
423
  className: "mt-0.5 h-4 w-4",
424
424
  "aria-hidden": "true"
425
- }), /* @__PURE__ */ u("span", { children: S })]
425
+ }), /* @__PURE__ */ u("span", { children: w })]
426
426
  }) : null,
427
- /* @__PURE__ */ u(de, {
427
+ /* @__PURE__ */ u(fe, {
428
428
  type: "button",
429
429
  size: "lg",
430
- onClick: Wt,
431
- disabled: !Ut,
430
+ onClick: Gt,
431
+ disabled: !Wt,
432
432
  className: "mt-4 hidden w-fit lg:inline-flex",
433
- children: /* @__PURE__ */ u("span", { children: Bt })
433
+ children: /* @__PURE__ */ u("span", { children: Vt })
434
434
  }),
435
- Ht ? /* @__PURE__ */ u("p", {
435
+ Ut ? /* @__PURE__ */ u("p", {
436
436
  className: "text-sm text-slate-600",
437
437
  children: /* @__PURE__ */ u("span", { children: p("checkout_delivery_address_required") })
438
438
  }) : null
439
439
  ]
440
440
  })
441
441
  ]
442
- }), Gt({ className: "hidden lg:block" })]
443
- }), /* @__PURE__ */ u(we, {
444
- canSubmit: Ut,
445
- compactSubmitLabel: Vt,
446
- itemCount: We,
447
- submitLabel: Bt,
448
- totalLabel: Ot,
449
- onSubmit: Wt,
450
- children: Gt({ presentation: "flat" })
442
+ }), Kt({ className: "hidden lg:block" })]
443
+ }), /* @__PURE__ */ u(Te, {
444
+ canSubmit: Wt,
445
+ compactSubmitLabel: Ht,
446
+ itemCount: Ge,
447
+ submitLabel: Vt,
448
+ totalLabel: kt,
449
+ onSubmit: Gt,
450
+ children: Kt({ presentation: "flat" })
451
451
  })]
452
- }) : /* @__PURE__ */ u(Ce, {
453
- bookingPath: Z,
452
+ }) : /* @__PURE__ */ u(we, {
453
+ bookingPath: Q,
454
454
  checkoutPath: Et
455
455
  });
456
456
  }
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutPaymentPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPaymentPage.tsx"],"names":[],"mappings":"AAmGA,MAAM,CAAC,OAAO,UAAU,mBAAmB,4CA+Y1C"}
1
+ {"version":3,"file":"CheckoutPaymentPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPaymentPage.tsx"],"names":[],"mappings":"AAwGA,MAAM,CAAC,OAAO,UAAU,mBAAmB,4CA2Z1C"}