@loczer/storefront-sdk 0.212.0 → 0.214.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 (62) hide show
  1. package/dist/StorefrontContext.d.ts +18 -0
  2. package/dist/StorefrontContext.d.ts.map +1 -1
  3. package/dist/StorefrontProvider.d.ts +9 -0
  4. package/dist/StorefrontProvider.d.ts.map +1 -1
  5. package/dist/chunks/pkg/ui/dist/Drawer/{index-CSvSVP_J.js → index-Dp62Y2o5.js} +10 -7
  6. package/dist/chunks/pkg/ui/dist/{ResponsiveDialog-BVwhTZQo.js → ResponsiveDialog-BJ0RG6gh.js} +1 -1
  7. package/dist/components/BikeProductCard/index.d.ts.map +1 -1
  8. package/dist/components/BikeProductCard/index.js +5 -5
  9. package/dist/components/BookingBikeVariantDialog/index.d.ts.map +1 -1
  10. package/dist/components/BookingBikeVariantDialog/index.js +23 -27
  11. package/dist/components/BookingFlowSteps/index.d.ts.map +1 -1
  12. package/dist/components/BookingFlowSteps/index.js +73 -32
  13. package/dist/components/BookingPeriodSelector/components/BookingEndDateField.js +1 -1
  14. package/dist/components/BookingPeriodSelector/components/BookingEndTimeField.js +1 -1
  15. package/dist/components/BookingPeriodSelector/components/BookingMobileDateDrawer.js +16 -16
  16. package/dist/components/BookingPeriodSelector/components/BookingStartDateField.js +1 -1
  17. package/dist/components/BookingPeriodSelector/components/BookingStartTimeField.js +1 -1
  18. package/dist/components/BookingPeriodSelector/components/internal/StorefrontHourPickerField.js +2 -2
  19. package/dist/components/BookingPeriodSelector/index.js +3 -3
  20. package/dist/components/Footer/index.d.ts +2 -1
  21. package/dist/components/Footer/index.d.ts.map +1 -1
  22. package/dist/components/Footer/index.js +64 -58
  23. package/dist/components/FulfillmentSection/index.js +10 -4
  24. package/dist/components/Header/index.d.ts.map +1 -1
  25. package/dist/components/Header/index.js +205 -100
  26. package/dist/components/Layout/index.d.ts.map +1 -1
  27. package/dist/components/Layout/index.js +3 -2
  28. package/dist/components/PlatformFooter/index.js +6 -6
  29. package/dist/components/ProductPriceBadge/index.js +16 -10
  30. package/dist/components/StorefrontCancellationPolicyNotice/index.js +1 -1
  31. package/dist/components/StorefrontInsuranceNotice/index.js +1 -1
  32. package/dist/components/StorefrontPopupMessages/index.js +1 -1
  33. package/dist/i18n/en.d.ts +13 -4
  34. package/dist/i18n/en.d.ts.map +1 -1
  35. package/dist/i18n/en.js +13 -4
  36. package/dist/i18n/fr.d.ts +13 -4
  37. package/dist/i18n/fr.d.ts.map +1 -1
  38. package/dist/i18n/fr.js +13 -4
  39. package/dist/index.d.ts +88 -11
  40. package/dist/index.js +69 -68
  41. package/dist/lib/cart.d.ts +6 -2
  42. package/dist/lib/cart.d.ts.map +1 -1
  43. package/dist/lib/cart.js +45 -23
  44. package/dist/lib/checkoutSubmit.d.ts +3 -0
  45. package/dist/lib/checkoutSubmit.d.ts.map +1 -1
  46. package/dist/lib/checkoutSubmit.js +14 -2
  47. package/dist/pages/BookingPage.d.ts.map +1 -1
  48. package/dist/pages/BookingPage.js +8 -2
  49. package/dist/pages/CheckoutPage.d.ts.map +1 -1
  50. package/dist/pages/CheckoutPage.js +235 -245
  51. package/dist/pages/HomePage.d.ts.map +1 -1
  52. package/dist/pages/HomePage.js +253 -235
  53. package/dist/pages/RentalTermsPage.d.ts +2 -0
  54. package/dist/pages/RentalTermsPage.d.ts.map +1 -0
  55. package/dist/pages/RentalTermsPage.js +52 -0
  56. package/dist/routes.d.ts.map +1 -1
  57. package/dist/routes.js +14 -10
  58. package/dist/storefront.css +1 -1
  59. package/dist/storefrontSchemas.d.ts +19 -0
  60. package/dist/storefrontSchemas.d.ts.map +1 -1
  61. package/dist/storefrontSchemas.js +39 -35
  62. package/package.json +1 -1
