@instockng/storefront-ui 1.0.70 → 1.0.72

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 (180) hide show
  1. package/dist/contexts/CartContext.d.ts.map +1 -1
  2. package/dist/hooks/usePageTracking.d.ts +1 -1
  3. package/dist/hooks/usePageTracking.d.ts.map +1 -1
  4. package/dist/index.mjs +65 -63
  5. package/dist/index100.mjs +174 -28
  6. package/dist/index101.mjs +53 -2
  7. package/dist/index102.mjs +69 -2
  8. package/dist/index106.mjs +2 -2
  9. package/dist/index107.mjs +2 -2
  10. package/dist/index140.mjs +1 -1
  11. package/dist/index142.mjs +2 -21
  12. package/dist/index143.mjs +19 -54
  13. package/dist/index144.mjs +55 -28
  14. package/dist/index145.mjs +28 -6
  15. package/dist/index146.mjs +6 -51
  16. package/dist/index147.mjs +51 -5
  17. package/dist/index148.mjs +6 -12
  18. package/dist/index149.mjs +12 -7
  19. package/dist/index15.mjs +1 -1
  20. package/dist/index150.mjs +6 -27
  21. package/dist/index151.mjs +28 -2
  22. package/dist/index152.mjs +2 -70
  23. package/dist/index153.mjs +67 -164
  24. package/dist/index154.mjs +167 -2
  25. package/dist/index158.mjs +1 -1
  26. package/dist/index159.mjs +1 -1
  27. package/dist/index160.mjs +1 -1
  28. package/dist/index161.mjs +1 -1
  29. package/dist/index162.mjs +1 -1
  30. package/dist/index164.mjs +3 -3
  31. package/dist/index165.mjs +1 -1
  32. package/dist/index167.mjs +2 -2
  33. package/dist/index168.mjs +1 -1
  34. package/dist/index173.mjs +2 -2
  35. package/dist/index175.mjs +1 -1
  36. package/dist/index177.mjs +2 -2
  37. package/dist/index178.mjs +5 -5
  38. package/dist/index181.mjs +1 -1
  39. package/dist/index184.mjs +1 -1
  40. package/dist/index187.mjs +1 -1
  41. package/dist/index188.mjs +1 -1
  42. package/dist/index192.mjs +1 -1
  43. package/dist/index194.mjs +1 -1
  44. package/dist/index198.mjs +1 -1
  45. package/dist/index2.mjs +1 -1
  46. package/dist/index200.mjs +1 -1
  47. package/dist/index213.mjs +2 -13
  48. package/dist/index214.mjs +2 -7
  49. package/dist/index215.mjs +2 -31
  50. package/dist/index216.mjs +2 -11
  51. package/dist/index217.mjs +2 -4
  52. package/dist/index218.mjs +2 -4
  53. package/dist/index219.mjs +2 -12
  54. package/dist/index22.mjs +10 -6
  55. package/dist/index220.mjs +2 -5
  56. package/dist/index221.mjs +108 -33
  57. package/dist/index222.mjs +2 -31
  58. package/dist/index223.mjs +2 -28
  59. package/dist/index224.mjs +34 -58
  60. package/dist/index225.mjs +2 -2
  61. package/dist/index226.mjs +2 -2
  62. package/dist/index227.mjs +244 -2
  63. package/dist/index228.mjs +2 -2
  64. package/dist/index229.mjs +28 -103
  65. package/dist/index23.mjs +13 -14
  66. package/dist/index230.mjs +65 -2
  67. package/dist/index231.mjs +25 -2
  68. package/dist/index232.mjs +2 -2
  69. package/dist/index233.mjs +2 -2
  70. package/dist/index234.mjs +2 -2
  71. package/dist/index236.mjs +2 -37
  72. package/dist/index237.mjs +2 -2
  73. package/dist/index238.mjs +2 -244
  74. package/dist/index239.mjs +2 -2
  75. package/dist/index240.mjs +30 -32
  76. package/dist/index241.mjs +10 -64
  77. package/dist/index242.mjs +3 -24
  78. package/dist/index243.mjs +4 -2
  79. package/dist/index244.mjs +13 -2
  80. package/dist/index245.mjs +7 -2
  81. package/dist/index246.mjs +12 -2
  82. package/dist/index247.mjs +5 -2
  83. package/dist/index248.mjs +33 -2
  84. package/dist/index249.mjs +31 -2
  85. package/dist/index250.mjs +28 -2
  86. package/dist/index251.mjs +61 -2
  87. package/dist/index253.mjs +2 -2
  88. package/dist/index256.mjs +2 -3
  89. package/dist/index257.mjs +2 -2
  90. package/dist/index258.mjs +18 -2
  91. package/dist/index259.mjs +46 -16
  92. package/dist/index260.mjs +2 -13
  93. package/dist/index261.mjs +2 -6
  94. package/dist/index262.mjs +2 -30
  95. package/dist/index264.mjs +91 -2
  96. package/dist/index265.mjs +2 -2
  97. package/dist/index266.mjs +3 -2
  98. package/dist/index267.mjs +2 -2
  99. package/dist/index268.mjs +2 -91
  100. package/dist/index269.mjs +17 -2
  101. package/dist/index27.mjs +17 -17
  102. package/dist/index270.mjs +12 -17
  103. package/dist/index271.mjs +6 -47
  104. package/dist/index272.mjs +30 -2
  105. package/dist/index273.mjs +2 -2
  106. package/dist/index275.mjs +2 -2
  107. package/dist/index28.mjs +58 -47
  108. package/dist/index29.mjs +11 -11
  109. package/dist/index3.mjs +141 -123
  110. package/dist/index30.mjs +4 -4
  111. package/dist/index31.mjs +5 -5
  112. package/dist/index33.mjs +21 -20
  113. package/dist/index35.mjs +36 -29
  114. package/dist/index36.mjs +8 -25
  115. package/dist/index37.mjs +1 -1
  116. package/dist/index38.mjs +26 -9
  117. package/dist/index39.mjs +9 -9
  118. package/dist/index4.mjs +59 -46
  119. package/dist/index40.mjs +2 -2
  120. package/dist/index42.mjs +2 -2
  121. package/dist/index45.mjs +3 -3
  122. package/dist/index46.mjs +1 -1
  123. package/dist/index49.mjs +1 -1
  124. package/dist/index54.mjs +17 -17
  125. package/dist/index55.mjs +2 -2
  126. package/dist/index56.mjs +1 -1
  127. package/dist/index57.mjs +1 -1
  128. package/dist/index58.mjs +1 -1
  129. package/dist/index59.mjs +1 -1
  130. package/dist/index6.mjs +7 -7
  131. package/dist/index60.mjs +1 -1
  132. package/dist/index61.mjs +1 -1
  133. package/dist/index62.mjs +1 -1
  134. package/dist/index63.mjs +1 -1
  135. package/dist/index64.mjs +1 -1
  136. package/dist/index65.mjs +1 -1
  137. package/dist/index66.mjs +1 -1
  138. package/dist/index67.mjs +1 -1
  139. package/dist/index68.mjs +23 -4
  140. package/dist/index69.mjs +149 -19
  141. package/dist/index7.mjs +1 -1
  142. package/dist/index70.mjs +2 -24
  143. package/dist/index71.mjs +19 -149
  144. package/dist/index72.mjs +75 -2
  145. package/dist/index73.mjs +14 -74
  146. package/dist/index74.mjs +62 -14
  147. package/dist/index75.mjs +4 -62
  148. package/dist/index76.mjs +2 -34
  149. package/dist/index77.mjs +5 -42
  150. package/dist/index78.mjs +1129 -230
  151. package/dist/index79.mjs +19 -5
  152. package/dist/index80.mjs +48 -127
  153. package/dist/index81.mjs +32 -67
  154. package/dist/index82.mjs +2 -87
  155. package/dist/index83.mjs +2 -29
  156. package/dist/index84.mjs +34 -9
  157. package/dist/index85.mjs +39 -71
  158. package/dist/index86.mjs +234 -3
  159. package/dist/index87.mjs +6 -2
  160. package/dist/index88.mjs +128 -77
  161. package/dist/index89.mjs +67 -53
  162. package/dist/index90.mjs +86 -5
  163. package/dist/index91.mjs +28 -4
  164. package/dist/index92.mjs +7 -177
  165. package/dist/index93.mjs +72 -50
  166. package/dist/index94.mjs +4 -69
  167. package/dist/index95.mjs +2 -2
  168. package/dist/index96.mjs +82 -5
  169. package/dist/index97.mjs +53 -1133
  170. package/dist/index98.mjs +5 -19
  171. package/dist/index99.mjs +4 -54
  172. package/dist/lib/utils.d.ts +5 -0
  173. package/dist/lib/utils.d.ts.map +1 -1
  174. package/dist/providers/MetaPixelProvider.d.ts +3 -2
  175. package/dist/providers/MetaPixelProvider.d.ts.map +1 -1
  176. package/package.json +2 -2
  177. package/src/contexts/CartContext.tsx +50 -22
  178. package/src/hooks/usePageTracking.ts +3 -3
  179. package/src/lib/utils.ts +11 -0
  180. package/src/providers/MetaPixelProvider.tsx +20 -6
