@instockng/storefront-ui 1.0.75 → 1.0.77

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 (255) hide show
  1. package/dist/components/ProductAddOns.d.ts +3 -1
  2. package/dist/components/ProductAddOns.d.ts.map +1 -1
  3. package/dist/components/RecommendedProducts.d.ts.map +1 -1
  4. package/dist/components/VariantPickerModal.d.ts +28 -0
  5. package/dist/components/VariantPickerModal.d.ts.map +1 -0
  6. package/dist/contexts/CartContext.d.ts.map +1 -1
  7. package/dist/index.d.ts +2 -0
  8. package/dist/index.d.ts.map +1 -1
  9. package/dist/index.mjs +104 -102
  10. package/dist/index10.mjs +162 -121
  11. package/dist/index100.mjs +20 -69
  12. package/dist/index101.mjs +55 -34
  13. package/dist/index102.mjs +32 -42
  14. package/dist/index103.mjs +2 -2
  15. package/dist/index104.mjs +2 -28
  16. package/dist/index105.mjs +2 -18
  17. package/dist/index106.mjs +26 -213
  18. package/dist/index107.mjs +13 -175
  19. package/dist/index108.mjs +210 -17
  20. package/dist/index109.mjs +174 -17
  21. package/dist/index11.mjs +116 -88
  22. package/dist/index110.mjs +14 -25
  23. package/dist/index111.mjs +17 -150
  24. package/dist/index112.mjs +26 -13
  25. package/dist/index113.mjs +149 -24
  26. package/dist/index114.mjs +13 -77
  27. package/dist/index115.mjs +20 -27
  28. package/dist/index116.mjs +76 -137
  29. package/dist/index117.mjs +33 -50
  30. package/dist/index118.mjs +141 -19
  31. package/dist/index119.mjs +50 -22
  32. package/dist/index12.mjs +86 -90
  33. package/dist/index120.mjs +14 -14
  34. package/dist/index121.mjs +20 -18
  35. package/dist/index122.mjs +16 -14
  36. package/dist/index123.mjs +17 -14
  37. package/dist/index124.mjs +12 -12
  38. package/dist/index125.mjs +15 -58
  39. package/dist/index126.mjs +14 -11
  40. package/dist/index127.mjs +56 -30
  41. package/dist/index128.mjs +9 -15
  42. package/dist/index129.mjs +31 -26
  43. package/dist/index13.mjs +83 -185
  44. package/dist/index130.mjs +13 -16
  45. package/dist/index131.mjs +26 -11
  46. package/dist/index132.mjs +18 -12
  47. package/dist/index133.mjs +12 -40
  48. package/dist/index134.mjs +14 -16
  49. package/dist/index135.mjs +42 -263
  50. package/dist/index136.mjs +15 -62
  51. package/dist/index137.mjs +267 -7
  52. package/dist/index138.mjs +70 -2
  53. package/dist/index139.mjs +8 -2
  54. package/dist/index14.mjs +196 -94
  55. package/dist/index140.mjs +2 -33
  56. package/dist/index141.mjs +2 -2
  57. package/dist/index142.mjs +33 -2
  58. package/dist/index143.mjs +2 -21
  59. package/dist/index144.mjs +19 -54
  60. package/dist/index145.mjs +55 -28
  61. package/dist/index146.mjs +27 -5
  62. package/dist/index147.mjs +6 -51
  63. package/dist/index148.mjs +51 -5
  64. package/dist/index149.mjs +6 -12
  65. package/dist/index15.mjs +82 -713
  66. package/dist/index150.mjs +12 -7
  67. package/dist/index151.mjs +6 -27
  68. package/dist/index152.mjs +28 -2
  69. package/dist/index153.mjs +2 -70
  70. package/dist/index154.mjs +67 -164
  71. package/dist/index155.mjs +167 -2
  72. package/dist/index159.mjs +1 -1
  73. package/dist/index16.mjs +722 -53
  74. package/dist/index160.mjs +1 -1
  75. package/dist/index161.mjs +1 -1
  76. package/dist/index162.mjs +1 -1
  77. package/dist/index163.mjs +1 -1
  78. package/dist/index165.mjs +3 -3
  79. package/dist/index166.mjs +1 -1
  80. package/dist/index168.mjs +3 -3
  81. package/dist/index169.mjs +1 -1
  82. package/dist/index17.mjs +58 -60
  83. package/dist/index174.mjs +2 -2
  84. package/dist/index176.mjs +1 -1
  85. package/dist/index178.mjs +2 -2
  86. package/dist/index179.mjs +5 -5
  87. package/dist/index18.mjs +60 -22
  88. package/dist/index182.mjs +1 -1
  89. package/dist/index185.mjs +1 -1
  90. package/dist/index188.mjs +3 -3
  91. package/dist/index189.mjs +1 -1
  92. package/dist/index19.mjs +22 -107
  93. package/dist/index193.mjs +2 -2
  94. package/dist/index195.mjs +2 -2
  95. package/dist/index199.mjs +1 -1
  96. package/dist/index2.mjs +2 -2
  97. package/dist/index20.mjs +105 -38
  98. package/dist/index201.mjs +1 -1
  99. package/dist/index21.mjs +37 -37
  100. package/dist/index210.mjs +2 -2
  101. package/dist/index212.mjs +1 -1
  102. package/dist/index213.mjs +1 -1
  103. package/dist/index214.mjs +2 -31
  104. package/dist/index215.mjs +30 -10
  105. package/dist/index216.mjs +10 -3
  106. package/dist/index217.mjs +3 -3
  107. package/dist/index218.mjs +4 -13
  108. package/dist/index219.mjs +13 -7
  109. package/dist/index22.mjs +42 -71
  110. package/dist/index220.mjs +7 -12
  111. package/dist/index221.mjs +11 -4
  112. package/dist/index222.mjs +5 -33
  113. package/dist/index223.mjs +33 -31
  114. package/dist/index224.mjs +29 -26
  115. package/dist/index225.mjs +26 -59
  116. package/dist/index226.mjs +61 -2
  117. package/dist/index227.mjs +2 -108
  118. package/dist/index228.mjs +2 -2
  119. package/dist/index229.mjs +2 -2
  120. package/dist/index23.mjs +67 -28
  121. package/dist/index230.mjs +2 -37
  122. package/dist/index231.mjs +108 -2
  123. package/dist/index232.mjs +2 -2
  124. package/dist/index233.mjs +2 -2
  125. package/dist/index234.mjs +2 -2
  126. package/dist/index236.mjs +2 -2
  127. package/dist/index237.mjs +2 -244
  128. package/dist/index238.mjs +37 -2
  129. package/dist/index239.mjs +2 -33
  130. package/dist/index24.mjs +29 -6
  131. package/dist/index240.mjs +2 -65
  132. package/dist/index241.mjs +243 -24
  133. package/dist/index242.mjs +2 -2
  134. package/dist/index243.mjs +33 -2
  135. package/dist/index244.mjs +65 -2
  136. package/dist/index245.mjs +25 -2
  137. package/dist/index246.mjs +2 -2
  138. package/dist/index247.mjs +2 -2
  139. package/dist/index248.mjs +2 -2
  140. package/dist/index249.mjs +2 -2
  141. package/dist/index25.mjs +8 -21
  142. package/dist/index250.mjs +2 -2
  143. package/dist/index251.mjs +2 -2
  144. package/dist/index253.mjs +2 -2
  145. package/dist/index254.mjs +2 -2
  146. package/dist/index255.mjs +4 -2
  147. package/dist/index256.mjs +2 -4
  148. package/dist/index258.mjs +3 -2
  149. package/dist/index259.mjs +2 -18
  150. package/dist/index26.mjs +19 -34
  151. package/dist/index260.mjs +2 -47
  152. package/dist/index261.mjs +17 -2
  153. package/dist/index262.mjs +13 -2
  154. package/dist/index263.mjs +6 -2
  155. package/dist/index264.mjs +30 -2
  156. package/dist/index265.mjs +2 -91
  157. package/dist/index266.mjs +2 -3
  158. package/dist/index267.mjs +18 -2
  159. package/dist/index268.mjs +47 -2
  160. package/dist/index269.mjs +2 -17
  161. package/dist/index27.mjs +34 -37
  162. package/dist/index270.mjs +2 -13
  163. package/dist/index271.mjs +2 -6
  164. package/dist/index272.mjs +2 -30
  165. package/dist/index273.mjs +91 -2
  166. package/dist/index274.mjs +2 -2
  167. package/dist/index276.mjs +2 -2
  168. package/dist/index277.mjs +5 -0
  169. package/dist/index28.mjs +28 -103
  170. package/dist/index29.mjs +104 -20
  171. package/dist/index3.mjs +90 -90
  172. package/dist/index30.mjs +29 -9
  173. package/dist/index31.mjs +9 -9
  174. package/dist/index32.mjs +11 -116
  175. package/dist/index33.mjs +116 -25
  176. package/dist/index34.mjs +25 -81
  177. package/dist/index35.mjs +81 -112
  178. package/dist/index36.mjs +109 -8
  179. package/dist/index37.mjs +9 -33
  180. package/dist/index38.mjs +27 -20
  181. package/dist/index39.mjs +26 -9
  182. package/dist/index4.mjs +1 -1
  183. package/dist/index40.mjs +10 -122
  184. package/dist/index41.mjs +114 -380
  185. package/dist/index42.mjs +384 -20
  186. package/dist/index43.mjs +24 -31
  187. package/dist/index44.mjs +32 -7
  188. package/dist/index45.mjs +6 -1432
  189. package/dist/index46.mjs +1432 -69
  190. package/dist/index47.mjs +70 -2
  191. package/dist/index48.mjs +2 -60
  192. package/dist/index49.mjs +57 -48
  193. package/dist/index5.mjs +1 -1
  194. package/dist/index50.mjs +51 -33
  195. package/dist/index51.mjs +33 -15
  196. package/dist/index52.mjs +12 -2260
  197. package/dist/index53.mjs +2263 -36
  198. package/dist/index54.mjs +36 -44
  199. package/dist/index55.mjs +44 -99
  200. package/dist/index56.mjs +99 -81
  201. package/dist/index57.mjs +75 -13
  202. package/dist/index58.mjs +15 -125
  203. package/dist/index59.mjs +93 -89
  204. package/dist/index6.mjs +1 -1
  205. package/dist/index60.mjs +102 -56
  206. package/dist/index61.mjs +55 -89
  207. package/dist/index62.mjs +82 -76
  208. package/dist/index63.mjs +100 -13
  209. package/dist/index64.mjs +17 -92
  210. package/dist/index65.mjs +70 -56
  211. package/dist/index66.mjs +62 -44
  212. package/dist/index67.mjs +47 -46
  213. package/dist/index68.mjs +48 -121
  214. package/dist/index69.mjs +133 -22
  215. package/dist/index7.mjs +6 -6
  216. package/dist/index70.mjs +4 -152
  217. package/dist/index71.mjs +21 -20
  218. package/dist/index72.mjs +2 -5
  219. package/dist/index73.mjs +23 -2
  220. package/dist/index74.mjs +149 -71
  221. package/dist/index75.mjs +74 -14
  222. package/dist/index76.mjs +14 -62
  223. package/dist/index77.mjs +63 -2
  224. package/dist/index78.mjs +234 -5
  225. package/dist/index79.mjs +5 -1133
  226. package/dist/index8.mjs +4 -4
  227. package/dist/index80.mjs +131 -17
  228. package/dist/index81.mjs +67 -54
  229. package/dist/index82.mjs +84 -30
  230. package/dist/index83.mjs +29 -2
  231. package/dist/index84.mjs +9 -235
  232. package/dist/index85.mjs +74 -5
  233. package/dist/index86.mjs +3 -133
  234. package/dist/index87.mjs +2 -68
  235. package/dist/index88.mjs +79 -83
  236. package/dist/index89.mjs +52 -27
  237. package/dist/index9.mjs +3 -3
  238. package/dist/index90.mjs +5 -8
  239. package/dist/index91.mjs +4 -74
  240. package/dist/index92.mjs +178 -3
  241. package/dist/index93.mjs +53 -2
  242. package/dist/index94.mjs +68 -82
  243. package/dist/index95.mjs +33 -53
  244. package/dist/index96.mjs +42 -5
  245. package/dist/index97.mjs +2 -5
  246. package/dist/index98.mjs +5 -178
  247. package/dist/index99.mjs +1134 -53
  248. package/dist/styles.css +1 -1
  249. package/package.json +1 -1
  250. package/src/components/ProductAddOns.stories.tsx +10 -3
  251. package/src/components/ProductAddOns.tsx +167 -112
  252. package/src/components/RecommendedProducts.tsx +130 -88
  253. package/src/components/VariantPickerModal.tsx +154 -0
  254. package/src/contexts/CartContext.tsx +8 -1
  255. package/src/index.ts +3 -0
