@instockng/storefront-ui 1.0.12 → 1.0.14

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.
@@ -1 +1 @@
1
- {"version":3,"file":"Checkout.d.ts","sourceRoot":"","sources":["../../src/components/Checkout.tsx"],"names":[],"mappings":"AA4FA,MAAM,MAAM,aAAa,GAAG,KAAK,GAAG,QAAQ,CAAC;AAE7C,MAAM,WAAW,gBAAgB;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,EAAE,aAAa,CAAC;IAC7B,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,aAAa;IAC5B,gCAAgC;IAChC,MAAM,EAAE,OAAO,CAAC;IAChB,uCAAuC;IACvC,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,wBAAwB;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACxC,sCAAsC;IACtC,SAAS,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC;IACtC,wBAAwB;IACxB,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;IACjC,yBAAyB;IACzB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,qCAAqC;IACrC,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;IACjD,4BAA4B;IAC5B,YAAY,CAAC,EAAE;QACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC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ACb,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;KACrB,CAAC;CACH;AAID,wBAAgB,QAAQ,CAAC,EACvB,MAAM,EACN,OAAO,EACP,WAAW,EACX,SAAS,EACT,OAAO,EACP,gBAAgC,EAChC,YAAY,GACb,EAAE,aAAa,2CAszBf"}
@@ -32,6 +32,8 @@ interface CartContextValue {
32
32
  removeDiscount: () => Promise<void>;
33
33
  /** Clear cart (removes from localStorage) */
34
34
  clearCart: () => void;
35
+ /** Clear cart and create a new one immediately */
36
+ clearAndCreateNewCart: () => void;
35
37
  /** Refresh cart data */
36
38
  refetch: () => void;
37
39
  /** Whether the cart modal is open */
@@ -1 +1 @@
1
- {"version":3,"file":"CartContext.d.ts","sourceRoot":"","sources":["../../src/contexts/CartContext.tsx"],"names":[],"mappings":"AAEA;;;;;;GAMG;AAEH,OAAO,EAAkD,SAAS,EAAuB,MAAM,OAAO,CAAC;AACvG,OAAO,EAGL,aAAa,EAMb,eAAe,EACf,KAAK,IAAI,EACV,MAAM,iBAAiB,CAAC;AAKzB,UAAU,gBAAgB;IACxB,wBAAwB;IACxB,IAAI,EAAE,IAAI,GAAG,IAAI,CAAC;IAClB,mDAAmD;IACnD,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,oBAAoB;IACpB,SAAS,EAAE,OAAO,CAAC;IACnB,kBAAkB;IAClB,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IACpB,gDAAgD;IAChD,kBAAkB,EAAE,UAAU,CAAC,OAAO,aAAa,CAAC,CAAC;IACrD,+CAA+C;IAC/C,gBAAgB,EAAE,UAAU,CAAC,OAAO,eAAe,CAAC,CAAC;IACrD,8BAA8B;IAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1D,2BAA2B;IAC3B,UAAU,EAAE,CAAC,MAAM,EAAE,M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,eAAO,MAAM,WAAW,kDAA+C,CAAC;AAExE,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,SAAS,CAAC;IACpB,qCAAqC;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,kDAAkD;IAClD,iBAAiB,CAAC,EAAE,IAAI,CAAC,OAAO,4BAA4B,EAAE,iBAAiB,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;CACxG;AAED,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,SAAS,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,iBAAiB,2CAoPxG;AAED;;GAEG;AACH,wBAAgB,OAAO,qBAMtB"}
package/dist/index10.mjs CHANGED
@@ -1,51 +1,51 @@
1
1
  'use client';
2
- import { jsxs as a, jsx as e, Fragment as fe } from "react/jsx-runtime";
3
- import { useState as N, useEffect as q, useMemo as te, useCallback as pe } from "react";
4
- import { object as $, string as y, ValidationError as ve } from "./index34.mjs";
2
+ import { jsxs as a, jsx as e, Fragment as pe } from "react/jsx-runtime";
3
+ import { useState as N, useEffect as q, useMemo as re, useCallback as ve } from "react";
4
+ import { object as $, string as y, ValidationError as Ne } from "./index34.mjs";
5
5
  import "./index18.mjs";
6
6
  import "@tanstack/react-query";
7
- import { useGetDeliveryZones as Ne } from "./index32.mjs";
8
- import { useCart as ge } from "./index3.mjs";
9
- import { Modal as re } from "./index14.mjs";
7
+ import { useGetDeliveryZones as ge } from "./index32.mjs";
8
+ import { useCart as be } from "./index3.mjs";
9
+ import { Modal as ae } from "./index14.mjs";
10
10
  import { FormInput as P } from "./index15.mjs";
11
- import { FormSelect as ae } from "./index16.mjs";
11
+ import { FormSelect as se } from "./index16.mjs";
12
12
  import { Button as L } from "./index11.mjs";
13
- import { Loader2 as R, ChevronLeft as be, ChevronRight as xe, CheckCircle as we, Package as Ce, Mail as Pe, Phone as ke, Zap as Me, Banknote as qe, ChevronDown as Ie } from "lucide-react";
13
+ import { Loader2 as R, ChevronLeft as xe, ChevronRight as we, CheckCircle as Ce, Package as Pe, Mail as ke, Phone as Me, Zap as qe, Banknote as Ie, ChevronDown as Ze } from "lucide-react";
14
14
  import { formatCurrency as k, cn as w } from "./index17.mjs";
15
- import Ze from "./index35.mjs";
16
- import { usePaystackPayment as je } from "./index36.mjs";
17
- const Se = (d) => d.replace(/\D/g, ""), ze = $({
15
+ import je from "./index35.mjs";
16
+ import { usePaystackPayment as Se } from "./index36.mjs";
17
+ const ze = (d) => d.replace(/\D/g, ""), Fe = $({
18
18
  firstName: y().required("First name is required").min(2, "First name must be at least 2 characters").max(50, "First name must be less than 50 characters"),
19
19
  lastName: y().required("Last name is required").min(2, "Last name must be at least 2 characters").max(50, "Last name must be less than 50 characters"),
20
20
  email: y().required("Email is required").email("Please enter a valid email address"),
21
21
  phone: y().required("Phone number is required").test("nigerian-phone", "Please enter a valid Nigerian phone number (e.g. 0812 564 8668)", (d) => {
22
22
  if (!d) return !1;
23
- const M = Se(d);
23
+ const M = ze(d);
24
24
  return [
25
25
  /^0[789]\d{9}$/
26
26
  // 0xxxxxxxxx (11 digits total)
27
27
  ].some((f) => f.test(M));
28
28
  })
29
- }), Fe = $({
29
+ }), Le = $({
30
30
  address: y().required("Street address is required").min(10, "Please provide a complete address"),
31
31
  city: y().required("City is required").min(3, "City name must be at least 3 characters"),
32
32
  state: y().required("State is required").test("not-empty", "State is required", (d) => !!d && d.trim() !== ""),
33
33
  deliveryZoneId: y().required("Delivery zone is required").test("not-empty", "Delivery zone is required", (d) => !!d && d.trim() !== "")
34
- }), Le = $({
34
+ }), Be = $({
35
35
  paymentMethod: y().oneOf(["cod", "online"], "Please select a payment method").required("Payment method is required")
36
36
  });
37
- function Xe({
37
+ function Ee({
38
38
  isOpen: d,
39
39
  onClose: M,
40
40
  initialData: l,
41
41
  onSuccess: f,
42
42
  onError: c,
43
- submitButtonText: se = "Place Order",
43
+ submitButtonText: ne = "Place Order",
44
44
  refundPolicy: I
45
45
  }) {
46
- var W, J, Q, U, X, E, D, ee;
47
- const ne = "pk_live_dfb74efb5f74d2acbc253d5ca396ab9015ef0fa7", [o, p] = N("customer"), [Z, le] = N(void 0), [g, G] = N(void 0), [u, B] = N(null), { refetch: K, isLoading: O, cart: s, updateCartMutation: T, checkoutMutation: de } = ge(), V = je({
48
- publicKey: ne,
46
+ var J, Q, U, X, E, D, ee, te;
47
+ const le = "pk_live_dfb74efb5f74d2acbc253d5ca396ab9015ef0fa7", [o, p] = N("customer"), [Z, de] = N(void 0), [g, G] = N(void 0), [u, B] = N(null), { refetch: K, isLoading: O, cart: s, updateCartMutation: T, checkoutMutation: ie, clearAndCreateNewCart: V } = be(), Y = Se({
48
+ publicKey: le,
49
49
  onSuccess: async (t) => {
50
50
  try {
51
51
  const n = await C.mutateAsync({
@@ -64,7 +64,7 @@ function Xe({
64
64
  c == null || c(new Error((i == null ? void 0 : i.message) || "Checkout failed"));
65
65
  return;
66
66
  }
67
- B(n), f == null || f(n.id);
67
+ B(n), V(), f == null || f(n.id);
68
68
  } catch (n) {
69
69
  c == null || c(n);
70
70
  }
@@ -76,9 +76,9 @@ function Xe({
76
76
  q(() => {
77
77
  d && K();
78
78
  }, [d, K]);
79
- const { data: b } = Ne(((W = s == null ? void 0 : s.brand) == null ? void 0 : W.id) || "", {
80
- enabled: !!((J = s == null ? void 0 : s.brand) != null && J.id)
81
- }), h = te(() => b == null ? void 0 : b.find((t) => t.id === Z), [b, Z]), C = de;
79
+ const { data: b } = ge(((J = s == null ? void 0 : s.brand) == null ? void 0 : J.id) || "", {
80
+ enabled: !!((Q = s == null ? void 0 : s.brand) != null && Q.id)
81
+ }), h = re(() => b == null ? void 0 : b.find((t) => t.id === Z), [b, Z]), C = ie;
82
82
  q(() => {
83
83
  d || (B(null), p("customer"), C.reset());
84
84
  }, [d]);
@@ -96,9 +96,9 @@ function Xe({
96
96
  q(() => {
97
97
  d && p("customer");
98
98
  }, [d]);
99
- const [Y, H] = N(!1);
99
+ const [H, W] = N(!1);
100
100
  q(() => {
101
- d && s && !l && !Y && (_((t) => {
101
+ d && s && !l && !H && (_((t) => {
102
102
  var n;
103
103
  return {
104
104
  ...t,
@@ -108,8 +108,8 @@ function Xe({
108
108
  phone: s.customerPhone || t.phone,
109
109
  deliveryZoneId: ((n = s.deliveryZone) == null ? void 0 : n.id) || t.deliveryZoneId
110
110
  };
111
- }), H(!0)), d || H(!1);
112
- }, [d, s, l, Y]), q(() => {
111
+ }), W(!0)), d || W(!1);
112
+ }, [d, s, l, H]), q(() => {
113
113
  if (g) {
114
114
  const t = h == null ? void 0 : h.zones.find((n) => n.id === g);
115
115
  t && _((n) => ({
@@ -118,10 +118,10 @@ function Xe({
118
118
  }));
119
119
  }
120
120
  }, [g, h]);
121
- const [m, j] = N({}), [A, ie] = N(!1), v = (t) => {
121
+ const [m, j] = N({}), [A, ce] = N(!1), v = (t) => {
122
122
  const { name: n, value: i } = t.target;
123
123
  _((x) => ({ ...x, [n]: i })), m[n] && j((x) => ({ ...x, [n]: void 0 }));
124
- }, S = pe(
124
+ }, S = ve(
125
125
  (t) => {
126
126
  const n = r[t];
127
127
  if (!n) return;
@@ -133,7 +133,7 @@ function Xe({
133
133
  const n = {};
134
134
  try {
135
135
  if (t === "customer")
136
- ze.validateSync(r, { abortEarly: !1 });
136
+ Fe.validateSync(r, { abortEarly: !1 });
137
137
  else if (t === "delivery") {
138
138
  const i = {
139
139
  address: r.address,
@@ -141,19 +141,19 @@ function Xe({
141
141
  state: Z || r.state || "",
142
142
  deliveryZoneId: g || r.deliveryZoneId || ""
143
143
  };
144
- Fe.validateSync(i, { abortEarly: !1 });
145
- } else t === "payment" && Le.validateSync(r, { abortEarly: !1 });
144
+ Le.validateSync(i, { abortEarly: !1 });
145
+ } else t === "payment" && Be.validateSync(r, { abortEarly: !1 });
146
146
  } catch (i) {
147
- i instanceof ve && i.inner.forEach((x) => {
147
+ i instanceof Ne && i.inner.forEach((x) => {
148
148
  x.path && (n[x.path] = x.message);
149
149
  });
150
150
  }
151
151
  return j(n), Object.keys(n).length === 0;
152
- }, ce = () => {
153
- z(o) && (o === "customer" ? p("delivery") : o === "delivery" && p("payment"));
154
152
  }, oe = () => {
153
+ z(o) && (o === "customer" ? p("delivery") : o === "delivery" && p("payment"));
154
+ }, me = () => {
155
155
  o === "payment" ? p("delivery") : o === "delivery" && p("customer");
156
- }, me = async () => {
156
+ }, ue = async () => {
157
157
  if (!z("customer")) {
158
158
  p("customer");
159
159
  return;
@@ -164,12 +164,12 @@ function Xe({
164
164
  }
165
165
  if (z("payment")) {
166
166
  if (r.paymentMethod === "online") {
167
- if (!V.isLoaded) {
167
+ if (!Y.isLoaded) {
168
168
  c == null || c(new Error("Payment system is loading. Please try again."));
169
169
  return;
170
170
  }
171
171
  const t = Math.round(s.pricing.total * 100);
172
- V.initializePayment({
172
+ Y.initializePayment({
173
173
  email: r.email || (s == null ? void 0 : s.customerEmail) || "customer@example.com",
174
174
  amount: t,
175
175
  currency: "NGN",
@@ -207,37 +207,37 @@ function Xe({
207
207
  c == null || c(new Error((n == null ? void 0 : n.message) || "Checkout failed"));
208
208
  return;
209
209
  }
210
- B(t), f == null || f(t.id);
210
+ B(t), V(), f == null || f(t.id);
211
211
  } catch (t) {
212
212
  c == null || c(t);
213
213
  }
214
214
  }
215
- }, ue = {
215
+ }, he = {
216
216
  customer: "Customer Information",
217
217
  delivery: "Delivery Address",
218
218
  payment: "Payment Method"
219
- }, he = te(() => ue[o], [o]), ye = /* @__PURE__ */ a("div", { className: "space-y-3", children: [
220
- (o === "payment" || o === "delivery") && ((Q = s == null ? void 0 : s.pricing) == null ? void 0 : Q.total) && /* @__PURE__ */ a("div", { className: "text-sm text-black relative", children: [
219
+ }, ye = re(() => he[o], [o]), fe = /* @__PURE__ */ a("div", { className: "space-y-3", children: [
220
+ (o === "payment" || o === "delivery") && ((U = s == null ? void 0 : s.pricing) == null ? void 0 : U.total) && /* @__PURE__ */ a("div", { className: "text-sm text-black relative", children: [
221
221
  O && /* @__PURE__ */ e("div", { className: "absolute flex items-center justify-center inset-0 bg-white opacity-50", children: /* @__PURE__ */ e(R, { className: "animate-spin text-accent-500" }) }),
222
222
  /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
223
223
  /* @__PURE__ */ e("span", { children: "Subtotal" }),
224
- /* @__PURE__ */ e("span", { children: k(((U = s == null ? void 0 : s.pricing) == null ? void 0 : U.subtotal) ?? 0) })
224
+ /* @__PURE__ */ e("span", { children: k(((X = s == null ? void 0 : s.pricing) == null ? void 0 : X.subtotal) ?? 0) })
225
225
  ] }),
226
226
  s.pricing.discount && /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
227
227
  /* @__PURE__ */ e("span", { children: "Discount" }),
228
228
  /* @__PURE__ */ a("span", { className: "text-green-600", children: [
229
229
  "-",
230
- k(((E = (X = s == null ? void 0 : s.pricing) == null ? void 0 : X.discount) == null ? void 0 : E.amount) ?? 0)
230
+ k(((D = (E = s == null ? void 0 : s.pricing) == null ? void 0 : E.discount) == null ? void 0 : D.amount) ?? 0)
231
231
  ] })
232
232
  ] }),
233
233
  /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
234
234
  /* @__PURE__ */ e("span", { children: "Delivery Fee" }),
235
- /* @__PURE__ */ e("span", { children: k(((D = s == null ? void 0 : s.pricing) == null ? void 0 : D.deliveryCharge) ?? 0) })
235
+ /* @__PURE__ */ e("span", { children: k(((ee = s == null ? void 0 : s.pricing) == null ? void 0 : ee.deliveryCharge) ?? 0) })
236
236
  ] }),
237
237
  /* @__PURE__ */ e("hr", { className: "border-gray-200 my-2" }),
238
238
  /* @__PURE__ */ a("div", { className: "flex items-center justify-between font-medium", children: [
239
239
  /* @__PURE__ */ e("span", { children: "Total" }),
240
- /* @__PURE__ */ e("span", { children: k(((ee = s == null ? void 0 : s.pricing) == null ? void 0 : ee.total) ?? 0) })
240
+ /* @__PURE__ */ e("span", { children: k(((te = s == null ? void 0 : s.pricing) == null ? void 0 : te.total) ?? 0) })
241
241
  ] })
242
242
  ] }),
243
243
  /* @__PURE__ */ a("div", { className: "flex gap-3", children: [
@@ -246,11 +246,11 @@ function Xe({
246
246
  {
247
247
  type: "button",
248
248
  variant: "outline",
249
- onClick: oe,
249
+ onClick: me,
250
250
  className: "flex-1 border-gray-400",
251
251
  size: "lg",
252
252
  children: [
253
- /* @__PURE__ */ e(be, { className: "mr-2 h-4 w-4" }),
253
+ /* @__PURE__ */ e(xe, { className: "mr-2 h-4 w-4" }),
254
254
  "Back"
255
255
  ]
256
256
  }
@@ -259,33 +259,33 @@ function Xe({
259
259
  L,
260
260
  {
261
261
  type: "button",
262
- onClick: ce,
262
+ onClick: oe,
263
263
  className: "flex-1 bg-accent-500 text-white hover:bg-accent-600",
264
264
  size: "lg",
265
265
  children: [
266
266
  "Next",
267
- /* @__PURE__ */ e(xe, { className: "ml-2 h-4 w-4" })
267
+ /* @__PURE__ */ e(we, { className: "ml-2 h-4 w-4" })
268
268
  ]
269
269
  }
270
270
  ) : /* @__PURE__ */ e(
271
271
  L,
272
272
  {
273
273
  type: "button",
274
- onClick: me,
274
+ onClick: ue,
275
275
  disabled: C.isPending,
276
276
  className: "flex-1 bg-accent-500 text-white hover:bg-accent-600",
277
277
  size: "lg",
278
- children: C.isPending ? /* @__PURE__ */ a(fe, { children: [
278
+ children: C.isPending ? /* @__PURE__ */ a(pe, { children: [
279
279
  /* @__PURE__ */ e(R, { className: "mr-2 h-4 w-4 animate-spin" }),
280
280
  "Processing..."
281
- ] }) : se
281
+ ] }) : ne
282
282
  }
283
283
  )
284
284
  ] }),
285
285
  C.isError && /* @__PURE__ */ e("div", { className: "rounded-lg bg-red-50 p-3 text-sm text-red-600", children: "Failed to place order. Please check your information and try again." })
286
286
  ] }), F = (t) => !(s != null && s.availablePaymentMethods.includes(t));
287
287
  return u ? /* @__PURE__ */ e(
288
- re,
288
+ ae,
289
289
  {
290
290
  isOpen: d,
291
291
  onClose: M,
@@ -302,14 +302,14 @@ function Xe({
302
302
  size: "lg",
303
303
  contentClassName: "p-6",
304
304
  children: /* @__PURE__ */ a("div", { className: "text-center space-y-6", children: [
305
- /* @__PURE__ */ e("div", { className: "flex justify-center", children: /* @__PURE__ */ e("div", { className: "w-20 h-20 bg-green-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ e(we, { className: "h-12 w-12 text-green-600" }) }) }),
305
+ /* @__PURE__ */ e("div", { className: "flex justify-center", children: /* @__PURE__ */ e("div", { className: "w-20 h-20 bg-green-100 rounded-full flex items-center justify-center", children: /* @__PURE__ */ e(Ce, { className: "h-12 w-12 text-green-600" }) }) }),
306
306
  /* @__PURE__ */ a("div", { className: "space-y-2", children: [
307
307
  /* @__PURE__ */ e("h3", { className: "text-2xl font-bold text-gray-900", children: "Thank You!" }),
308
308
  /* @__PURE__ */ e("p", { className: "text-gray-600", children: "Your order has been placed successfully." })
309
309
  ] }),
310
310
  /* @__PURE__ */ a("div", { className: "bg-gray-50 rounded-lg p-6 space-y-4", children: [
311
311
  /* @__PURE__ */ a("div", { className: "flex items-center justify-center space-x-2 text-gray-700", children: [
312
- /* @__PURE__ */ e(Ce, { className: "h-5 w-5" }),
312
+ /* @__PURE__ */ e(Pe, { className: "h-5 w-5" }),
313
313
  /* @__PURE__ */ a("span", { className: "font-medium", children: [
314
314
  "Order #",
315
315
  u.orderNumber
@@ -350,12 +350,12 @@ function Xe({
350
350
  ] })
351
351
  }
352
352
  ) : /* @__PURE__ */ e(
353
- re,
353
+ ae,
354
354
  {
355
355
  isOpen: d,
356
356
  onClose: M,
357
- title: he,
358
- footer: ye,
357
+ title: ye,
358
+ footer: fe,
359
359
  size: "lg",
360
360
  contentClassName: "p-0",
361
361
  children: O ? /* @__PURE__ */ e("div", { className: "flex items-center justify-center min-h-[300px]", children: /* @__PURE__ */ e(R, { className: "h-8 w-8 animate-spin text-gray-600" }) }) : /* @__PURE__ */ e("div", { className: "w-full overflow-hidden", children: /* @__PURE__ */ e("div", { className: "relative w-full", children: /* @__PURE__ */ a(
@@ -407,7 +407,7 @@ function Xe({
407
407
  onChange: v,
408
408
  onBlur: () => S("email"),
409
409
  error: m.email,
410
- icon: /* @__PURE__ */ e(Pe, { size: 16 }),
410
+ icon: /* @__PURE__ */ e(ke, { size: 16 }),
411
411
  autoCorrect: "off",
412
412
  required: !0
413
413
  }
@@ -424,7 +424,7 @@ function Xe({
424
424
  placeholder: "e.g. 08012345678",
425
425
  maxLength: 18,
426
426
  error: m.phone,
427
- icon: /* @__PURE__ */ e(ke, { size: 16 }),
427
+ icon: /* @__PURE__ */ e(Me, { size: 16 }),
428
428
  autoCorrect: "off",
429
429
  required: !0,
430
430
  className: "font-semibold"
@@ -460,7 +460,7 @@ function Xe({
460
460
  }
461
461
  ),
462
462
  /* @__PURE__ */ a(
463
- ae,
463
+ se,
464
464
  {
465
465
  label: "State",
466
466
  name: "state",
@@ -468,7 +468,7 @@ function Xe({
468
468
  onChange: (t) => {
469
469
  G("");
470
470
  const n = t.target.value;
471
- le(n || void 0), m.state && j((i) => ({ ...i, state: void 0 }));
471
+ de(n || void 0), m.state && j((i) => ({ ...i, state: void 0 }));
472
472
  },
473
473
  error: m.state,
474
474
  required: !0,
@@ -479,7 +479,7 @@ function Xe({
479
479
  }
480
480
  ),
481
481
  /* @__PURE__ */ a(
482
- ae,
482
+ se,
483
483
  {
484
484
  label: "Delivery Zone",
485
485
  value: g || "",
@@ -534,7 +534,7 @@ function Xe({
534
534
  "p-3 rounded-full",
535
535
  r.paymentMethod === "online" ? "bg-accent-100 text-accent-600" : "bg-gray-100 text-gray-600"
536
536
  ),
537
- children: /* @__PURE__ */ e(Me, { size: 24 })
537
+ children: /* @__PURE__ */ e(qe, { size: 24 })
538
538
  }
539
539
  ),
540
540
  /* @__PURE__ */ a("div", { children: [
@@ -543,7 +543,7 @@ function Xe({
543
543
  /* @__PURE__ */ e(
544
544
  "img",
545
545
  {
546
- src: Ze,
546
+ src: je,
547
547
  alt: "Paystack",
548
548
  className: "h-4 w-auto mt-2 mx-auto"
549
549
  }
@@ -583,7 +583,7 @@ function Xe({
583
583
  "p-3 rounded-full",
584
584
  r.paymentMethod === "cod" ? "bg-accent-100 text-accent-600" : "bg-gray-100 text-gray-600"
585
585
  ),
586
- children: /* @__PURE__ */ e(qe, { size: 24 })
586
+ children: /* @__PURE__ */ e(Ie, { size: 24 })
587
587
  }
588
588
  ),
589
589
  /* @__PURE__ */ a("div", { children: [
@@ -602,12 +602,12 @@ function Xe({
602
602
  "button",
603
603
  {
604
604
  type: "button",
605
- onClick: () => ie(!A),
605
+ onClick: () => ce(!A),
606
606
  className: "overflow-hidden w-full flex items-center overflow-hidden rounded-lg rounded-b-none justify-between p-4 text-left hover:bg-gray-50 transition-colors",
607
607
  children: [
608
608
  /* @__PURE__ */ e("span", { className: "text-sm font-medium text-gray-700", children: I.title || "🤔 Curious about Refunds?" }),
609
609
  /* @__PURE__ */ e(
610
- Ie,
610
+ Ze,
611
611
  {
612
612
  size: 16,
613
613
  className: w(
@@ -644,5 +644,5 @@ function Xe({
644
644
  );
645
645
  }
646
646
  export {
647
- Xe as Checkout
647
+ Ee as Checkout
648
648
  };
package/dist/index29.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useQueryClient as s, useMutation as i } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as o } from "./index61.mjs";
3
+ import { useQueryUnwrapped as o } from "./index59.mjs";
4
4
  import { queryKeys as r } from "./index26.mjs";
5
5
  import { updateCart as c, createCart as l, applyDiscount as y, removeDiscount as m, addCartItem as C, updateCartItem as p, removeCartItem as q, checkoutCart as d, fetchCart as f } from "./index23.mjs";
6
6
  function b(e, t) {
package/dist/index3.mjs CHANGED
@@ -1,145 +1,150 @@
1
1
  'use client';
2
- import { jsxs as Y, jsx as q } from "react/jsx-runtime";
3
- import { createContext as z, useState as d, useRef as w, useEffect as a, useCallback as r, useContext as B } from "react";
2
+ import { jsxs as z, jsx as B } from "react/jsx-runtime";
3
+ import { createContext as J, useState as w, useRef as C, useEffect as c, useCallback as r, useContext as Q } from "react";
4
4
  import "./index18.mjs";
5
- import { useGetCart as J, useCreateCart as Q, useAddCartItem as V, useUpdateCartItem as W, useRemoveCartItem as X, useApplyDiscount as Z, useRemoveDiscount as $, useUpdateCart as tt, useCheckoutCart as et } from "./index29.mjs";
5
+ import { useGetCart as V, useCreateCart as W, useAddCartItem as X, useUpdateCartItem as Z, useRemoveCartItem as $, useApplyDiscount as b, useRemoveDiscount as tt, useUpdateCart as et, useCheckoutCart as rt } from "./index29.mjs";
6
6
  import "@tanstack/react-query";
7
- import { ShoppingCart as rt } from "./index8.mjs";
8
- const m = "oms_cart_id", D = z(null);
9
- function it({ children: c, brandSlug: f, initialCartId: u, shoppingCartProps: E }) {
10
- const [t, s] = d(u || null), [p, C] = d(!1), [M, g] = d(!1), I = w(!1), h = w(!1), l = w(!1);
11
- a(() => {
7
+ import { ShoppingCart as ot } from "./index8.mjs";
8
+ const u = "oms_cart_id", A = J(null);
9
+ function mt({ children: i, brandSlug: s, initialCartId: m, shoppingCartProps: E }) {
10
+ const [t, a] = w(m || null), [p, I] = w(!1), [M, g] = w(!1), y = C(!1), h = C(!1), l = C(!1);
11
+ c(() => {
12
12
  g(!0);
13
- }, []), a(() => {
14
- if (u || I.current) return;
15
- I.current = !0;
13
+ }, []), c(() => {
14
+ if (m || y.current) return;
15
+ y.current = !0;
16
16
  const n = new URLSearchParams(window.location.search).get("cartId");
17
17
  if (n) {
18
- s(n);
18
+ a(n);
19
19
  return;
20
20
  }
21
- const v = localStorage.getItem(m);
22
- v && s(v);
23
- }, [u]);
24
- const { data: A, isLoading: R, error: i, refetch: o } = J(t || "", {
21
+ const S = localStorage.getItem(u);
22
+ S && a(S);
23
+ }, [m]);
24
+ const { data: R, isLoading: x, error: f, refetch: o } = V(t || "", {
25
25
  enabled: !!t,
26
26
  retry: !1
27
27
  // Don't retry on failure - cart might be invalid/expired
28
- }), y = Q({
28
+ }), d = W({
29
29
  onSuccess: (e) => {
30
30
  if ("error" in e) {
31
31
  console.error("Failed to create cart:", e.error);
32
32
  return;
33
33
  }
34
- s(e.id);
34
+ a(e.id);
35
35
  },
36
36
  onError: (e) => {
37
37
  console.error("Failed to create cart:", e);
38
- }
38
+ },
39
+ retry: 10
39
40
  });
40
- a(() => {
41
+ c(() => {
41
42
  if (h.current) return;
42
43
  h.current = !0;
43
44
  const e = setTimeout(() => {
44
- !t && !u && y.mutate(f);
45
+ !(typeof window < "u" ? localStorage.getItem(u) : null) && !m && d.mutate(s);
45
46
  }, 150);
46
47
  return () => clearTimeout(e);
47
- }, []), a(() => {
48
- i && t && !l.current && (l.current = !0, console.warn("Cart fetch failed, creating new cart:", i), s(null), typeof window < "u" && localStorage.removeItem(m), setTimeout(() => {
49
- y.mutate(f), l.current = !1;
48
+ }, []), c(() => {
49
+ f && t && !l.current && (l.current = !0, console.warn("Cart fetch failed, creating new cart:", f), a(null), typeof window < "u" && localStorage.removeItem(u), setTimeout(() => {
50
+ d.mutate(s), l.current = !1;
50
51
  }, 100));
51
- }, [i, t, f]);
52
- const x = V(t || "", {
52
+ }, [f, t, s]);
53
+ const N = X(t || "", {
53
54
  onSuccess: () => o()
54
- }), P = W(t || "", {
55
+ }), P = Z(t || "", {
55
56
  onSuccess: () => o()
56
- }), N = X(t || "", {
57
+ }), F = $(t || "", {
57
58
  onSuccess: () => o()
58
- }), F = Z(t || "", {
59
- onSuccess: () => o()
60
- }), T = $(t || "", {
59
+ }), T = b(t || "", {
61
60
  onSuccess: () => o()
62
61
  }), U = tt(t || "", {
63
62
  onSuccess: () => o()
64
- }), _ = et(t || "");
65
- a(() => {
66
- t && typeof window < "u" && localStorage.setItem(m, t);
63
+ }), _ = et(t || "", {
64
+ onSuccess: () => o(),
65
+ retry: 3
66
+ }), k = rt(t || "");
67
+ c(() => {
68
+ t && typeof window < "u" && localStorage.setItem(u, t);
67
69
  }, [t]);
68
- const k = r(
70
+ const L = r(
69
71
  async (e, n) => {
70
72
  if (!t) throw new Error("No cart ID");
71
- await x.mutateAsync({ sku: e, quantity: n });
73
+ await N.mutateAsync({ sku: e, quantity: n });
72
74
  },
73
75
  // eslint-disable-next-line react-hooks/exhaustive-deps
74
76
  [t]
75
- ), L = r(
77
+ ), j = r(
76
78
  async (e, n) => {
77
79
  if (!t) throw new Error("No cart ID");
78
80
  await P.mutateAsync({ itemId: e, quantity: n });
79
81
  },
80
82
  // eslint-disable-next-line react-hooks/exhaustive-deps
81
83
  [t]
82
- ), j = r(
84
+ ), O = r(
83
85
  async (e) => {
84
86
  if (!t) throw new Error("No cart ID");
85
- await N.mutateAsync(e);
87
+ await F.mutateAsync(e);
86
88
  },
87
89
  // eslint-disable-next-line react-hooks/exhaustive-deps
88
90
  [t]
89
- ), O = r(
91
+ ), G = r(
90
92
  async (e) => {
91
93
  if (!t) throw new Error("No cart ID");
92
- await F.mutateAsync({ code: e });
94
+ await T.mutateAsync({ code: e });
93
95
  },
94
96
  // eslint-disable-next-line react-hooks/exhaustive-deps
95
97
  [t]
96
- ), b = r(async () => {
98
+ ), H = r(async () => {
97
99
  if (!t) throw new Error("No cart ID");
98
- await T.mutateAsync();
99
- }, [t]), G = r(() => {
100
- s(null), typeof window < "u" && localStorage.removeItem(m);
101
- }, []), H = r(() => {
102
- C(!0);
103
- }, []), S = r(() => {
104
- C(!1);
105
- }, []), K = {
106
- cart: A || null,
100
+ await U.mutateAsync();
101
+ }, [t]), v = r(() => {
102
+ a(null), typeof window < "u" && localStorage.removeItem(u);
103
+ }, []), K = r(() => {
104
+ v(), d.mutate(s);
105
+ }, [s]), Y = r(() => {
106
+ I(!0);
107
+ }, []), D = r(() => {
108
+ I(!1);
109
+ }, []), q = {
110
+ cart: R || null,
107
111
  cartId: t,
108
- isLoading: R,
109
- error: i,
110
- updateCartMutation: U,
111
- checkoutMutation: _,
112
- addItem: k,
113
- updateItem: L,
114
- removeItem: j,
115
- applyDiscount: O,
116
- removeDiscount: b,
117
- clearCart: G,
112
+ isLoading: x,
113
+ error: f,
114
+ updateCartMutation: _,
115
+ checkoutMutation: k,
116
+ addItem: L,
117
+ updateItem: j,
118
+ removeItem: O,
119
+ applyDiscount: G,
120
+ removeDiscount: H,
121
+ clearCart: v,
122
+ clearAndCreateNewCart: K,
118
123
  refetch: o,
119
124
  isOpen: p,
120
- open: H,
121
- close: S
125
+ open: Y,
126
+ close: D
122
127
  };
123
- return /* @__PURE__ */ Y(D.Provider, { value: K, children: [
124
- c,
125
- M && /* @__PURE__ */ q(
126
- rt,
128
+ return /* @__PURE__ */ z(A.Provider, { value: q, children: [
129
+ i,
130
+ M && /* @__PURE__ */ B(
131
+ ot,
127
132
  {
128
133
  isOpen: p,
129
- onClose: S,
134
+ onClose: D,
130
135
  ...E
131
136
  }
132
137
  )
133
138
  ] });
134
139
  }
135
- function mt() {
136
- const c = B(D);
137
- if (!c)
140
+ function ft() {
141
+ const i = Q(A);
142
+ if (!i)
138
143
  throw new Error("useCart must be used within CartProvider");
139
- return c;
144
+ return i;
140
145
  }
141
146
  export {
142
- D as CartContext,
143
- it as CartProvider,
144
- mt as useCart
147
+ A as CartContext,
148
+ mt as CartProvider,
149
+ ft as useCart
145
150
  };
package/dist/index30.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useMutation as t } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as u } from "./index61.mjs";
3
+ import { useQueryUnwrapped as u } from "./index59.mjs";
4
4
  import { queryKeys as n } from "./index26.mjs";
5
5
  import { confirmOrder as i, fetchOrder as m } from "./index24.mjs";
6
6
  function y(e, r, o) {
package/dist/index31.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { useQueryUnwrapped as u } from "./index61.mjs";
2
+ import { useQueryUnwrapped as u } from "./index59.mjs";
3
3
  import { queryKeys as t } from "./index26.mjs";
4
4
  import { fetchProductsByBrand as o, fetchProductBySlug as c } from "./index22.mjs";
5
5
  function n(r, e) {
package/dist/index32.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { useQueryUnwrapped as o } from "./index61.mjs";
2
+ import { useQueryUnwrapped as o } from "./index59.mjs";
3
3
  import { queryKeys as i } from "./index26.mjs";
4
4
  import { fetchDeliveryZones as t } from "./index25.mjs";
5
5
  function p(e, r) {
package/dist/index44.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useQueryClient as y, useMutation as m } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as p } from "./index61.mjs";
3
+ import { useQueryUnwrapped as p } from "./index59.mjs";
4
4
  import { createAdminRpcClients as d, authHeaders as c } from "./index21.mjs";
5
5
  import { queryKeys as i } from "./index26.mjs";
6
6
  import { useApiConfig as l } from "./index19.mjs";
package/dist/index45.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useQueryClient as y, useMutation as m } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as b } from "./index61.mjs";
3
+ import { useQueryUnwrapped as b } from "./index59.mjs";
4
4
  import { createAdminRpcClients as u, authHeaders as c } from "./index21.mjs";
5
5
  import { queryKeys as o } from "./index26.mjs";
6
6
  import { useApiConfig as d } from "./index19.mjs";
package/dist/index46.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useQueryClient as p, useMutation as y } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as m } from "./index61.mjs";
3
+ import { useQueryUnwrapped as m } from "./index59.mjs";
4
4
  import { createAdminRpcClients as a, authHeaders as c } from "./index21.mjs";
5
5
  import { queryKeys as i } from "./index26.mjs";
6
6
  import { useApiConfig as d } from "./index19.mjs";
package/dist/index47.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useQueryClient as y, useMutation as v } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as m } from "./index61.mjs";
3
+ import { useQueryUnwrapped as m } from "./index59.mjs";
4
4
  import { createAdminRpcClients as u, authHeaders as c } from "./index21.mjs";
5
5
  import { queryKeys as i } from "./index26.mjs";
6
6
  import { useApiConfig as d } from "./index19.mjs";
package/dist/index48.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useQueryClient as w, useMutation as y } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as d } from "./index61.mjs";
3
+ import { useQueryUnwrapped as d } from "./index59.mjs";
4
4
  import { createAdminRpcClients as i, authHeaders as c } from "./index21.mjs";
5
5
  import { queryKeys as u } from "./index26.mjs";
6
6
  import { useApiConfig as l } from "./index19.mjs";
package/dist/index49.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useQueryClient as d, useMutation as v } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as l } from "./index61.mjs";
3
+ import { useQueryUnwrapped as l } from "./index59.mjs";
4
4
  import { createAdminRpcClients as u, authHeaders as c } from "./index21.mjs";
5
5
  import { queryKeys as s } from "./index26.mjs";
6
6
  import { useApiConfig as y } from "./index19.mjs";
package/dist/index50.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { useQueryUnwrapped as i } from "./index61.mjs";
2
+ import { useQueryUnwrapped as i } from "./index59.mjs";
3
3
  import { createAdminRpcClients as n, authHeaders as u } from "./index21.mjs";
4
4
  import { queryKeys as m } from "./index26.mjs";
5
5
  import { useApiConfig as a } from "./index19.mjs";
package/dist/index51.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- import { useQueryUnwrapped as s } from "./index61.mjs";
2
+ import { useQueryUnwrapped as s } from "./index59.mjs";
3
3
  import { createAdminRpcClients as i, authHeaders as u } from "./index21.mjs";
4
4
  import { queryKeys as c } from "./index26.mjs";
5
5
  import { useApiConfig as d } from "./index19.mjs";
package/dist/index52.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useQueryClient as l, useMutation as y } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as c } from "./index61.mjs";
3
+ import { useQueryUnwrapped as c } from "./index59.mjs";
4
4
  import { createAdminRpcClients as s, authHeaders as o } from "./index21.mjs";
5
5
  import { queryKeys as i } from "./index26.mjs";
6
6
  import { useApiConfig as u } from "./index19.mjs";
package/dist/index53.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useQueryClient as l, useMutation as y } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as C } from "./index61.mjs";
3
+ import { useQueryUnwrapped as C } from "./index59.mjs";
4
4
  import { createAdminRpcClients as c, authHeaders as a } from "./index21.mjs";
5
5
  import { queryKeys as r } from "./index26.mjs";
6
6
  import { useApiConfig as d } from "./index19.mjs";
package/dist/index54.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
2
  import { useQueryClient as y, useMutation as v } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as m } from "./index61.mjs";
3
+ import { useQueryUnwrapped as m } from "./index59.mjs";
4
4
  import { createAdminRpcClients as u, authHeaders as l } from "./index21.mjs";
5
5
  import { queryKeys as o } from "./index26.mjs";
6
6
  import { useApiConfig as c } from "./index19.mjs";
package/dist/index58.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use client';
2
- import { getDefaultExportFromCjs as d } from "./index59.mjs";
3
- import { __module as v } from "./index60.mjs";
2
+ import { getDefaultExportFromCjs as d } from "./index60.mjs";
3
+ import { __module as v } from "./index61.mjs";
4
4
  v.exports = function(n) {
5
5
  return g(m(n), n);
6
6
  };
package/dist/index59.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
  'use client';
2
- function e(t) {
3
- return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
2
+ import { useQuery as e } from "@tanstack/react-query";
3
+ function n(r) {
4
+ return e(r);
4
5
  }
5
6
  export {
6
- e as getDefaultExportFromCjs
7
+ n as useQueryUnwrapped
7
8
  };
package/dist/index60.mjs CHANGED
@@ -1,5 +1,7 @@
1
1
  'use client';
2
- var o = { exports: {} };
2
+ function e(t) {
3
+ return t && t.__esModule && Object.prototype.hasOwnProperty.call(t, "default") ? t.default : t;
4
+ }
3
5
  export {
4
- o as __module
6
+ e as getDefaultExportFromCjs
5
7
  };
package/dist/index61.mjs CHANGED
@@ -1,8 +1,5 @@
1
1
  'use client';
2
- import { useQuery as e } from "@tanstack/react-query";
3
- function n(r) {
4
- return e(r);
5
- }
2
+ var o = { exports: {} };
6
3
  export {
7
- n as useQueryUnwrapped
4
+ o as __module
8
5
  };
@@ -1 +1 @@
1
- {"version":3,"file":"MockCartProvider.d.ts","sourceRoot":"","sources":["../../src/test-utils/MockCartProvider.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAyB,MAAM,OAAO,CAAC;AAGzD,OAAO,KAAK,EAAE,IAAI,EAAuB,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAiHpE,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,kDAAkD;IAClD,iBAAiB,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;IAClE,mEAAmE;IACnE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,IAAI,EAAE,YAAY,EAClB,SAAiB,EACjB,KAAY,EACZ,iBAAiB,EACjB,UAAiB,GAClB,EAAE,qBAAqB,2CA0RvB"}
1
+ {"version":3,"file":"MockCartProvider.d.ts","sourceRoot":"","sources":["../../src/test-utils/MockCartProvider.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,SAAS,EAAyB,MAAM,OAAO,CAAC;AAGzD,OAAO,KAAK,EAAE,IAAI,EAAuB,MAAM,iBAAiB,CAAC;AACjE,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,4BAA4B,CAAC;AAiHpE,UAAU,qBAAqB;IAC7B,QAAQ,EAAE,SAAS,CAAC;IACpB,IAAI,CAAC,EAAE,OAAO,CAAC,IAAI,CAAC,CAAC;IACrB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,KAAK,GAAG,IAAI,CAAC;IACrB,kDAAkD;IAClD,iBAAiB,CAAC,EAAE,IAAI,CAAC,iBAAiB,EAAE,QAAQ,GAAG,SAAS,CAAC,CAAC;IAClE,mEAAmE;IACnE,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB;AAED,wBAAgB,gBAAgB,CAAC,EAC/B,QAAQ,EACR,IAAI,EAAE,YAAY,EAClB,SAAiB,EACjB,KAAY,EACZ,iBAAiB,EACjB,UAAiB,GAClB,EAAE,qBAAqB,2CAkSvB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@instockng/storefront-ui",
3
- "version": "1.0.12",
3
+ "version": "1.0.14",
4
4
  "description": "Pre-built UI components for OMS e-commerce sites",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -66,8 +66,8 @@
66
66
  "tailwindcss": "^4.1.14",
67
67
  "typescript": "^5.3.3",
68
68
  "vite": "^5.4.20",
69
- "@oms/shared": "1.0.0",
70
- "@oms/api-client": "1.0.0"
69
+ "@oms/api-client": "1.0.0",
70
+ "@oms/shared": "1.0.0"
71
71
  },
72
72
  "scripts": {
73
73
  "type-check": "tsc --noEmit",
@@ -147,7 +147,7 @@ export function Checkout({
147
147
  const [completedOrder, setCompletedOrder] = useState<Order | null>(null);
148
148
 
149
149
  // Get cart from CartProvider context (required)
150
- const { refetch: refetchCart, isLoading: isLoadingCart, cart, updateCartMutation, checkoutMutation } = useCart();
150
+ const { refetch: refetchCart, isLoading: isLoadingCart, cart, updateCartMutation, checkoutMutation, clearAndCreateNewCart } = useCart();
151
151
 
152
152
  // Paystack payment integration
153
153
  const paystack = usePaystackPayment({
@@ -176,6 +176,10 @@ export function Checkout({
176
176
 
177
177
  // Store the completed order to show success view
178
178
  setCompletedOrder(order as Order);
179
+
180
+ // Clear the cart and create a new one for next purchase
181
+ clearAndCreateNewCart();
182
+
179
183
  onSuccess?.(order.id);
180
184
  } catch (error) {
181
185
  onError?.(error as Error);
@@ -431,6 +435,10 @@ export function Checkout({
431
435
 
432
436
  // Store the completed order to show success view
433
437
  setCompletedOrder(order as Order);
438
+
439
+ // Clear the cart and create a new one for next purchase
440
+ clearAndCreateNewCart();
441
+
434
442
  onSuccess?.(order.id);
435
443
  } catch (error) {
436
444
  onError?.(error as Error);
@@ -50,6 +50,8 @@ interface CartContextValue {
50
50
  removeDiscount: () => Promise<void>;
51
51
  /** Clear cart (removes from localStorage) */
52
52
  clearCart: () => void;
53
+ /** Clear cart and create a new one immediately */
54
+ clearAndCreateNewCart: () => void;
53
55
  /** Refresh cart data */
54
56
  refetch: () => void;
55
57
  /** Whether the cart modal is open */
@@ -135,6 +137,7 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
135
137
  onError: (error) => {
136
138
  console.error('Failed to create cart:', error);
137
139
  },
140
+ retry: 10,
138
141
  });
139
142
 
140
143
  // Auto-create cart ONLY on initial mount if no cartId in localStorage
@@ -147,8 +150,11 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
147
150
 
148
151
  // Defer cart creation to allow localStorage to load first
149
152
  const timeoutId = setTimeout(() => {
153
+ // Check localStorage directly (don't rely on state due to closure)
154
+ const storedCartId = typeof window !== 'undefined' ? localStorage.getItem(CART_ID_KEY) : null;
155
+
150
156
  // Only create if we still don't have a cartId after localStorage loaded
151
- if (!cartId && !initialCartId) {
157
+ if (!storedCartId && !initialCartId) {
152
158
  createCartMutation.mutate(brandSlug);
153
159
  }
154
160
  }, 150); // Delay to ensure localStorage effect has run
@@ -202,6 +208,7 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
202
208
 
203
209
  const updateCartMutation = useUpdateCart(cartId || '', {
204
210
  onSuccess: () => refetch(),
211
+ retry: 3
205
212
  });
206
213
 
207
214
  const checkoutMutation = useCheckoutCart(cartId || '');
@@ -262,6 +269,14 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
262
269
  }
263
270
  }, []);
264
271
 
272
+ const clearAndCreateNewCart = useCallback(() => {
273
+ clearCart();
274
+
275
+ // Create a new cart immediately
276
+ createCartMutation.mutate(brandSlug);
277
+ // eslint-disable-next-line react-hooks/exhaustive-deps
278
+ }, [brandSlug]);
279
+
265
280
  const open = useCallback(() => {
266
281
  setIsOpen(true);
267
282
  }, []);
@@ -283,6 +298,7 @@ export function CartProvider({ children, brandSlug, initialCartId, shoppingCartP
283
298
  applyDiscount,
284
299
  removeDiscount,
285
300
  clearCart,
301
+ clearAndCreateNewCart,
286
302
  refetch,
287
303
  isOpen,
288
304
  open,
@@ -400,6 +400,14 @@ export function MockCartProvider({
400
400
  }));
401
401
  },
402
402
 
403
+ clearAndCreateNewCart: () => {
404
+ console.log('Mock clearAndCreateNewCart');
405
+ setCart(prev => ({
406
+ ...prev,
407
+ items: [],
408
+ }));
409
+ },
410
+
403
411
  refetch: () => {
404
412
  console.log('Mock refetch');
405
413
  },