package/dist/index272.mjs CHANGED
@@ -1,5 +1,33 @@
1
1
  'use client';
2
- const e = {};
2
+ import r from "./index86.mjs";
3
+ import c from "./index150.mjs";
4
+ const p = c.hasStandardBrowserEnv ? (
5
+ // Standard browser envs support document.cookie
6
+ {
7
+ write(e, t, n, i, s, u) {
8
+ const o = [e + "=" + encodeURIComponent(t)];
9
+ r.isNumber(n) && o.push("expires=" + new Date(n).toGMTString()), r.isString(i) && o.push("path=" + i), r.isString(s) && o.push("domain=" + s), u === !0 && o.push("secure"), document.cookie = o.join("; ");
10
+ },
11
+ read(e) {
12
+ const t = document.cookie.match(new RegExp("(^|;\\s*)(" + e + ")=([^;]*)"));
13
+ return t ? decodeURIComponent(t[3]) : null;
14
+ },
15
+ remove(e) {
16
+ this.write(e, "", Date.now() - 864e5);
17
+ }
18
+ }
19
+ ) : (
20
+ // Non-standard browser env (web workers, react-native) lack needed support.
21
+ {
22
+ write() {
23
+ },
24
+ read() {
25
+ return null;
26
+ },
27
+ remove() {
28
+ }
29
+ }
30
+ );
3
31
  export {
4
- e as default
32
+ p as default
5
33
  };
