@loczer/storefront-sdk 0.222.0 → 0.223.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/i18n/en.js CHANGED
@@ -63,7 +63,7 @@ var e = {
63
63
  cancellation_policy_modal_title: "Cancellation policy",
64
64
  cancellation_policy_modal_description: "Refunds depend on how far in advance you cancel.",
65
65
  cancellation_policy_modal_tier_deadline: "Up to {{duration}} in advance",
66
- cancellation_policy_modal_tier_refund: "Refund of {{percentage}} of the total amount",
66
+ cancellation_policy_modal_tier_refund: "Refund of {{percentage}} of the total booking amount",
67
67
  cancellation_policy_modal_disclaimer: "These are the standard cancellation conditions. Depending on your reservation, different conditions may be offered.",
68
68
  cancellation_policy_duration_hours_one: "{{count}} hour",
69
69
  cancellation_policy_duration_hours_other: "{{count}} hours",
package/dist/i18n/fr.js CHANGED
@@ -63,7 +63,7 @@ var e = {
63
63
  cancellation_policy_modal_title: "Conditions d'annulation",
64
64
  cancellation_policy_modal_description: "Le remboursement dépend du délai entre l'annulation et le début de la réservation.",
65
65
  cancellation_policy_modal_tier_deadline: "Jusqu'à {{duration}} à l'avance",
66
- cancellation_policy_modal_tier_refund: "Remboursement de {{percentage}} du montant total",
66
+ cancellation_policy_modal_tier_refund: "Remboursement de {{percentage}} du montant total de la réservation",
67
67
  cancellation_policy_modal_disclaimer: "Il s'agit des conditions d'annulation de base. Selon votre réservation, des conditions différentes pourront vous être proposées.",
68
68
  cancellation_policy_duration_hours_one: "{{count}} heure",
69
69
  cancellation_policy_duration_hours_other: "{{count}} heures",
@@ -15,6 +15,7 @@ export declare const requestSchema: z.ZodObject<{
15
15
  endTime: z.ZodString;
16
16
  }, z.core.$strip>;
17
17
  estimatedTotalMinor: z.ZodNumber;
18
+ insuranceAmountMinor: z.ZodOptional<z.ZodNumber>;
18
19
  nowIso: z.ZodOptional<z.ZodString>;
19
20
  }, z.core.$strip>;
20
21
  export type RequestPayload = z.infer<typeof requestSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"checkoutPaymentDecision.d.ts","sourceRoot":"","sources":["../../src/lib/checkoutPaymentDecision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,KAAK,qDAAqD,CAAA;AAEvE,eAAO,MAAM,yBAAyB;;;;EAAsC,CAAA;AAC5E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAE3E,eAAO,MAAM,aAAa;;;;;;;;;;iBAYxB,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AAE1D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBzB,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
1
+ {"version":3,"file":"checkoutPaymentDecision.d.ts","sourceRoot":"","sources":["../../src/lib/checkoutPaymentDecision.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAGvB,eAAO,MAAM,KAAK,qDAAqD,CAAA;AAEvE,eAAO,MAAM,yBAAyB;;;;EAAsC,CAAA;AAC5E,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAE3E,eAAO,MAAM,aAAa;;;;;;;;;;;iBAaxB,CAAA;AAEF,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,aAAa,CAAC,CAAA;AAE1D,eAAO,MAAM,cAAc;;;;;;;;;;;;;;;;;;;;;;;;;iBAuBzB,CAAA;AAEF,MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
@@ -13,6 +13,7 @@ var t = "/api/public/storefront/checkout/payment-decision", n = e.enum([
13
13
  endTime: e.string().regex(/^\d{2}:\d{2}$/)
14
14
  }),
15
15
  estimatedTotalMinor: e.number().int().min(0),
16
+ insuranceAmountMinor: e.number().int().min(0).optional(),
16
17
  nowIso: e.string().datetime({ offset: !0 }).optional()
17
18
  }), i = e.object({
18
19
  success: e.boolean(),
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPage.tsx"],"names":[],"mappings":"AAoFA,MAAM,CAAC,OAAO,UAAU,YAAY,4CAooBnC"}
1
+ {"version":3,"file":"CheckoutPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPage.tsx"],"names":[],"mappings":"AAoFA,MAAM,CAAC,OAAO,UAAU,YAAY,4CAsoBnC"}
@@ -45,102 +45,102 @@ var Fe = .2, f = (e, t, n) => {
45
45
  }
46
46
  };
47
47
  function p() {
48
- let { t: p, i18n: m } = Ae(), { storefrontConfiguration: h } = fe(), Le = h.workspace?.workspaceLanguage, { bikes: Re, accessories: ze } = pe(), { storeSlug: g } = Oe(), [_, Be] = ke(), Ve = De(), { items: He, itemCount: Ue, setQuantity: We, removeItem: Ge, beginCheckoutSubmission: Ke, confirmCheckoutPaymentSession: qe, clearCheckoutSession: Je, clear: Ye } = ee(), [v, Xe] = l(!1), y = Te(!1), [b, x] = l(null), [Ze, S] = l(!1), [C, w] = l(null), Qe = _.get("coupon") ?? _.get("code") ?? "", [$e, et] = l(Qe), [tt, nt] = l(Qe.trim()), [T, E] = l(null), [D, O] = l(null), [k, A] = l(!1), [rt, j] = l(null), [it, M] = l(null), [N, at] = l(!1), [P, ot] = l(!1), st = n(_).toString(), ct = c(() => r(new URLSearchParams(st), g), [st, g]), F = h.settings.fulfillmentModes.includes("delivery"), lt = h.settings.deliveryDisabledReason.trim(), ut = F || lt.length > 0, dt = h.shop.address?.trim() ?? "", I = c(() => {
49
- let e = t(ct, {
48
+ let { t: p, i18n: m } = Ae(), { storefrontConfiguration: h } = fe(), Le = h.workspace?.workspaceLanguage, { bikes: g, accessories: Re } = pe(), { storeSlug: _ } = Oe(), [v, ze] = ke(), Be = De(), { items: Ve, itemCount: He, setQuantity: Ue, removeItem: We, beginCheckoutSubmission: Ge, confirmCheckoutPaymentSession: Ke, clearCheckoutSession: qe, clear: Je } = ee(), [y, Ye] = l(!1), b = Te(!1), [x, S] = l(null), [Xe, C] = l(!1), [w, T] = l(null), Ze = v.get("coupon") ?? v.get("code") ?? "", [Qe, E] = l(Ze), [$e, et] = l(Ze.trim()), [D, O] = l(null), [k, A] = l(null), [j, M] = l(!1), [tt, N] = l(null), [nt, P] = l(null), [F, rt] = l(!1), [I, it] = l(!1), at = n(v).toString(), ot = c(() => r(new URLSearchParams(at), _), [at, _]), L = h.settings.fulfillmentModes.includes("delivery"), st = h.settings.deliveryDisabledReason.trim(), ct = L || st.length > 0, lt = h.shop.address?.trim() ?? "", R = c(() => {
49
+ let e = t(ot, {
50
50
  start_time: "",
51
51
  end_time: ""
52
52
  });
53
- return e.fulfillment === "delivery" && !F ? {
53
+ return e.fulfillment === "delivery" && !L ? {
54
54
  ...e,
55
55
  fulfillment: "pickup"
56
56
  } : e;
57
- }, [ct, F]), L = c(() => le(I), [I]), R = h.bookingEngine.pricing, ft = te(I, R, h.bookingEngine.shop.timeZone), pt = ne(R.baseUnit, p), mt = ft?.billableUnitCount, z = c(() => re({
58
- items: He,
57
+ }, [ot, L]), z = c(() => le(R), [R]), B = h.bookingEngine.pricing, ut = te(R, B, h.bookingEngine.shop.timeZone), dt = ne(B.baseUnit, p), ft = ut?.billableUnitCount, V = c(() => re({
58
+ items: Ve,
59
59
  language: m.language,
60
60
  fallbackLanguage: Le,
61
61
  products: {
62
- bikes: Re,
63
- accessories: ze
62
+ bikes: g,
63
+ accessories: Re
64
64
  },
65
- priceUnit: R.baseUnit,
66
- billableUnitCount: mt
65
+ priceUnit: B.baseUnit,
66
+ billableUnitCount: ft
67
67
  }), [
68
- ze,
69
68
  Re,
70
- mt,
69
+ g,
70
+ ft,
71
71
  m.language,
72
- He,
73
- R.baseUnit,
72
+ Ve,
73
+ B.baseUnit,
74
74
  Le
75
- ]), B = c(() => z.lines.map((e) => ({
75
+ ]), H = c(() => V.lines.map((e) => ({
76
76
  productId: e.checkoutProductId,
77
77
  productVariantId: e.productVariantId,
78
78
  quantity: e.quantity
79
- })), [z.lines]), [ht, V] = l([]), [H, U] = l(!1);
79
+ })), [V.lines]), [pt, U] = l([]), [W, G] = l(!1);
80
80
  s(() => {
81
- if (!g || B.length === 0) {
82
- V([]), U(!1);
81
+ if (!_ || H.length === 0) {
82
+ U([]), G(!1);
83
83
  return;
84
84
  }
85
- if (!L) {
86
- V([]), U(!1);
85
+ if (!z) {
86
+ U([]), G(!1);
87
87
  return;
88
88
  }
89
89
  let e = !1;
90
- return U(!0), V([]), (async () => {
90
+ return G(!0), U([]), (async () => {
91
91
  try {
92
92
  let t = await o(oe, {
93
- storeSlug: g,
94
- schedule: L,
95
- products: B
93
+ storeSlug: _,
94
+ schedule: z,
95
+ products: H
96
96
  }), n = ue.parse(t);
97
97
  if (e) return;
98
- V(n.success ? n.availability ?? [] : []);
98
+ U(n.success ? n.availability ?? [] : []);
99
99
  } catch (t) {
100
100
  if (e) return;
101
- console.error("Failed to load checkout cart availability", t), V([]);
101
+ console.error("Failed to load checkout cart availability", t), U([]);
102
102
  } finally {
103
- e || U(!1);
103
+ e || G(!1);
104
104
  }
105
105
  })(), () => {
106
106
  e = !0;
107
107
  };
108
108
  }, [
109
- I.end_date,
110
- I.end_time,
111
- I.start_date,
112
- I.start_time,
113
- L,
114
- B,
115
- g
109
+ R.end_date,
110
+ R.end_time,
111
+ R.start_date,
112
+ R.start_time,
113
+ z,
114
+ H,
115
+ _
116
116
  ]);
117
- let gt = c(() => new Map(ht.map((e) => [se(e.productId, e.productVariantId), e])), [ht]), _t = c(() => ({
118
- ...z,
119
- lines: z.lines.map((e) => {
120
- let t = gt.get(se(e.checkoutProductId, e.productVariantId)), n = t ? ce(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
117
+ let mt = c(() => new Map(pt.map((e) => [se(e.productId, e.productVariantId), e])), [pt]), ht = c(() => ({
118
+ ...V,
119
+ lines: V.lines.map((e) => {
120
+ let t = mt.get(se(e.checkoutProductId, e.productVariantId)), n = t ? ce(t) : e.availabilityStatus === "OUT_OF_STOCK" ? "unavailable" : void 0;
121
121
  return {
122
122
  ...e,
123
- insufficientCapacity: !H && n !== void 0,
124
- availabilityIssue: H ? void 0 : n
123
+ insufficientCapacity: !W && n !== void 0,
124
+ availabilityIssue: W ? void 0 : n
125
125
  };
126
126
  })
127
127
  }), [
128
- gt,
129
- H,
130
- z
131
- ]), W = c(() => z.lines.map((e) => ({
128
+ mt,
129
+ W,
130
+ V
131
+ ]), K = c(() => V.lines.map((e) => ({
132
132
  kind: e.kind,
133
133
  productId: e.checkoutProductId,
134
134
  productVariantId: e.productVariantId,
135
135
  quantity: e.quantity
136
- })), [z.lines]), vt = new Map(Re.map((e) => [e.checkoutProductId?.trim() || e.id, e])), G = z.lines.flatMap((e) => {
137
- let t = vt.get(e.checkoutProductId);
136
+ })), [V.lines]), gt = new Map(g.map((e) => [e.checkoutProductId?.trim() || e.id, e])), q = V.lines.flatMap((e) => {
137
+ let t = gt.get(e.checkoutProductId);
138
138
  return t?.insurance?.enabled ? [{
139
139
  quantity: e.quantity,
140
140
  pricePerDayMinor: t.insurance.pricePerDayMinor,
141
141
  deductibleAmountMinor: t.insurance.deductibleAmountMinor
142
142
  }] : [];
143
- }), K = h.modules?.insurance?.enabled === !0 && G.length > 0, q = K && P, yt = G.reduce((e, t) => e + t.pricePerDayMinor * t.quantity, 0), bt = G.reduce((e, t) => Math.max(e, t.deductibleAmountMinor), 0), xt = z.totalMinor ?? 0, J = D?.totalMinor ?? xt, St = T?.discountAmountMinor ?? 0, Y = e(new URLSearchParams(), I).toString(), X = `/${g ?? ""}/booking${Y ? `?${Y}` : ""}`, Ct = `/${g ?? ""}/checkout${Y ? `?${Y}` : ""}`, wt = Ne({
143
+ }), J = h.modules?.insurance?.enabled === !0 && q.length > 0, Y = J && I, _t = q.reduce((e, t) => e + t.pricePerDayMinor * t.quantity, 0), vt = q.reduce((e, t) => Math.max(e, t.deductibleAmountMinor), 0), yt = V.totalMinor ?? 0, X = k?.totalMinor ?? yt, Z = k?.insuranceSubtotalMinor ?? 0, bt = D?.discountAmountMinor ?? 0, Q = e(new URLSearchParams(), R).toString(), xt = `/${_ ?? ""}/booking${Q ? `?${Q}` : ""}`, St = `/${_ ?? ""}/checkout${Q ? `?${Q}` : ""}`, Ct = Ne({
144
144
  resolver: Pe(we),
145
145
  defaultValues: {
146
146
  first_name: "",
@@ -151,121 +151,123 @@ function p() {
151
151
  }
152
152
  });
153
153
  s(() => {
154
- i(g, I);
155
- }, [I, g]), s(() => {
156
- !K && P && ot(!1);
157
- }, [P, K]);
158
- let Z = (t) => {
154
+ i(_, R);
155
+ }, [R, _]), s(() => {
156
+ !J && I && it(!1);
157
+ }, [I, J]);
158
+ let wt = (t) => {
159
159
  let n = {
160
- ...I,
160
+ ...R,
161
161
  ...t
162
- }, r = e(_, n);
163
- r.toString() !== _.toString() && (Be(r, { replace: !0 }), i(g, r));
162
+ }, r = e(v, n);
163
+ r.toString() !== v.toString() && (ze(r, { replace: !0 }), i(_, r));
164
164
  };
165
165
  s(() => {
166
- if (!g || W.length === 0 || !L) {
167
- E(null), O(null), A(!1), j(null), M(null);
166
+ if (!_ || K.length === 0 || !z) {
167
+ O(null), A(null), M(!1), N(null), P(null);
168
168
  return;
169
169
  }
170
- let e = tt.trim(), t = e.length === 0 && !N, n = !1;
171
- return A(!0), M(null), j(null), (async () => {
170
+ let e = $e.trim(), t = e.length === 0 && !F, n = !1;
171
+ return M(!0), P(null), N(null), (async () => {
172
172
  try {
173
173
  let r = await o(ye, {
174
- storeSlug: g,
175
- schedule: L,
176
- items: W,
174
+ storeSlug: _,
175
+ schedule: z,
176
+ items: K,
177
177
  couponCode: e || void 0,
178
178
  includeAutoApply: t,
179
- insuranceAccepted: q
179
+ insuranceAccepted: Y
180
180
  }), i = be.parse(r);
181
181
  if (n) return;
182
- if (O(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
182
+ if (A(typeof i.subtotalMinor == "number" && typeof i.totalMinor == "number" ? {
183
183
  subtotalMinor: i.subtotalMinor,
184
184
  totalMinor: i.totalMinor,
185
185
  lateReturnSurchargeMinor: i.lateReturnSurchargeMinor,
186
186
  insuranceSubtotalMinor: i.insuranceSubtotalMinor,
187
187
  insuranceBillableDays: i.insuranceBillableDays
188
188
  } : null), !i.success) {
189
- E(null), M(i.message || p("checkout_coupon_invalid"));
189
+ O(null), P(i.message || p("checkout_coupon_invalid"));
190
190
  return;
191
191
  }
192
- E(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (et(i.coupon.code), j(p("checkout_coupon_auto_applied", { code: i.coupon.code }))) : j(p("checkout_coupon_manual_applied")));
192
+ O(i.coupon ?? null), i.coupon && (i.coupon.autoApplied && e.length === 0 ? (E(i.coupon.code), N(p("checkout_coupon_auto_applied", { code: i.coupon.code }))) : N(p("checkout_coupon_manual_applied")));
193
193
  } catch (e) {
194
194
  if (n) return;
195
- console.error("Failed to verify checkout coupon", e), E(null), O(null), M(p("checkout_coupon_error"));
195
+ console.error("Failed to verify checkout coupon", e), O(null), A(null), P(p("checkout_coupon_error"));
196
196
  } finally {
197
- n || A(!1);
197
+ n || M(!1);
198
198
  }
199
199
  })(), () => {
200
200
  n = !0;
201
201
  };
202
202
  }, [
203
- N,
204
- I.end_date,
205
- I.end_time,
206
- I.start_date,
207
- I.start_time,
208
- L,
209
- W,
210
- q,
211
- g,
212
- tt,
203
+ F,
204
+ R.end_date,
205
+ R.end_time,
206
+ R.start_date,
207
+ R.start_time,
208
+ z,
209
+ K,
210
+ Y,
211
+ _,
212
+ $e,
213
213
  p
214
214
  ]), s(() => {
215
- if (!g || z.lines.length === 0 || !L) {
216
- x(null), w(null), S(!1);
215
+ if (!_ || V.lines.length === 0 || !z) {
216
+ S(null), T(null), C(!1);
217
217
  return;
218
218
  }
219
219
  let e = !1;
220
- return S(!0), w(null), (async () => {
220
+ return C(!0), T(null), (async () => {
221
221
  try {
222
222
  let t = await o(_e, {
223
- storeSlug: g,
224
- schedule: L,
225
- estimatedTotalMinor: J
223
+ storeSlug: _,
224
+ schedule: z,
225
+ estimatedTotalMinor: X,
226
+ insuranceAmountMinor: Z
226
227
  }), n = ve.parse(t);
227
228
  if (e) return;
228
229
  if (!n.success || !n.decision) {
229
- x(null), w(n.message || p("checkout_payment_error"));
230
+ S(null), T(n.message || p("checkout_payment_error"));
230
231
  return;
231
232
  }
232
- x(n.decision);
233
+ S(n.decision);
233
234
  } catch (t) {
234
235
  if (e) return;
235
- console.error("Failed to load checkout payment decision", t), x(null), w(p("checkout_payment_error"));
236
+ console.error("Failed to load checkout payment decision", t), S(null), T(p("checkout_payment_error"));
236
237
  } finally {
237
- e || S(!1);
238
+ e || C(!1);
238
239
  }
239
240
  })(), () => {
240
241
  e = !0;
241
242
  };
242
243
  }, [
243
- I.end_date,
244
- I.end_time,
245
- I.start_date,
246
- I.start_time,
247
- L,
248
- J,
249
- z.lines.length,
250
- g,
244
+ R.end_date,
245
+ R.end_time,
246
+ R.start_date,
247
+ R.start_time,
248
+ z,
249
+ X,
250
+ V.lines.length,
251
+ Z,
252
+ _,
251
253
  p
252
254
  ]);
253
- let Q = b?.currency ?? "EUR", Tt = f(J, Q, m.language), $ = D?.insuranceSubtotalMinor ?? 0, Et = Math.max(0, J - $), Dt = Math.round(Et / 1.2), Ot = Dt + $, kt = Math.max(0, Et - Dt), At = f(Ot, Q, m.language), jt = f(kt, Q, m.language), Mt = Ie(Fe, m.language), Nt = $ > 0 ? f($, Q, m.language) : void 0, Pt = b?.amountToCollectMinor ?? 0, Ft = b?.shouldCollectOnlinePayment === !0 && Pt > 0, It = wt.handleSubmit(async (e) => {
254
- if (!g || W.length === 0 || !L || y.current) return;
255
- Xe(!0), y.current = !0;
256
- let t = Ke();
255
+ let $ = x?.currency ?? "EUR", Tt = f(X, $, m.language), Et = Math.max(0, X - Z), Dt = Math.round(Et / 1.2), Ot = Dt + Z, kt = Math.max(0, Et - Dt), At = f(Ot, $, m.language), jt = f(kt, $, m.language), Mt = Ie(Fe, m.language), Nt = Z > 0 ? f(Z, $, m.language) : void 0, Pt = x?.amountToCollectMinor ?? 0, Ft = x?.shouldCollectOnlinePayment === !0 && Pt > 0, It = Ct.handleSubmit(async (e) => {
256
+ if (!_ || K.length === 0 || !z || b.current) return;
257
+ Ye(!0), b.current = !0;
258
+ let t = Ge();
257
259
  try {
258
260
  let n = await o(ie, {
259
- storeSlug: g,
261
+ storeSlug: _,
260
262
  checkoutSessionId: t.checkoutSessionId,
261
263
  replacesCheckoutSessionId: t.replacesCheckoutSessionId,
262
- schedule: L,
263
- fulfillment: I.fulfillment,
264
- startAddress: I.fulfillment === "delivery" ? I.start_address : void 0,
265
- endAddress: I.fulfillment === "delivery" ? I.end_address : void 0,
266
- couponCode: T?.code,
267
- couponAutoApplied: !N && T?.autoApplied,
268
- insuranceAccepted: q,
264
+ schedule: z,
265
+ fulfillment: R.fulfillment,
266
+ startAddress: R.fulfillment === "delivery" ? R.start_address : void 0,
267
+ endAddress: R.fulfillment === "delivery" ? R.end_address : void 0,
268
+ couponCode: D?.code,
269
+ couponAutoApplied: !F && D?.autoApplied,
270
+ insuranceAccepted: Y,
269
271
  customer: {
270
272
  firstName: e.first_name,
271
273
  lastName: e.last_name,
@@ -273,20 +275,20 @@ function p() {
273
275
  phone: e.phone,
274
276
  notes: e.notes
275
277
  },
276
- items: W
278
+ items: K
277
279
  }), r = ae.parse(n);
278
280
  if (!r.success || !r.checkout) {
279
- Je(), a.error(r.message || p("checkout_payment_error"));
281
+ qe(), a.error(r.message || p("checkout_payment_error"));
280
282
  return;
281
283
  }
282
- r.checkout.requiresPayment ? qe(r.checkout.checkoutSessionId ?? t.checkoutSessionId) : a.success(p("checkout_success_toast")), await Ve(r.checkout.nextPath), r.checkout.requiresPayment || Ye();
284
+ r.checkout.requiresPayment ? Ke(r.checkout.checkoutSessionId ?? t.checkoutSessionId) : a.success(p("checkout_success_toast")), await Be(r.checkout.nextPath), r.checkout.requiresPayment || Je();
283
285
  } catch (e) {
284
286
  console.error("Failed to submit storefront checkout", e), a.error(p("checkout_payment_error"));
285
287
  } finally {
286
- y.current = !1, Xe(!1);
288
+ b.current = !1, Ye(!1);
287
289
  }
288
- }), Lt = p(Ft ? "checkout_continue_to_payment" : "checkout_submit"), Rt = I.fulfillment === "delivery" && I.start_address.trim().length === 0, zt = !v && !Ze && !C && !k && !it && !!b && !!L && !Rt && W.length > 0;
289
- return z.lines.length === 0 ? /* @__PURE__ */ u("div", {
290
+ }), Lt = p(Ft ? "checkout_continue_to_payment" : "checkout_submit"), Rt = R.fulfillment === "delivery" && R.start_address.trim().length === 0, zt = !y && !Xe && !w && !j && !nt && !!x && !!z && !Rt && K.length > 0;
291
+ return V.lines.length === 0 ? /* @__PURE__ */ u("div", {
290
292
  className: "mx-auto max-w-3xl px-4 py-10 sm:px-6",
291
293
  children: /* @__PURE__ */ d("div", {
292
294
  className: "rounded-xl border border-slate-200 bg-white p-4 shadow-sm",
@@ -302,7 +304,7 @@ function p() {
302
304
  /* @__PURE__ */ u("div", {
303
305
  className: "mt-6",
304
306
  children: /* @__PURE__ */ u(Ee, {
305
- to: X,
307
+ to: xt,
306
308
  children: /* @__PURE__ */ d(de, {
307
309
  className: "gap-2",
308
310
  children: [/* @__PURE__ */ u(Me, {
@@ -316,9 +318,9 @@ function p() {
316
318
  })
317
319
  }) : /* @__PURE__ */ u(he, {
318
320
  currentStep: "checkout",
319
- bookingPath: X,
320
- checkoutPath: Ct,
321
- backPath: X,
321
+ bookingPath: xt,
322
+ checkoutPath: St,
323
+ backPath: xt,
322
324
  backLabel: p("back_to_booking"),
323
325
  children: /* @__PURE__ */ d("div", {
324
326
  className: "grid gap-6 lg:grid-cols-12",
@@ -329,7 +331,7 @@ function p() {
329
331
  className: "text-xl font-semibold tracking-tight text-slate-950",
330
332
  children: /* @__PURE__ */ u("span", { children: p("checkout_title") })
331
333
  }),
332
- L ? null : /* @__PURE__ */ u("p", {
334
+ z ? null : /* @__PURE__ */ u("p", {
333
335
  role: "alert",
334
336
  className: "mt-3 text-sm text-destructive",
335
337
  children: /* @__PURE__ */ u("span", { children: p("booking_time_slots_required") })
@@ -337,33 +339,33 @@ function p() {
337
339
  /* @__PURE__ */ d("div", {
338
340
  className: "mt-5 grid gap-4",
339
341
  children: [
340
- ut ? /* @__PURE__ */ u("div", {
342
+ ct ? /* @__PURE__ */ u("div", {
341
343
  className: "rounded-xl border border-slate-200 bg-white p-3 shadow-sm",
342
344
  children: /* @__PURE__ */ u(me, {
343
- value: I.fulfillment,
344
- onValueChange: (e) => Z({ fulfillment: e }),
345
- pickupAddress: dt,
346
- deliveryEnabled: F,
347
- deliveryDisabledReason: lt,
348
- startAddress: I.start_address,
349
- onStartAddressChange: (e) => Z({ start_address: e }),
350
- endAddress: I.end_address,
351
- onEndAddressChange: (e) => Z({ end_address: e }),
345
+ value: R.fulfillment,
346
+ onValueChange: (e) => wt({ fulfillment: e }),
347
+ pickupAddress: lt,
348
+ deliveryEnabled: L,
349
+ deliveryDisabledReason: st,
350
+ startAddress: R.start_address,
351
+ onStartAddressChange: (e) => wt({ start_address: e }),
352
+ endAddress: R.end_address,
353
+ onEndAddressChange: (e) => wt({ end_address: e }),
352
354
  showPickupAddressWhenPickupOnly: !1,
353
355
  testIdPrefix: "storefront-checkout-fulfillment"
354
356
  })
355
357
  }) : null,
356
- /* @__PURE__ */ u(xe, { form: wt }),
357
- K ? /* @__PURE__ */ u(Se, {
358
- accepted: q,
359
- disabled: v || k,
360
- dailyAmountLabel: f(yt, Q, m.language),
358
+ /* @__PURE__ */ u(xe, { form: Ct }),
359
+ J ? /* @__PURE__ */ u(Se, {
360
+ accepted: Y,
361
+ disabled: y || j,
362
+ dailyAmountLabel: f(_t, $, m.language),
361
363
  totalAmountLabel: Nt,
362
- billableDays: D?.insuranceBillableDays,
363
- deductibleLabel: bt > 0 ? f(bt, Q, m.language) : void 0,
364
- onAcceptedChange: ot
364
+ billableDays: k?.insuranceBillableDays,
365
+ deductibleLabel: vt > 0 ? f(vt, $, m.language) : void 0,
366
+ onAcceptedChange: it
365
367
  }) : null,
366
- Ze ? /* @__PURE__ */ d("div", {
368
+ Xe ? /* @__PURE__ */ d("div", {
367
369
  className: "flex items-center gap-2 text-sm text-slate-600",
368
370
  role: "status",
369
371
  children: [/* @__PURE__ */ u(ge, {
@@ -371,13 +373,13 @@ function p() {
371
373
  "aria-hidden": "true"
372
374
  }), /* @__PURE__ */ u("span", { children: p("checkout_payment_loading") })]
373
375
  }) : null,
374
- C ? /* @__PURE__ */ d("div", {
376
+ w ? /* @__PURE__ */ d("div", {
375
377
  className: "flex items-start gap-2 rounded-md bg-destructive p-3 text-sm text-destructive-foreground shadow-sm",
376
378
  role: "alert",
377
379
  children: [/* @__PURE__ */ u(je, {
378
380
  className: "mt-0.5 h-4 w-4",
379
381
  "aria-hidden": "true"
380
- }), /* @__PURE__ */ u("span", { children: C })]
382
+ }), /* @__PURE__ */ u("span", { children: w })]
381
383
  }) : null,
382
384
  /* @__PURE__ */ u(de, {
383
385
  type: "button",
@@ -397,31 +399,31 @@ function p() {
397
399
  })
398
400
  ]
399
401
  }), /* @__PURE__ */ u(Ce, {
400
- lines: _t.lines,
401
- itemCount: Ue,
402
- baseUnitLabel: pt,
402
+ lines: ht.lines,
403
+ itemCount: He,
404
+ baseUnitLabel: dt,
403
405
  bookingSubtotalLabel: At,
404
406
  vatAmountLabel: jt,
405
407
  vatRateLabel: Mt,
406
408
  bookingTotalLabel: Tt,
407
- onQuantityChange: We,
408
- onRemove: Ge,
409
+ onQuantityChange: Ue,
410
+ onRemove: We,
409
411
  coupon: {
410
- code: $e,
411
- appliedCode: T?.code,
412
- discountLabel: T && St > 0 ? f(St, Q, m.language) : null,
413
- message: rt,
414
- error: it,
415
- loading: k,
416
- disabled: v,
412
+ code: Qe,
413
+ appliedCode: D?.code,
414
+ discountLabel: D && bt > 0 ? f(bt, $, m.language) : null,
415
+ message: tt,
416
+ error: nt,
417
+ loading: j,
418
+ disabled: y,
417
419
  onCodeChange: (e) => {
418
- et(e), M(null), j(null);
420
+ E(e), P(null), N(null);
419
421
  },
420
422
  onApply: () => {
421
- at(!1), nt($e.trim());
423
+ rt(!1), et(Qe.trim());
422
424
  },
423
425
  onRemove: () => {
424
- et(""), nt(""), E(null), O(null), M(null), j(null), at(!0);
426
+ E(""), et(""), O(null), A(null), P(null), N(null), rt(!0);
425
427
  }
426
428
  }
427
429
  })]
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loczer/storefront-sdk",
3
- "version": "0.222.0",
3
+ "version": "0.223.0",
4
4
  "publishConfig": {
5
5
  "access": "public",
6
6
  "registry": "https://registry.npmjs.org/"