package/dist/index28.mjs CHANGED
@@ -1,118 +1,43 @@
1
1
  'use client';
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
- });
8
- if (!s.ok)
9
- throw new Error(`Failed to fetch cart: ${s.statusText}`);
10
- return s.json();
11
- }
12
- async function p(n) {
13
- const s = await o(r).carts.index.$post({
14
- json: { brandSlug: n }
15
- });
16
- if (!s.ok)
17
- throw new Error(`Failed to create cart: ${s.statusText}`);
18
- return s.json();
19
- }
20
- async function w(n, e) {
21
- const t = await o(r).carts[":id"].$patch({
22
- param: { id: n },
23
- // @ts-expect-error - Hono RPC type inference issue
24
- json: e
25
- });
26
- if (!t.ok)
27
- throw new Error(`Failed to update cart: ${t.statusText}`);
28
- return t.json();
29
- }
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
- // @ts-expect-error - Hono RPC type inference issue
34
- json: { sku: e, quantity: s, fbc: t, fbp: a, ttp: c, ttclid: d }
35
- });
36
- if (!i.ok)
37
- throw new Error(`Failed to add item to cart: ${i.statusText}`);
38
- return i.json();
39
- }
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
- // @ts-expect-error - Hono RPC type inference issue
44
- json: { quantity: s }
45
- });
46
- if (!a.ok)
47
- throw new Error(`Failed to update cart item: ${a.statusText}`);
48
- return a.json();
49
- }
50
- async function $(n, e) {
51
- const t = await o(r).carts[":id"].items[":itemId"].$delete({
52
- param: { id: n, itemId: e }
2
+ import { createRpcClients as e } from "./index27.mjs";
3
+ const s = "https://oms-api.instock.com.ng";
4
+ async function a(o) {
5
+ const t = await e(s).products[":brandSlug"].$get({
6
+ param: { brandSlug: o }
53
7
  });
54
8
  if (!t.ok)
55
- throw new Error(`Failed to remove cart item: ${t.statusText}`);
9
+ throw new Error(`Failed to fetch products: ${t.statusText}`);
56
10
  return t.json();
57
11
  }
58
- async function j(n, e) {
59
- const t = await o(r).carts[":id"]["apply-discount"].$post({
60
- param: { id: n },
61
- // @ts-expect-error - Hono RPC type inference issue
62
- json: { code: e }
12
+ async function i(o) {
13
+ const t = await e(s).products.product[":slug"].$get({
14
+ param: { slug: o }
63
15
  });
64
16
  if (!t.ok)
65
- throw new Error(`Failed to apply discount: ${t.statusText}`);
17
+ throw new Error(`Failed to fetch product: ${t.statusText}`);
66
18
  return t.json();
67
19
  }
68
- async function k(n) {
69
- const s = await o(r).carts[":id"]["remove-discount"].$post({
70
- param: { id: n }
71
- });
72
- if (!s.ok)
73
- throw new Error(`Failed to remove discount: ${s.statusText}`);
74
- return s.json();
75
- }
76
- async function y(n, e) {
77
- const t = await o(r).carts[":id"].checkout.$post({
78
- param: { id: n },
79
- // @ts-expect-error - Hono RPC type inference issue
80
- json: e
20
+ async function u(o, n) {
21
+ const r = await e(s).productAddons[":slug"].$get({
22
+ param: { slug: o },
23
+ query: n !== void 0 ? { limit: String(n) } : {}
81
24
  });
82
- if (!t.ok)
83
- throw new Error(`Failed to checkout cart: ${t.statusText}`);
84
- return t.json();
25
+ if (!r.ok)
26
+ throw new Error(`Failed to fetch product add-ons: ${r.statusText}`);
27
+ return r.json();
85
28
  }
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
29
+ async function d(o, n) {
30
+ const r = await e(s).products.product[":slug"].recommendations.$get({
31
+ param: { slug: o },
32
+ query: n !== void 0 ? { limit: String(n) } : {}
91
33
  });
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 },
99
- // @ts-ignore - Hono RPC type inference issue with query parameters
100
- query: { limit: e.toString() }
101
- });
102
- if (!t.ok)
103
- throw new Error(`Failed to fetch cart recommendations: ${t.statusText}`);
104
- return t.json();
34
+ if (!r.ok)
35
+ throw new Error(`Failed to fetch product recommendations: ${r.statusText}`);
36
+ return r.json();
105
37
  }
106
38
  export {
107
- f as addCartItem,
108
- j as applyDiscount,
109
- y as checkoutCart,
110
- p as createCart,
111
- m as fetchCart,
112
- E as fetchCartRecommendations,
113
- x as initiateCheckout,
114
- $ as removeCartItem,
115
- k as removeDiscount,
116
- w as updateCart,
117
- h as updateCartItem
39
+ u as fetchProductAddons,
40
+ i as fetchProductBySlug,
41
+ d as fetchProductRecommendations,
42
+ a as fetchProductsByBrand
118
43
  };
package/dist/index29.mjs CHANGED
@@ -1,34 +1,118 @@
1
1
  'use client';
2
- import { createRpcClients as s } from "./index26.mjs";
3
- const i = "https://oms-api.instock.com.ng";
4
- async function a(r, o) {
5
- const t = await s(i).orders[":id"][":token"].$get({
6
- param: { id: r, token: o }
2
+ import { createRpcClients as o } from "./index27.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
+ });
8
+ if (!s.ok)
9
+ throw new Error(`Failed to fetch cart: ${s.statusText}`);
10
+ return s.json();
11
+ }
12
+ async function p(n) {
13
+ const s = await o(r).carts.index.$post({
14
+ json: { brandSlug: n }
15
+ });
16
+ if (!s.ok)
17
+ throw new Error(`Failed to create cart: ${s.statusText}`);
18
+ return s.json();
19
+ }
20
+ async function w(n, e) {
21
+ const t = await o(r).carts[":id"].$patch({
22
+ param: { id: n },
23
+ // @ts-expect-error - Hono RPC type inference issue
24
+ json: e
25
+ });
26
+ if (!t.ok)
27
+ throw new Error(`Failed to update cart: ${t.statusText}`);
28
+ return t.json();
29
+ }
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
+ // @ts-expect-error - Hono RPC type inference issue
34
+ json: { sku: e, quantity: s, fbc: t, fbp: a, ttp: c, ttclid: d }
35
+ });
36
+ if (!i.ok)
37
+ throw new Error(`Failed to add item to cart: ${i.statusText}`);
38
+ return i.json();
39
+ }
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
+ // @ts-expect-error - Hono RPC type inference issue
44
+ json: { quantity: s }
45
+ });
46
+ if (!a.ok)
47
+ throw new Error(`Failed to update cart item: ${a.statusText}`);
48
+ return a.json();
49
+ }
50
+ async function $(n, e) {
51
+ const t = await o(r).carts[":id"].items[":itemId"].$delete({
52
+ param: { id: n, itemId: e }
7
53
  });
8
54
  if (!t.ok)
9
- throw new Error(`Failed to fetch order: ${t.statusText}`);
55
+ throw new Error(`Failed to remove cart item: ${t.statusText}`);
10
56
  return t.json();
11
57
  }