package/dist/lib/cart.js CHANGED
@@ -14,7 +14,7 @@ var c = t(void 0), l = "loczer.storefront.cart.v5", u = () => globalThis.crypto?
14
14
  }, m = (e) => {
15
15
  if (!e) return { items: [] };
16
16
  try {
17
- let t = JSON.parse(e), n = typeof t.checkoutSessionId == "string" ? t.checkoutSessionId.trim() : "";
17
+ let t = JSON.parse(e), n = typeof t.checkoutSessionId == "string" ? t.checkoutSessionId.trim() : "", r = t.checkoutSessionStage === "submitting" ? "submitting" : n ? "payment" : void 0, i = r === "submitting" && typeof t.replacesCheckoutSessionId == "string" ? t.replacesCheckoutSessionId.trim() : "";
18
18
  return {
19
19
  items: (Array.isArray(t.items) ? t.items : []).map((e) => {
20
20
  let t = e ?? {}, n = t.kind === "accessory" ? "accessory" : t.kind === "e-bike" ? "e-bike" : t.kind === "bike" ? "bike" : null, r = typeof t.productId == "string" ? t.productId.trim() : "", i = typeof t.productVariantId == "string" ? t.productVariantId.trim() : "", a = typeof t.quantity == "number" ? Math.floor(t.quantity) : 0;
@@ -30,7 +30,9 @@ var c = t(void 0), l = "loczer.storefront.cart.v5", u = () => globalThis.crypto?
30
30
  ...o
31
31
  };
32
32
  }).filter((e) => e !== null),
33
- ...n ? { checkoutSessionId: n } : {}
33
+ ...n ? { checkoutSessionId: n } : {},
34
+ ...r ? { checkoutSessionStage: r } : {},
35
+ ...i && i !== n ? { replacesCheckoutSessionId: i } : {}
34
36
  };
35
37
  } catch {
36
38
  return { items: [] };
@@ -107,43 +109,63 @@ function h({ storeSlug: e, products: t, children: r }) {
107
109
  }));
108
110
  }, []), w = n(() => {
109
111
  let e = _.checkoutSessionId?.trim();
110
- if (e) return e;
112
+ if (e && _.checkoutSessionStage === "submitting") return {
113
+ checkoutSessionId: e,
114
+ ..._.replacesCheckoutSessionId ? { replacesCheckoutSessionId: _.replacesCheckoutSessionId } : {}
115
+ };
111
116
  let t = u(), n = {
112
- ..._,
113
- checkoutSessionId: t
117
+ items: _.items,
118
+ checkoutSessionId: t,
119
+ checkoutSessionStage: "submitting",
120
+ ...e ? { replacesCheckoutSessionId: e } : {}
121
+ };
122
+ return v(n), typeof window < "u" && window.localStorage.setItem(f, JSON.stringify(n)), {
123
+ checkoutSessionId: t,
124
+ ...e ? { replacesCheckoutSessionId: e } : {}
114
125
  };
115
- return v(n), typeof window < "u" && window.localStorage.setItem(f, JSON.stringify(n)), t;
116
- }, [_, f]), T = n(() => {
117
- let e = { items: _.items };
118
- v(e), typeof window < "u" && window.localStorage.setItem(f, JSON.stringify(e));
119
- }, [_.items, f]), E = n(() => {
126
+ }, [_, f]), T = n((e) => {
127
+ let t = e.trim();
128
+ t && v((e) => {
129
+ let n = {
130
+ items: e.items,
131
+ checkoutSessionId: t,
132
+ checkoutSessionStage: "payment"
133
+ };
134
+ return typeof window < "u" && window.localStorage.setItem(f, JSON.stringify(n)), n;
135
+ });
136
+ }, [f]), E = n(() => {
137
+ v((e) => {
138
+ let t = { items: e.items };
139
+ return typeof window < "u" && window.localStorage.setItem(f, JSON.stringify(t)), t;
140
+ });
141
+ }, [f]), D = n(() => {
120
142
  v({ items: [] });
121
- }, []), D = p(_.items, {
143
+ }, []), O = p(_.items, {
122
144
  bikes: y,
123
145
  accessories: b
124
- }), O = D.reduce((e, t) => e + t.quantity, 0), k = a(() => ({
125
- items: D,
126
- itemCount: O,
127
- checkoutSessionId: _.checkoutSessionId,
146
+ }), k = O.reduce((e, t) => e + t.quantity, 0), A = a(() => ({
147
+ items: O,
148
+ itemCount: k,
128
149
  addItem: x,
129
150
  setQuantity: S,
130
151
  removeItem: C,
131
- ensureCheckoutSessionId: w,
132
- clearCheckoutSession: T,
133
- clear: E
152
+ beginCheckoutSubmission: w,
153
+ confirmCheckoutPaymentSession: T,
154
+ clearCheckoutSession: E,
155
+ clear: D
134
156
  }), [
135
157
  x,
158
+ w,
159
+ D,
136
160
  E,
137
161
  T,
138
- w,
162
+ k,
139
163
  O,
140
- D,
141
164
  C,
142
- S,
143
- _.checkoutSessionId
165
+ S
144
166
  ]);
145
167
  return /* @__PURE__ */ s(c.Provider, {
146
- value: k,
168
+ value: A,
147
169
  children: r
148
170
  });
149
171
  }