package/dist/index273.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- var o = { exports: {} };
2
+ var e = {};
3
3
  export {
4
- o as __module
4
+ e as __exports
5
5
  };
package/dist/index275.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  'use client';
2
- var e = {};
2
+ var o = { exports: {} };
3
3
  export {
4
- e as __exports
4
+ o as __module
5
5
  };
package/dist/index28.mjs CHANGED
@@ -1,45 +1,45 @@
1
1
  'use client';
2
- import { createRpcClients as n } from "./index26.mjs";
3
- import { API_BASE_URL as o } from "./index23.mjs";
4
- async function p(e) {
5
- const s = await n(o).carts[":id"].$get({
6
- param: { id: e }
2
+ import { createRpcClients as o } from "./index26.mjs";
3
+ const r = "https://oms-api.instock.com.ng";
4
+ async function m(n) {
5
+ const s = await o(r).carts[":id"].$get({
6
+ param: { id: n }
7
7
  });
8
8
  if (!s.ok)
9
9
  throw new Error(`Failed to fetch cart: ${s.statusText}`);
10
10
  return s.json();
11
11
  }
12
- async function w(e) {
13
- const s = await n(o).carts.index.$post({
14
- json: { brandSlug: e }
12
+ async function p(n) {
13
+ const s = await o(r).carts.index.$post({
14
+ json: { brandSlug: n }
15
15
  });
16
16
  if (!s.ok)
17
17
  throw new Error(`Failed to create cart: ${s.statusText}`);
18
18
  return s.json();
19
19
  }
20
- async function f(e, r) {
21
- const t = await n(o).carts[":id"].$patch({
22
- param: { id: e },
20
+ async function w(n, e) {
21
+ const t = await o(r).carts[":id"].$patch({
22
+ param: { id: n },
23
23
  // @ts-expect-error - Hono RPC type inference issue
24
- json: r
24
+ json: e
25
25
  });
26
26
  if (!t.ok)
27
27
  throw new Error(`Failed to update cart: ${t.statusText}`);
28
28
  return t.json();
29
29
  }
30
- async function $(e, r, s, t, a, i, d) {
31
- const c = await n(o).carts[":id"].items.$post({
32
- param: { id: e },
30
+ async function f(n, e, s, t, a, c, d) {
31
+ const i = await o(r).carts[":id"].items.$post({
32
+ param: { id: n },
33
33
  // @ts-expect-error - Hono RPC type inference issue
34
- json: { sku: r, quantity: s, fbc: t, fbp: a, ttp: i, ttclid: d }
34
+ json: { sku: e, quantity: s, fbc: t, fbp: a, ttp: c, ttclid: d }
35
35
  });
36
- if (!c.ok)
37
- throw new Error(`Failed to add item to cart: ${c.statusText}`);
38
- return c.json();
36
+ if (!i.ok)
37
+ throw new Error(`Failed to add item to cart: ${i.statusText}`);
38
+ return i.json();
39
39
  }
40
- async function h(e, r, s) {
41
- const a = await n(o).carts[":id"].items[":itemId"].$patch({
42
- param: { id: e, itemId: r },
40
+ async function h(n, e, s) {
41
+ const a = await o(r).carts[":id"].items[":itemId"].$patch({
42
+ param: { id: n, itemId: e },
43
43
  // @ts-expect-error - Hono RPC type inference issue
44
44
  json: { quantity: s }
45
45
  });
@@ -47,61 +47,72 @@ async function h(e, r, s) {
47
47
  throw new Error(`Failed to update cart item: ${a.statusText}`);
48
48
  return a.json();
49
49
  }
50
- async function j(e, r) {
51
- const t = await n(o).carts[":id"].items[":itemId"].$delete({
52
- param: { id: e, itemId: r }
50
+ async function $(n, e) {
51
+ const t = await o(r).carts[":id"].items[":itemId"].$delete({
52
+ param: { id: n, itemId: e }
53
53
  });
54
54
  if (!t.ok)
55
55
  throw new Error(`Failed to remove cart item: ${t.statusText}`);
56
56
  return t.json();
57
57
  }
58
- async function y(e, r) {
59
- const t = await n(o).carts[":id"]["apply-discount"].$post({
60
- param: { id: e },
58
+ async function j(n, e) {
59
+ const t = await o(r).carts[":id"]["apply-discount"].$post({
60
+ param: { id: n },
61
61
  // @ts-expect-error - Hono RPC type inference issue
62
- json: { code: r }
62
+ json: { code: e }
63
63
  });
64
64
  if (!t.ok)
65
65
  throw new Error(`Failed to apply discount: ${t.statusText}`);
66
66
  return t.json();
67
67
  }
68
- async function k(e) {
69
- const s = await n(o).carts[":id"]["remove-discount"].$post({
70
- param: { id: e }
68
+ async function k(n) {
69
+ const s = await o(r).carts[":id"]["remove-discount"].$post({
70
+ param: { id: n }
71
71
  });
72
72
  if (!s.ok)
73
73
  throw new Error(`Failed to remove discount: ${s.statusText}`);
74
74
  return s.json();
75
75
  }
76
- async function x(e, r) {
77
- const t = await n(o).carts[":id"].checkout.$post({
78
- param: { id: e },
76
+ async function y(n, e) {
77
+ const t = await o(r).carts[":id"].checkout.$post({
78
+ param: { id: n },
79
79
  // @ts-expect-error - Hono RPC type inference issue
80
- json: r
80
+ json: e
81
81
  });
82
82
  if (!t.ok)
83
83
  throw new Error(`Failed to checkout cart: ${t.statusText}`);
84
84
  return t.json();
85
85
  }
86
- async function E(e, r) {
87
- const t = await n(o).carts[":id"].recommendations.$get({
88
- param: { id: e },
86
+ async function x(n, e) {
87
+ const t = await o(r).carts[":id"]["initiate-checkout"].$post({
88
+ param: { id: n },
89
+ // @ts-expect-error - Hono RPC type inference issue
90
+ json: e
91
+ });
92
+ if (!t.ok)
93
+ throw new Error(`Failed to initiate checkout intent: ${t.statusText}`);
94
+ return t.json();
95
+ }
96
+ async function E(n, e) {
97
+ const t = await o(r).carts[":id"].recommendations.$get({
98
+ param: { id: n },
89
99
  // @ts-ignore - Hono RPC type inference issue with query parameters
90
- query: { limit: r.toString() }
100
+ query: { limit: e.toString() }
91
101
  });
92
102
  if (!t.ok)
93
103
  throw new Error(`Failed to fetch cart recommendations: ${t.statusText}`);
94
104
  return t.json();
95
105
  }
96
106
  export {
97
- $ as addCartItem,
98
- y as applyDiscount,
99
- x as checkoutCart,
100
- w as createCart,
101
- p as fetchCart,
107
+ f as addCartItem,
108
+ j as applyDiscount,
109
+ y as checkoutCart,
110
+ p as createCart,
111
+ m as fetchCart,
102
112
  E as fetchCartRecommendations,
103
- j as removeCartItem,
113
+ x as initiateCheckout,
114
+ $ as removeCartItem,
104
115
  k as removeDiscount,
105
- f as updateCart,
116
+ w as updateCart,
106
117
  h as updateCartItem
107
118
  };
package/dist/index29.mjs CHANGED
@@ -1,34 +1,34 @@
1
1
  'use client';
2
2
  import { createRpcClients as s } from "./index26.mjs";
3
- import { API_BASE_URL as i } from "./index23.mjs";
4
- async function d(r, e) {
3
+ const i = "https://oms-api.instock.com.ng";
4
+ async function a(r, o) {
5
5
  const t = await s(i).orders[":id"][":token"].$get({
6
- param: { id: r, token: e }
6
+ param: { id: r, token: o }
7
7
  });
8
8
  if (!t.ok)
9
9
  throw new Error(`Failed to fetch order: ${t.statusText}`);
10
10
  return t.json();
11
11
  }
12
- async function m(r, e) {
12
+ async function d(r, o) {
13
13
  const t = await s(i).orders.confirm.$post({
14
- json: { orderId: r, token: e }
14
+ json: { orderId: r, token: o }
15
15
  });
16
16
  if (!t.ok)
17
17
  throw new Error(`Failed to confirm order: ${t.statusText}`);
18
18
  return t.json();
19
19
  }
20
- async function f(r, e, o = 4) {
20
+ async function m(r, o, e = 4) {
21
21
  const n = await s(i).orders[":id"][":token"].recommendations.$get({
22
- param: { id: r, token: e },
22
+ param: { id: r, token: o },
23
23
  // @ts-ignore - Hono RPC type inference issue with query parameters
24
- query: { limit: String(o) }
24
+ query: { limit: String(e) }
25
25
  });
26
26
  if (!n.ok)
27
27
  throw new Error(`Failed to fetch order recommendations: ${n.statusText}`);
28
28
  return n.json();
29
29
  }
30
30
  export {
31
- m as confirmOrder,
32
- d as fetchOrder,
33
- f as fetchOrderRecommendations
31
+ d as confirmOrder,
32
+ a as fetchOrder,
33
+ m as fetchOrderRecommendations
34
34
  };
package/dist/index3.mjs CHANGED
@@ -1,35 +1,35 @@
1
1
  'use client';
2
- import { jsxs as it, jsx as ut } from "react/jsx-runtime";
3
- import { createContext as mt, useState as _, useRef as g, useEffect as d, useCallback as n, useContext as dt } from "react";
2
+ import { jsxs as dt, jsx as ft } from "react/jsx-runtime";
3
+ import { createContext as lt, useState as x, useRef as P, useEffect as f, useCallback as a, useContext as Ct } from "react";
4
4
  import "./index23.mjs";
5
- import { queryKeys as ft } from "./index32.mjs";
6
- import { useGetCart as lt, useCreateCart as Ct, useAddCartItem as It, useUpdateCartItem as wt, useRemoveCartItem as pt, useApplyDiscount as kt, useRemoveDiscount as yt, useUpdateCart as ht, useCheckoutCart as vt } from "./index35.mjs";
7
- import { useQueryClient as Tt } from "@tanstack/react-query";
8
- import { ShoppingCart as At } from "./index13.mjs";
9
- import { useMetaPixel as Dt } from "./index4.mjs";
10
- import { useTikTokPixel as Mt } from "./index5.mjs";
11
- import { getFbCookies as Et, getTikTokCookies as St } from "./index22.mjs";
12
- const f = "oms_cart_id", j = mt(null);
13
- function Lt({ children: l, brandSlug: u, initialCartId: C, shoppingCartProps: q }) {
14
- const [t, m] = _(C || null), [I, T] = _(!1), [O, Q] = _(!1), x = g(!1), R = g(!1), A = g(!1), G = Tt(), { trackAddToCart: D, trackInitiateCheckout: P } = Dt(), { trackAddToCart: M, trackInitiateCheckout: b } = Mt();
15
- d(() => {
16
- Q(!0);
17
- }, []), d(() => {
18
- if (C || x.current) return;
19
- x.current = !0;
20
- const r = new URLSearchParams(window.location.search).get("cartId");
21
- if (r) {
22
- m(r), T(!0);
5
+ import { queryKeys as pt } from "./index32.mjs";
6
+ import { useGetCart as It, useCreateCart as kt, useAddCartItem as wt, useUpdateCartItem as ht, useRemoveCartItem as yt, useApplyDiscount as vt, useRemoveDiscount as Tt, useUpdateCart as gt, useCheckoutCart as At, useInitiateCheckout as Dt } from "./index35.mjs";
7
+ import { useQueryClient as Mt } from "@tanstack/react-query";
8
+ import { ShoppingCart as Et } from "./index13.mjs";
9
+ import { useMetaPixel as St } from "./index4.mjs";
10
+ import { useTikTokPixel as xt } from "./index5.mjs";
11
+ import { getFbCookies as j, getTikTokCookies as O, generateClientEventId as Pt } from "./index22.mjs";
12
+ const l = "oms_cart_id", Q = lt(null);
13
+ function Ot({ children: C, brandSlug: u, initialCartId: p, shoppingCartProps: $ }) {
14
+ const [t, m] = x(p || null), [I, y] = x(!1), [G, H] = x(!1), _ = P(!1), R = P(!1), v = P(!1), Y = Mt(), { trackAddToCart: T, trackInitiateCheckout: g } = St(), { trackAddToCart: A, trackInitiateCheckout: D } = xt();
15
+ f(() => {
16
+ H(!0);
17
+ }, []), f(() => {
18
+ if (p || _.current) return;
19
+ _.current = !0;
20
+ const o = new URLSearchParams(window.location.search).get("cartId");
21
+ if (o) {
22
+ m(o), y(!0);
23
23
  return;
24
24
  }
25
- const o = localStorage.getItem(f);
26
- o && m(o);
27
- }, [C]);
28
- const { data: i, isLoading: H, error: w, refetch: c } = lt(t || "", {
25
+ const c = localStorage.getItem(l);
26
+ c && m(c);
27
+ }, [p]);
28
+ const { data: n, isLoading: z, error: k, refetch: s } = It(t || "", {
29
29
  enabled: !!t,
30
30
  retry: !1
31
31
  // Don't retry on failure - cart might be invalid/expired
32
- }), E = Ct({
32
+ }), M = kt({
33
33
  onSuccess: (e) => {
34
34
  if ("error" in e) {
35
35
  console.error("Failed to create cart:", e.error);
@@ -42,149 +42,167 @@ function Lt({ children: l, brandSlug: u, initialCartId: C, shoppingCartProps: q
42
42
  },
43
43
  retry: 10
44
44
  });
45
- d(() => {
45
+ f(() => {
46
46
  if (R.current) return;
47
47
  R.current = !0;
48
48
  const e = setTimeout(() => {
49
- !(typeof window < "u" ? localStorage.getItem(f) : null) && !C && E.mutate(u);
49
+ !(typeof window < "u" ? localStorage.getItem(l) : null) && !p && M.mutate(u);
50
50
  }, 150);
51
51
  return () => clearTimeout(e);
52
- }, []), d(() => {
53
- w && t && !A.current && (A.current = !0, console.warn("Cart fetch failed, creating new cart:", w), m(null), typeof window < "u" && localStorage.removeItem(f), setTimeout(() => {
54
- E.mutate(u), A.current = !1;
52
+ }, []), f(() => {
53
+ k && t && !v.current && (v.current = !0, console.warn("Cart fetch failed, creating new cart:", k), m(null), typeof window < "u" && localStorage.removeItem(l), setTimeout(() => {
54
+ M.mutate(u), v.current = !1;
55
55
  }, 100));
56
- }, [w, t, u]);
57
- const Y = It(t || "", {
58
- onSuccess: () => c()
59
- }), z = wt(t || "", {
60
- onSuccess: () => c()
61
- }), B = pt(t || "", {
56
+ }, [k, t, u]);
57
+ const B = wt(t || "", {
58
+ onSuccess: () => s()
59
+ }), J = ht(t || "", {
60
+ onSuccess: () => s()
61
+ }), V = yt(t || "", {
62
62
  onSuccess: () => {
63
- c(), t && G.invalidateQueries({ queryKey: ft.public.carts.recommendations(t) });
63
+ s(), t && Y.invalidateQueries({ queryKey: pt.public.carts.recommendations(t) });
64
64
  }
65
- }), J = kt(t || "", {
66
- onSuccess: () => c()
67
- }), V = yt(t || "", {
68
- onSuccess: () => c()
69
- }), W = ht(t || "", {
70
- onSuccess: () => c(),
65
+ }), W = vt(t || "", {
66
+ onSuccess: () => s()
67
+ }), X = Tt(t || "", {
68
+ onSuccess: () => s()
69
+ }), Z = gt(t || "", {
70
+ onSuccess: () => s(),
71
71
  retry: 3
72
- }), X = vt(t || "", {
72
+ }), tt = At(t || "", {
73
73
  onSuccess: () => {
74
74
  }
75
- });
76
- d(() => {
77
- t && typeof window < "u" && localStorage.setItem(f, t);
75
+ }), b = Dt(t || "");
76
+ f(() => {
77
+ t && typeof window < "u" && localStorage.setItem(l, t);
78
78
  }, [t]);
79
- const Z = n(
80
- async (e, r, o, p, a) => {
81
- var L;
79
+ const et = a(
80
+ async (e, o, c, i, r) => {
81
+ var K;
82
82
  if (!t) throw new Error("No cart ID");
83
- const { fbc: k, fbp: y } = Et(), { ttp: s, ttclid: S } = St(), U = await Y.mutateAsync({
84
- sku: p,
85
- quantity: a,
86
- fbc: k,
87
- fbp: y,
88
- ttp: s,
89
- ttclid: S,
83
+ const { fbc: d, fbp: E } = j(), { ttp: S, ttclid: mt } = O(), N = await B.mutateAsync({
84
+ sku: i,
85
+ quantity: r,
86
+ fbc: d,
87
+ fbp: E,
88
+ ttp: S,
89
+ ttclid: mt,
90
90
  refreshRecommendations: !I
91
91
  });
92
- if ("error" in U) return;
93
- const h = (L = U.items) == null ? void 0 : L.filter(
94
- (v) => {
95
- var $;
96
- return (($ = v.variant) == null ? void 0 : $.sku) === p;
92
+ if ("error" in N) return;
93
+ const w = (K = N.items) == null ? void 0 : K.filter(
94
+ (h) => {
95
+ var L;
96
+ return ((L = h.variant) == null ? void 0 : L.sku) === i;
97
97
  }
98
- ), K = h == null ? void 0 : h[h.length - 1];
99
- if (K) {
100
- const v = `cart_${t}_item_${K.id}`;
101
- D(e, r, o, a, v), M(e, r, o, a, v);
98
+ ), U = w == null ? void 0 : w[w.length - 1];
99
+ if (U) {
100
+ const h = `cart_${t}_item_${U.id}`;
101
+ T(i, o, c, r, h), A(e, o, c, r, h);
102
102
  } else
103
- D(e, r, o, a), M(e, r, o, a);
103
+ T(i, o, c, r), A(e, o, c, r);
104
104
  },
105
105
  // eslint-disable-next-line react-hooks/exhaustive-deps
106
- [t, I, D, M]
107
- ), tt = n(
108
- async (e, r) => {
106
+ [t, I, T, A]
107
+ ), rt = a(
108
+ async (e, o) => {
109
109
  if (!t) throw new Error("No cart ID");
110
- await z.mutateAsync({ itemId: e, quantity: r });
110
+ await J.mutateAsync({ itemId: e, quantity: o });
111
111
  },
112
112
  // eslint-disable-next-line react-hooks/exhaustive-deps
113
113
  [t]
114
- ), et = n(
114
+ ), ot = a(
115
115
  async (e) => {
116
116
  if (!t) throw new Error("No cart ID");
117
- await B.mutateAsync(e);
117
+ await V.mutateAsync(e);
118
118
  },
119
119
  // eslint-disable-next-line react-hooks/exhaustive-deps
120
120
  [t]
121
- ), rt = n(
121
+ ), nt = a(
122
122
  async (e) => {
123
123
  if (!t) throw new Error("No cart ID");
124
- await J.mutateAsync({ code: e });
124
+ await W.mutateAsync({ code: e });
125
125
  },
126
126
  // eslint-disable-next-line react-hooks/exhaustive-deps
127
127
  [t]
128
- ), ot = n(async () => {
128
+ ), ct = a(async () => {
129
129
  if (!t) throw new Error("No cart ID");
130
- await V.mutateAsync();
131
- }, [t]), F = n(() => {
132
- m(null), typeof window < "u" && localStorage.removeItem(f);
133
- }, []), nt = n(() => {
134
- F(), E.mutate(u);
135
- }, [u]), at = n(() => {
136
- T(!0);
137
- }, []), N = n(() => {
138
- T(!1);
139
- }, []), ct = n(() => {
140
- var a, k, y;
141
- if (!i || !t) return;
142
- const e = Number(((a = i.pricing) == null ? void 0 : a.total) || 0), r = ((k = i.items) == null ? void 0 : k.reduce((s, S) => s + S.quantity, 0)) || 0, o = `cart_${t}_checkout`, p = ((y = i.items) == null ? void 0 : y.map((s) => ({
143
- content_id: s.variant.sku,
144
- quantity: s.quantity,
145
- price: Number(s.variant.price)
146
- }))) || [];
147
- P(e, r, o), b(e, r, o, p);
148
- }, [i, t, P, b]), st = {
149
- cart: i || null,
130
+ await X.mutateAsync();
131
+ }, [t]), F = a(() => {
132
+ m(null), typeof window < "u" && localStorage.removeItem(l);
133
+ }, []), at = a(() => {
134
+ F(), M.mutate(u);
135
+ }, [u]), st = a(() => {
136
+ y(!0);
137
+ }, []), q = a(() => {
138
+ y(!1);
139
+ }, []), it = a(async () => {
140
+ if (!(!n || !n.pricing))
141
+ try {
142
+ const e = Pt("cart", n.id, "checkout"), o = n.pricing.total, c = n.items.reduce((r, d) => r + d.quantity, 0), i = n.items.map((r) => ({
143
+ id: r.variant.sku,
144
+ quantity: r.quantity,
145
+ item_price: Number(r.variant.price)
146
+ }));
147
+ if (g && g(o, c, i, e), n.brand.metaPixelId || n.brand.tiktokPixelId) {
148
+ const { fbc: r, fbp: d } = j(), { ttp: E, ttclid: S } = O();
149
+ b.mutate({
150
+ email: n.customerEmail,
151
+ phone: n.customerPhone,
152
+ fbc: r,
153
+ fbp: d,
154
+ ttp: E,
155
+ ttclid: S
156
+ });
157
+ }
158
+ D && D(o, c, e, i.map((r) => ({
159
+ content_id: r.id,
160
+ quantity: r.quantity,
161
+ price: r.item_price
162
+ })));
163
+ } catch (e) {
164
+ console.error("Error tracking initiate checkout:", e);
165
+ }
166
+ }, [n, g, D, b]), ut = {
167
+ cart: n || null,
150
168
  cartId: t,
151
- isLoading: H,
152
- error: w,
153
- updateCartMutation: W,
154
- checkoutMutation: X,
155
- addItem: Z,
156
- updateItem: tt,
157
- removeItem: et,
158
- applyDiscount: rt,
159
- removeDiscount: ot,
160
- trackCheckoutInitiated: ct,
169
+ isLoading: z,
170
+ error: k,
171
+ updateCartMutation: Z,
172
+ checkoutMutation: tt,
173
+ addItem: et,
174
+ updateItem: rt,
175
+ removeItem: ot,
176
+ applyDiscount: nt,
177
+ removeDiscount: ct,
178
+ trackCheckoutInitiated: it,
161
179
  clearCart: F,
162
- clearAndCreateNewCart: nt,
163
- refetch: c,
180
+ clearAndCreateNewCart: at,
181
+ refetch: s,
164
182
  isOpen: I,
165
- open: at,
166
- close: N
183
+ open: st,
184
+ close: q
167
185
  };
168
- return /* @__PURE__ */ it(j.Provider, { value: st, children: [
169
- l,
170
- O && /* @__PURE__ */ ut(
171
- At,
186
+ return /* @__PURE__ */ dt(Q.Provider, { value: ut, children: [
187
+ C,
188
+ G && /* @__PURE__ */ ft(
189
+ Et,
172
190
  {
173
191
  isOpen: I,
174
- onClose: N,
175
- ...q
192
+ onClose: q,
193
+ ...$
176
194
  }
177
195
  )
178
196
  ] });
179
197
  }
180
- function $t() {
181
- const l = dt(j);
182
- if (!l)
198
+ function Qt() {
199
+ const C = Ct(Q);
200
+ if (!C)
183
201
  throw new Error("useCart must be used within CartProvider");
184
- return l;
202
+ return C;
185
203
  }
186
204
  export {
187
- j as CartContext,
188
- Lt as CartProvider,
189
- $t as useCart
205
+ Q as CartContext,
206
+ Ot as CartProvider,
207
+ Qt as useCart
190
208
  };
package/dist/index30.mjs CHANGED
@@ -1,8 +1,8 @@
1
1
  'use client';
2
2
  import { createRpcClients as o } from "./index26.mjs";
3
- import { API_BASE_URL as r } from "./index23.mjs";
4
- async function c(t) {
5
- const e = await o(r).deliveryZones.index.$get({
3
+ const n = "https://oms-api.instock.com.ng";
4
+ async function r(t) {
5
+ const e = await o(n).deliveryZones.index.$get({
6
6
  query: t ? { brandId: t } : {}
7
7
  });
8
8
  if (!e.ok)
@@ -10,5 +10,5 @@ async function c(t) {
10
10
  return e.json();
11
11
  }
12
12
  export {
13
- c as fetchDeliveryZones
13
+ r as fetchDeliveryZones
14
14
  };
package/dist/index31.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  'use client';
2
- import { createRpcClients as e } from "./index26.mjs";
3
- import { API_BASE_URL as n } from "./index23.mjs";
4
- async function c(r) {
5
- const t = await e(n).brands[":slug"].$get({
6
- param: { slug: r }
2
+ import { createRpcClients as s } from "./index26.mjs";
3
+ const o = "https://oms-api.instock.com.ng";
4
+ async function c(n) {
5
+ const t = await s(o).brands[":slug"].$get({
6
+ param: { slug: n }
7
7
  });
8
8
  if (!t.ok)
9
9
  throw new Error(`Failed to fetch brand: ${t.statusText}`);