12
- async function d(r, o) {
13
- const t = await s(i).orders.confirm.$post({
14
- json: { orderId: r, token: o }
58
+ async function j(n, e) {
59
+ const t = await o(r).carts[":id"]["apply-discount"].$post({
60
+ param: { id: n },
61
+ // @ts-expect-error - Hono RPC type inference issue
62
+ json: { code: e }
15
63
  });
16
64
  if (!t.ok)
17
- throw new Error(`Failed to confirm order: ${t.statusText}`);
65
+ throw new Error(`Failed to apply discount: ${t.statusText}`);
18
66
  return t.json();
19
67
  }
20
- async function m(r, o, e = 4) {
21
- const n = await s(i).orders[":id"][":token"].recommendations.$get({
22
- param: { id: r, token: o },
68
+ async function k(n) {
69
+ const s = await o(r).carts[":id"]["remove-discount"].$post({
70
+ param: { id: n }
71
+ });
72
+ if (!s.ok)
73
+ throw new Error(`Failed to remove discount: ${s.statusText}`);
74
+ return s.json();
75
+ }
76
+ async function y(n, e) {
77
+ const t = await o(r).carts[":id"].checkout.$post({
78
+ param: { id: n },
79
+ // @ts-expect-error - Hono RPC type inference issue
80
+ json: e
81
+ });
82
+ if (!t.ok)
83
+ throw new Error(`Failed to checkout cart: ${t.statusText}`);
84
+ return t.json();
85
+ }
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 },
23
99
  // @ts-ignore - Hono RPC type inference issue with query parameters
24
- query: { limit: String(e) }
100
+ query: { limit: e.toString() }
25
101
  });
26
- if (!n.ok)
27
- throw new Error(`Failed to fetch order recommendations: ${n.statusText}`);
28
- return n.json();
102
+ if (!t.ok)
103
+ throw new Error(`Failed to fetch cart recommendations: ${t.statusText}`);
104
+ return t.json();
29
105
  }
30
106
  export {
31
- d as confirmOrder,
32
- a as fetchOrder,
33
- m as fetchOrderRecommendations
107
+ f as addCartItem,
108
+ j as applyDiscount,
109
+ y as checkoutCart,
110
+ p as createCart,
111
+ m as fetchCart,
112
+ E as fetchCartRecommendations,
113
+ x as initiateCheckout,
114
+ $ as removeCartItem,
115
+ k as removeDiscount,
116
+ w as updateCart,
117
+ h as updateCartItem
34
118
  };
package/dist/index3.mjs CHANGED
@@ -1,35 +1,35 @@
1
1
  'use client';
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
- import "./index23.mjs";
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;
2
+ import { jsxs as ft, jsx as Ct } from "react/jsx-runtime";
3
+ import { createContext as pt, useState as x, useRef as P, useEffect as l, useCallback as a, useContext as It } from "react";
4
+ import "./index24.mjs";
5
+ import { queryKeys as O } from "./index33.mjs";
6
+ import { useGetCart as kt, useCreateCart as ht, useAddCartItem as wt, useUpdateCartItem as yt, useRemoveCartItem as vt, useApplyDiscount as Tt, useRemoveDiscount as gt, useUpdateCart as At, useCheckoutCart as Dt, useInitiateCheckout as Mt } from "./index36.mjs";
7
+ import { useQueryClient as Et } from "@tanstack/react-query";
8
+ import { ShoppingCart as St } from "./index14.mjs";
9
+ import { useMetaPixel as xt } from "./index4.mjs";
10
+ import { useTikTokPixel as Pt } from "./index5.mjs";
11
+ import { getFbCookies as $, getTikTokCookies as G, generateClientEventId as Rt } from "./index23.mjs";
12
+ const f = "oms_cart_id", H = pt(null);
13
+ function Ot({ children: C, brandSlug: u, initialCartId: p, shoppingCartProps: Y }) {
14
+ const [t, m] = x(p || null), [I, y] = x(!1), [z, B] = x(!1), R = P(!1), _ = P(!1), v = P(!1), b = Et(), { trackAddToCart: T, trackInitiateCheckout: g } = xt(), { trackAddToCart: A, trackInitiateCheckout: D } = Pt();
15
+ l(() => {
16
+ B(!0);
17
+ }, []), l(() => {
18
+ if (p || R.current) return;
19
+ R.current = !0;
20
20
  const o = new URLSearchParams(window.location.search).get("cartId");
21
21
  if (o) {
22
22
  m(o), y(!0);
23
23
  return;
24
24
  }
25
- const c = localStorage.getItem(l);
25
+ const c = localStorage.getItem(f);
26
26
  c && m(c);
27
27
  }, [p]);
28
- const { data: n, isLoading: z, error: k, refetch: s } = It(t || "", {
28
+ const { data: n, isLoading: J, error: k, refetch: s } = kt(t || "", {
29
29
  enabled: !!t,
30
30
  retry: !1
31
31
  // Don't retry on failure - cart might be invalid/expired
32
- }), M = kt({
32
+ }), M = ht({
33
33
  onSuccess: (e) => {
34
34
  if ("error" in e) {
35
35
  console.error("Failed to create cart:", e.error);
@@ -42,111 +42,111 @@ function Ot({ children: C, brandSlug: u, initialCartId: p, shoppingCartProps: $
42
42
  },
43
43
  retry: 10
44
44
  });
45
- f(() => {
46
- if (R.current) return;
47
- R.current = !0;
45
+ l(() => {
46
+ if (_.current) return;
47
+ _.current = !0;
48
48
  const e = setTimeout(() => {
49
- !(typeof window < "u" ? localStorage.getItem(l) : null) && !p && M.mutate(u);
49
+ !(typeof window < "u" ? localStorage.getItem(f) : null) && !p && M.mutate(u);
50
50
  }, 150);
51
51
  return () => clearTimeout(e);
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(() => {
52
+ }, []), l(() => {
53
+ k && t && !v.current && (v.current = !0, console.warn("Cart fetch failed, creating new cart:", k), m(null), typeof window < "u" && localStorage.removeItem(f), setTimeout(() => {
54
54
  M.mutate(u), v.current = !1;
55
55
  }, 100));
56
56
  }, [k, t, u]);
57
- const B = wt(t || "", {
57
+ const V = wt(t || "", {
58
58
  onSuccess: () => s()
59
- }), J = ht(t || "", {
59
+ }), W = yt(t || "", {
60
60
  onSuccess: () => s()
61
- }), V = yt(t || "", {
61
+ }), X = vt(t || "", {
62
62
  onSuccess: () => {
63
- s(), t && Y.invalidateQueries({ queryKey: pt.public.carts.recommendations(t) });
63
+ s(), t && b.invalidateQueries({ queryKey: O.public.carts.recommendations(t) });
64
64
  }
65
- }), W = vt(t || "", {
65
+ }), Z = Tt(t || "", {
66
66
  onSuccess: () => s()
67
- }), X = Tt(t || "", {
67
+ }), tt = gt(t || "", {
68
68
  onSuccess: () => s()
69
- }), Z = gt(t || "", {
69
+ }), et = At(t || "", {
70
70
  onSuccess: () => s(),
71
71
  retry: 3
72
- }), tt = At(t || "", {
72
+ }), rt = Dt(t || "", {
73
73
  onSuccess: () => {
74
74
  }
75
- }), b = Dt(t || "");
76
- f(() => {
77
- t && typeof window < "u" && localStorage.setItem(l, t);
75
+ }), q = Mt(t || "");
76
+ l(() => {
77
+ t && typeof window < "u" && localStorage.setItem(f, t);
78
78
  }, [t]);
79
- const et = a(
79
+ const ot = a(
80
80
  async (e, o, c, i, r) => {
81
- var K;
81
+ var Q;
82
82
  if (!t) throw new Error("No cart ID");
83
- const { fbc: d, fbp: E } = j(), { ttp: S, ttclid: mt } = O(), N = await B.mutateAsync({
83
+ const { fbc: d, fbp: E } = $(), { ttp: S, ttclid: lt } = G(), N = !I, U = await V.mutateAsync({
84
84
  sku: i,
85
85
  quantity: r,
86
86
  fbc: d,
87
87
  fbp: E,
88
88
  ttp: S,
89
- ttclid: mt,
90
- refreshRecommendations: !I
89
+ ttclid: lt,
90
+ refreshRecommendations: N
91
91
  });
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;
92
+ if (N && t && b.invalidateQueries({ queryKey: O.public.carts.recommendations(t) }), "error" in U) return;
93
+ const h = (Q = U.items) == null ? void 0 : Q.filter(
94
+ (w) => {
95
+ var j;
96
+ return ((j = w.variant) == null ? void 0 : j.sku) === i;
97
97
  }
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);
98
+ ), L = h == null ? void 0 : h[h.length - 1];
99
+ if (L) {
100
+ const w = `cart_${t}_item_${L.id}`;
101
+ T(i, o, c, r, w), A(e, o, c, r, w);
102
102
  } else
103
103
  T(i, o, c, r), A(e, o, c, r);
104
104
  },
105
105
  // eslint-disable-next-line react-hooks/exhaustive-deps
106
106
  [t, I, T, A]
107
- ), rt = a(
107
+ ), nt = a(
108
108
  async (e, o) => {
109
109
  if (!t) throw new Error("No cart ID");
110
- await J.mutateAsync({ itemId: e, quantity: o });
110
+ await W.mutateAsync({ itemId: e, quantity: o });
111
111
  },
112
112
  // eslint-disable-next-line react-hooks/exhaustive-deps
113
113
  [t]
114
- ), ot = a(
114
+ ), ct = a(
115
115
  async (e) => {
116
116
  if (!t) throw new Error("No cart ID");
117
- await V.mutateAsync(e);
117
+ await X.mutateAsync(e);
118
118
  },
119
119
  // eslint-disable-next-line react-hooks/exhaustive-deps
120
120
  [t]
121
- ), nt = a(
121
+ ), at = a(
122
122
  async (e) => {
123
123
  if (!t) throw new Error("No cart ID");
124
- await W.mutateAsync({ code: e });
124
+ await Z.mutateAsync({ code: e });
125
125
  },
126
126
  // eslint-disable-next-line react-hooks/exhaustive-deps
127
127
  [t]
128
- ), ct = a(async () => {
128
+ ), st = a(async () => {
129
129
  if (!t) throw new Error("No cart ID");
130
- await X.mutateAsync();
130
+ await tt.mutateAsync();
131
131
  }, [t]), F = a(() => {
132
- m(null), typeof window < "u" && localStorage.removeItem(l);
133
- }, []), at = a(() => {
132
+ m(null), typeof window < "u" && localStorage.removeItem(f);
133
+ }, []), it = a(() => {
134
134
  F(), M.mutate(u);
135
- }, [u]), st = a(() => {
135
+ }, [u]), ut = a(() => {
136
136
  y(!0);
137
- }, []), q = a(() => {
137
+ }, []), K = a(() => {
138
138
  y(!1);
139
- }, []), it = a(async () => {
139
+ }, []), mt = a(async () => {
140
140
  if (!(!n || !n.pricing))
141
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) => ({
142
+ const e = Rt("cart", n.id, "checkout"), o = n.pricing.total, c = n.items.reduce((r, d) => r + d.quantity, 0), i = n.items.map((r) => ({
143
143
  id: r.variant.sku,
144
144
  quantity: r.quantity,
145
145
  item_price: Number(r.variant.price)
146
146
  }));
147
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({
148
+ const { fbc: r, fbp: d } = $(), { ttp: E, ttclid: S } = G();
149
+ q.mutate({
150
150
  email: n.customerEmail,
151
151
  phone: n.customerPhone,
152
152
  fbc: r,
@@ -163,46 +163,46 @@ function Ot({ children: C, brandSlug: u, initialCartId: p, shoppingCartProps: $
163
163
  } catch (e) {
164
164
  console.error("Error tracking initiate checkout:", e);
165
165
  }
166
- }, [n, g, D, b]), ut = {
166
+ }, [n, g, D, q]), dt = {
167
167
  cart: n || null,
168
168
  cartId: t,
169
- isLoading: z,
169
+ isLoading: J,
170
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,
171
+ updateCartMutation: et,
172
+ checkoutMutation: rt,
173
+ addItem: ot,
174
+ updateItem: nt,
175
+ removeItem: ct,
176
+ applyDiscount: at,
177
+ removeDiscount: st,
178
+ trackCheckoutInitiated: mt,
179
179
  clearCart: F,
180
- clearAndCreateNewCart: at,
180
+ clearAndCreateNewCart: it,
181
181
  refetch: s,
182
182
  isOpen: I,
183
- open: st,
184
- close: q
183
+ open: ut,
184
+ close: K
185
185
  };
186
- return /* @__PURE__ */ dt(Q.Provider, { value: ut, children: [
186
+ return /* @__PURE__ */ ft(H.Provider, { value: dt, children: [
187
187
  C,
188
- G && /* @__PURE__ */ ft(
189
- Et,
188
+ z && /* @__PURE__ */ Ct(
189
+ St,
190
190
  {
191
191
  isOpen: I,
192
- onClose: q,
193
- ...$
192
+ onClose: K,
193
+ ...Y
194
194
  }
195
195
  )
196
196
  ] });
197
197
  }
198
- function Qt() {
199
- const C = Ct(Q);
198
+ function $t() {
199
+ const C = It(H);
200
200
  if (!C)
201
201
  throw new Error("useCart must be used within CartProvider");
202
202
  return C;
203
203
  }
204
204
  export {
205
- Q as CartContext,
205
+ H as CartContext,
206
206
  Ot as CartProvider,
207
- Qt as useCart
207
+ $t as useCart
208
208
  };
package/dist/index30.mjs CHANGED
@@ -1,14 +1,34 @@
1
1
  'use client';
2
- import { createRpcClients as o } from "./index26.mjs";
3
- const n = "https://oms-api.instock.com.ng";
4
- async function r(t) {
5
- const e = await o(n).deliveryZones.index.$get({
6
- query: t ? { brandId: t } : {}
2
+ import { createRpcClients as s } from "./index27.mjs";
3
+ const i = "https://oms-api.instock.com.ng";
4
+ async function a(r, o) {
5
+ const t = await s(i).orders[":id"][":token"].$get({
6
+ param: { id: r, token: o }
7
7
  });
8
- if (!e.ok)
9
- throw new Error(`Failed to fetch delivery zones: ${e.statusText}`);
10
- return e.json();
8
+ if (!t.ok)
9
+ throw new Error(`Failed to fetch order: ${t.statusText}`);
10
+ return t.json();
11
+ }
12
+ async function d(r, o) {
13
+ const t = await s(i).orders.confirm.$post({
14
+ json: { orderId: r, token: o }
15
+ });
16
+ if (!t.ok)
17
+ throw new Error(`Failed to confirm order: ${t.statusText}`);
18
+ return t.json();
19
+ }
20
+ async function m(r, o, e = 4) {
21
+ const n = await s(i).orders[":id"][":token"].recommendations.$get({
22
+ param: { id: r, token: o },
23
+ // @ts-ignore - Hono RPC type inference issue with query parameters
24
+ query: { limit: String(e) }
25
+ });
26
+ if (!n.ok)
27
+ throw new Error(`Failed to fetch order recommendations: ${n.statusText}`);
28
+ return n.json();
11
29
  }
12
30
  export {
13
- r as fetchDeliveryZones
31
+ d as confirmOrder,
32
+ a as fetchOrder,
33
+ m as fetchOrderRecommendations
14
34
  };
package/dist/index31.mjs CHANGED
@@ -1,14 +1,14 @@
1
1
  'use client';
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 }
2
+ import { createRpcClients as o } from "./index27.mjs";
3
+ const n = "https://oms-api.instock.com.ng";
4
+ async function r(t) {
5
+ const e = await o(n).deliveryZones.index.$get({
6
+ query: t ? { brandId: t } : {}
7
7
  });
8
- if (!t.ok)
9
- throw new Error(`Failed to fetch brand: ${t.statusText}`);
10
- return t.json();
8
+ if (!e.ok)
9
+ throw new Error(`Failed to fetch delivery zones: ${e.statusText}`);
10
+ return e.json();
11
11
  }
12
12
  export {
13
- c as fetchBrandBySlug
13
+ r as fetchDeliveryZones
14
14
  };