@@ -12,6 +12,7 @@ export type RequestCheckoutItem = z.infer<typeof requestCheckoutItemSchema>;
12
12
  export declare const requestBaseSchema: z.ZodObject<{
13
13
  storeSlug: z.ZodString;
14
14
  checkoutSessionId: z.ZodOptional<z.ZodString>;
15
+ replacesCheckoutSessionId: z.ZodOptional<z.ZodString>;
15
16
  schedule: z.ZodObject<{
16
17
  startDate: z.ZodString;
17
18
  endDate: z.ZodString;
@@ -50,6 +51,7 @@ export declare const requestDeliveryRefinement: (payload: {
50
51
  export declare const requestSchema: z.ZodObject<{
51
52
  storeSlug: z.ZodString;
52
53
  checkoutSessionId: z.ZodOptional<z.ZodString>;
54
+ replacesCheckoutSessionId: z.ZodOptional<z.ZodString>;
53
55
  schedule: z.ZodObject<{
54
56
  startDate: z.ZodString;
55
57
  endDate: z.ZodString;
@@ -92,6 +94,7 @@ export declare const responseSchema: z.ZodObject<{
92
94
  nextPath: z.ZodString;
93
95
  successPath: z.ZodString;
94
96
  requiresPayment: z.ZodBoolean;
97
+ checkoutSessionId: z.ZodOptional<z.ZodString>;
95
98
  }, z.core.$strip>>;
96
99
  }, z.core.$strip>;
97
100
  export type ResponsePayload = z.infer<typeof responseSchema>;
@@ -1 +1 @@
1
- {"version":3,"file":"checkoutSubmit.d.ts","sourceRoot":"","sources":["../../src/lib/checkoutSubmit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAQvB,OAAO,EAEL,0CAA0C,EAC3C,MAAM,2BAA2B,CAAA;AAGlC,OAAO,EAAE,0CAA0C,EAAE,CAAA;AAGrD,eAAO,MAAM,KAAK,2CAA2C,CAAA;AAE7D,eAAO,MAAM,yBAAyB;;;;;iBAKpC,CAAA;AACF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAA;AAI3E,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBA8B5B,CAAA;AAEF,eAAO,MAAM,yBAAyB,GACpC,SAAS;IAAE,WAAW,CAAC,EAAE,MA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MAAM,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,cAAc,CAAC,CAAA"}
@@ -13,6 +13,7 @@ var s = "/api/public/storefront/checkout/submit", c = o.object({
13
13
  }), l = o.object({
14
14
  storeSlug: o.string().trim().min(1).toLowerCase(),
15
15
  checkoutSessionId: o.string().trim().min(1).max(256).optional(),
16
+ replacesCheckoutSessionId: o.string().trim().min(1).max(256).optional(),
16
17
  schedule: n,
17
18
  fulfillment: r.default(t),
18
19
  startAddress: o.string().trim().max(500).optional(),
@@ -42,7 +43,17 @@ var s = "/api/public/storefront/checkout/submit", c = o.object({
42
43
  message: "Delivery start address is required.",
43
44
  path: ["startAddress"]
44
45
  }));
45
- }, d = l.superRefine(u), f = o.object({
46
+ }, d = l.superRefine((e, t) => {
47
+ u(e, t), e.replacesCheckoutSessionId && !e.checkoutSessionId && t.addIssue({
48
+ code: o.ZodIssueCode.custom,
49
+ message: "A replacement checkout session requires a new checkout session id.",
50
+ path: ["checkoutSessionId"]
51
+ }), e.checkoutSessionId && e.replacesCheckoutSessionId === e.checkoutSessionId && t.addIssue({
52
+ code: o.ZodIssueCode.custom,
53
+ message: "The new and replaced checkout session ids must differ.",
54
+ path: ["replacesCheckoutSessionId"]
55
+ });
56
+ }), f = o.object({
46
57
  success: o.boolean(),
47
58
  message: o.string().optional(),
48
59
  errorCode: a.optional(),
@@ -51,7 +62,8 @@ var s = "/api/public/storefront/checkout/submit", c = o.object({
51
62
  saleId: o.string().trim().min(1),
52
63
  nextPath: o.string().trim().min(1),
53
64
  successPath: o.string().trim().min(1),
54
- requiresPayment: o.boolean()
65
+ requiresPayment: o.boolean(),
66
+ checkoutSessionId: o.string().trim().min(1).max(256).optional()
55
67
  }).optional()
56
68
  });
57
69
  //#endregion
@@ -1 +1 @@
1
- {"version":3,"file":"BookingPage.d.ts","sourceRoot":"","sources":["../../src/pages/BookingPage.tsx"],"names":[],"mappings":"AAuMA,MAAM,CAAC,OAAO,UAAU,WAAW,4CA2nBlC"}
1
+ {"version":3,"file":"BookingPage.d.ts","sourceRoot":"","sources":["../../src/pages/BookingPage.tsx"],"names":[],"mappings":"AAuMA,MAAM,CAAC,OAAO,UAAU,WAAW,4CAioBlC"}
@@ -185,6 +185,9 @@ function S() {
185
185
  pickEndDate: v("booking_end_date"),
186
186
  endTime: v("booking_end_time"),
187
187
  selectedDaysTooltip: ({ count: e }) => v("booking_selected_days_tooltip", { count: e }),
188
+ rentalPeriod: v("booking_rental_period"),
189
+ dateDrawerNext: v("booking_date_drawer_continue"),
190
+ closeDrawer: v("booking_date_drawer_close"),
188
191
  timeSlotsLoading: v("booking_time_slots_loading"),
189
192
  timeSlotsUnavailable: v("booking_time_slots_unavailable"),
190
193
  timeSlotsLoadError: v("booking_time_slots_load_error"),
@@ -211,6 +214,7 @@ function S() {
211
214
  endTime: I.end_time,
212
215
  onEndTimeChange: (e) => W({ end_time: e }),
213
216
  bookingPeriodConfig: Qe,
217
+ withMobileDateDrawer: !0,
214
218
  fetchTimeSlots: ft,
215
219
  onTimeSlotsConfirmationChange: (e) => {
216
220
  it(e ? at : void 0);
@@ -358,7 +362,7 @@ function S() {
358
362
  /* @__PURE__ */ g("div", {
359
363
  className: "grid gap-6 lg:grid-cols-12",
360
364
  children: [/* @__PURE__ */ h("div", {
361
- className: "lg:col-span-8",
365
+ className: "min-w-0 lg:col-span-8",
362
366
  children: /* @__PURE__ */ g("div", {
363
367
  className: "space-y-6",
364
368
  children: [
@@ -371,6 +375,7 @@ function S() {
371
375
  }),
372
376
  /* @__PURE__ */ h(me, {
373
377
  ...mt,
378
+ selectionFlow: "dates-first",
374
379
  className: "gap-3",
375
380
  labelClassName: "text-xs font-medium text-slate-700",
376
381
  inputClassName: "h-10"
@@ -385,6 +390,7 @@ function S() {
385
390
  onStartAddressChange: (e) => W({ start_address: e }),
386
391
  endAddress: I.end_address,
387
392
  onEndAddressChange: (e) => W({ end_address: e }),
393
+ showPickupAddressWhenPickupOnly: !1,
388
394
  testIdPrefix: "storefront-booking-fulfillment"
389
395
  })
390
396
  ]
@@ -513,7 +519,7 @@ function S() {
513
519
  ]
514
520
  })
515
521
  }), /* @__PURE__ */ h("div", {
516
- className: "lg:col-span-4",
522
+ className: "min-w-0 lg:col-span-4",
517
523
  children: /* @__PURE__ */ h(ve, {
518
524
  lines: _t.lines,
519
525
  itemCount: j,
@@ -1 +1 @@
1
- {"version":3,"file":"CheckoutPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPage.tsx"],"names":[],"mappings":"AAuGA,MAAM,CAAC,OAAO,UAAU,YAAY,4CAutBnC"}
1
+ {"version":3,"file":"CheckoutPage.d.ts","sourceRoot":"","sources":["../../src/pages/CheckoutPage.tsx"],"names":[],"mappings":"AAuGA,MAAM,CAAC,OAAO,UAAU,YAAY,4CA6sBnC"}