@instockng/storefront-ui 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (152) hide show
  1. package/README.md +394 -0
  2. package/dist/components/CartItem.d.ts +15 -0
  3. package/dist/components/CartItem.d.ts.map +1 -0
  4. package/dist/components/Checkout.d.ts +39 -0
  5. package/dist/components/Checkout.d.ts.map +1 -0
  6. package/dist/components/DiscountCodeInput.d.ts +20 -0
  7. package/dist/components/DiscountCodeInput.d.ts.map +1 -0
  8. package/dist/components/OrderConfirmation.d.ts +30 -0
  9. package/dist/components/OrderConfirmation.d.ts.map +1 -0
  10. package/dist/components/ProductCard.d.ts +42 -0
  11. package/dist/components/ProductCard.d.ts.map +1 -0
  12. package/dist/components/ProductGrid.d.ts +33 -0
  13. package/dist/components/ProductGrid.d.ts.map +1 -0
  14. package/dist/components/ShoppingCart.d.ts +28 -0
  15. package/dist/components/ShoppingCart.d.ts.map +1 -0
  16. package/dist/components/ui/badge.d.ts +10 -0
  17. package/dist/components/ui/badge.d.ts.map +1 -0
  18. package/dist/components/ui/button.d.ts +12 -0
  19. package/dist/components/ui/button.d.ts.map +1 -0
  20. package/dist/components/ui/card.d.ts +9 -0
  21. package/dist/components/ui/card.d.ts.map +1 -0
  22. package/dist/components/ui/form-input.d.ts +20 -0
  23. package/dist/components/ui/form-input.d.ts.map +1 -0
  24. package/dist/components/ui/form-select.d.ts +18 -0
  25. package/dist/components/ui/form-select.d.ts.map +1 -0
  26. package/dist/components/ui/modal.d.ts +31 -0
  27. package/dist/components/ui/modal.d.ts.map +1 -0
  28. package/dist/contexts/CartContext.d.ts +60 -0
  29. package/dist/contexts/CartContext.d.ts.map +1 -0
  30. package/dist/hooks/usePaystackPayment.d.ts +46 -0
  31. package/dist/hooks/usePaystackPayment.d.ts.map +1 -0
  32. package/dist/index.d.ts +34 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.mjs +99 -0
  35. package/dist/index10.mjs +644 -0
  36. package/dist/index100.mjs +7 -0
  37. package/dist/index101.mjs +35 -0
  38. package/dist/index102.mjs +33 -0
  39. package/dist/index103.mjs +30 -0
  40. package/dist/index104.mjs +63 -0
  41. package/dist/index105.mjs +5 -0
  42. package/dist/index106.mjs +4 -0
  43. package/dist/index107.mjs +4 -0
  44. package/dist/index108.mjs +19 -0
  45. package/dist/index109.mjs +15 -0
  46. package/dist/index11.mjs +62 -0
  47. package/dist/index110.mjs +8 -0
  48. package/dist/index111.mjs +32 -0
  49. package/dist/index12.mjs +64 -0
  50. package/dist/index13.mjs +26 -0
  51. package/dist/index14.mjs +117 -0
  52. package/dist/index15.mjs +44 -0
  53. package/dist/index16.mjs +44 -0
  54. package/dist/index17.mjs +44 -0
  55. package/dist/index18.mjs +43 -0
  56. package/dist/index19.mjs +11 -0
  57. package/dist/index2.mjs +24 -0
  58. package/dist/index20.mjs +29 -0
  59. package/dist/index21.mjs +34 -0
  60. package/dist/index22.mjs +22 -0
  61. package/dist/index23.mjs +90 -0
  62. package/dist/index24.mjs +22 -0
  63. package/dist/index25.mjs +13 -0
  64. package/dist/index26.mjs +99 -0
  65. package/dist/index27.mjs +20 -0
  66. package/dist/index28.mjs +67 -0
  67. package/dist/index29.mjs +98 -0
  68. package/dist/index3.mjs +121 -0
  69. package/dist/index30.mjs +21 -0
  70. package/dist/index31.mjs +21 -0
  71. package/dist/index32.mjs +13 -0
  72. package/dist/index33.mjs +6 -0
  73. package/dist/index34.mjs +1435 -0
  74. package/dist/index35.mjs +4 -0
  75. package/dist/index36.mjs +59 -0
  76. package/dist/index37.mjs +53 -0
  77. package/dist/index38.mjs +35 -0
  78. package/dist/index39.mjs +17 -0
  79. package/dist/index4.mjs +201 -0
  80. package/dist/index40.mjs +2265 -0
  81. package/dist/index41.mjs +25 -0
  82. package/dist/index42.mjs +38 -0
  83. package/dist/index43.mjs +46 -0
  84. package/dist/index44.mjs +101 -0
  85. package/dist/index45.mjs +114 -0
  86. package/dist/index46.mjs +78 -0
  87. package/dist/index47.mjs +89 -0
  88. package/dist/index48.mjs +106 -0
  89. package/dist/index49.mjs +87 -0
  90. package/dist/index5.mjs +112 -0
  91. package/dist/index50.mjs +76 -0
  92. package/dist/index51.mjs +20 -0
  93. package/dist/index52.mjs +19 -0
  94. package/dist/index53.mjs +64 -0
  95. package/dist/index54.mjs +131 -0
  96. package/dist/index55.mjs +135 -0
  97. package/dist/index56.mjs +77 -0
  98. package/dist/index57.mjs +17 -0
  99. package/dist/index58.mjs +65 -0
  100. package/dist/index59.mjs +6 -0
  101. package/dist/index6.mjs +82 -0
  102. package/dist/index60.mjs +4 -0
  103. package/dist/index61.mjs +7 -0
  104. package/dist/index62.mjs +36 -0
  105. package/dist/index63.mjs +45 -0
  106. package/dist/index64.mjs +237 -0
  107. package/dist/index65.mjs +8 -0
  108. package/dist/index66.mjs +136 -0
  109. package/dist/index67.mjs +70 -0
  110. package/dist/index68.mjs +89 -0
  111. package/dist/index69.mjs +31 -0
  112. package/dist/index7.mjs +100 -0
  113. package/dist/index70.mjs +11 -0
  114. package/dist/index71.mjs +77 -0
  115. package/dist/index72.mjs +6 -0
  116. package/dist/index73.mjs +4 -0
  117. package/dist/index74.mjs +85 -0
  118. package/dist/index75.mjs +56 -0
  119. package/dist/index76.mjs +8 -0
  120. package/dist/index77.mjs +7 -0
  121. package/dist/index78.mjs +181 -0
  122. package/dist/index79.mjs +55 -0
  123. package/dist/index8.mjs +165 -0
  124. package/dist/index80.mjs +71 -0
  125. package/dist/index81.mjs +23 -0
  126. package/dist/index82.mjs +58 -0
  127. package/dist/index83.mjs +31 -0
  128. package/dist/index84.mjs +9 -0
  129. package/dist/index85.mjs +54 -0
  130. package/dist/index86.mjs +8 -0
  131. package/dist/index87.mjs +14 -0
  132. package/dist/index88.mjs +9 -0
  133. package/dist/index89.mjs +30 -0
  134. package/dist/index9.mjs +100 -0
  135. package/dist/index90.mjs +4 -0
  136. package/dist/index91.mjs +72 -0
  137. package/dist/index92.mjs +169 -0
  138. package/dist/index93.mjs +15 -0
  139. package/dist/index94.mjs +9 -0
  140. package/dist/index95.mjs +33 -0
  141. package/dist/index96.mjs +13 -0
  142. package/dist/index97.mjs +6 -0
  143. package/dist/index98.mjs +6 -0
  144. package/dist/index99.mjs +14 -0
  145. package/dist/lib/utils.d.ts +7 -0
  146. package/dist/lib/utils.d.ts.map +1 -0
  147. package/dist/mockServiceWorker.js +349 -0
  148. package/dist/providers/StorefrontProvider.d.ts +47 -0
  149. package/dist/providers/StorefrontProvider.d.ts.map +1 -0
  150. package/dist/test-utils/MockCartProvider.d.ts +21 -0
  151. package/dist/test-utils/MockCartProvider.d.ts.map +1 -0
  152. package/package.json +77 -0
@@ -0,0 +1,121 @@
1
+ import { jsxs as L, jsx as O } from "react/jsx-runtime";
2
+ import { createContext as F, useState as v, useEffect as m, useCallback as o, useContext as G } from "react";
3
+ import "./index18.mjs";
4
+ import { useCreateCart as K, useGetCart as T, useAddCartItem as Y, useUpdateCartItem as q, useRemoveCartItem as z, useApplyDiscount as B, useRemoveDiscount as H, useUpdateCart as J, useCheckoutCart as Q } from "./index29.mjs";
5
+ import "@tanstack/react-query";
6
+ import { ShoppingCart as V } from "./index8.mjs";
7
+ const u = "oms_cart_id", D = F(null);
8
+ function ot({ children: a, brandSlug: f, initialCartId: s, shoppingCartProps: g }) {
9
+ const [t, i] = v(() => {
10
+ if (s) return s;
11
+ if (typeof window < "u") {
12
+ const n = new URLSearchParams(window.location.search).get("cartId");
13
+ return n || localStorage.getItem(u);
14
+ }
15
+ return null;
16
+ }), [d, l] = v(!1), w = K({
17
+ onSuccess: (e) => {
18
+ "error" in e || i(e.id);
19
+ }
20
+ });
21
+ m(() => {
22
+ !t && !s && w.mutate(f);
23
+ }, [t, s, f, w]);
24
+ const { data: A, isLoading: E, error: c, refetch: r } = T(t || "", {
25
+ enabled: !!t,
26
+ retry: !1
27
+ // Don't retry on failure - cart might be invalid/expired
28
+ });
29
+ m(() => {
30
+ c && t && (console.warn("Cart fetch failed, creating new cart:", c), i(null), typeof window < "u" && localStorage.removeItem(u));
31
+ }, [c, t]);
32
+ const p = Y(t || "", {
33
+ onSuccess: () => r()
34
+ }), C = q(t || "", {
35
+ onSuccess: () => r()
36
+ }), I = z(t || "", {
37
+ onSuccess: () => r()
38
+ }), y = B(t || "", {
39
+ onSuccess: () => r()
40
+ }), h = H(t || "", {
41
+ onSuccess: () => r()
42
+ }), M = J(t || "", {
43
+ onSuccess: () => r()
44
+ }), x = Q(t || "");
45
+ m(() => {
46
+ t && typeof window < "u" && localStorage.setItem(u, t);
47
+ }, [t]);
48
+ const P = o(
49
+ async (e, n) => {
50
+ if (!t) throw new Error("No cart ID");
51
+ await p.mutateAsync({ sku: e, quantity: n });
52
+ },
53
+ [t, p]
54
+ ), N = o(
55
+ async (e, n) => {
56
+ if (!t) throw new Error("No cart ID");
57
+ await C.mutateAsync({ itemId: e, quantity: n });
58
+ },
59
+ [t, C]
60
+ ), R = o(
61
+ async (e) => {
62
+ if (!t) throw new Error("No cart ID");
63
+ await I.mutateAsync(e);
64
+ },
65
+ [t, I]
66
+ ), U = o(
67
+ async (e) => {
68
+ if (!t) throw new Error("No cart ID");
69
+ await y.mutateAsync({ code: e });
70
+ },
71
+ [t, y]
72
+ ), _ = o(async () => {
73
+ if (!t) throw new Error("No cart ID");
74
+ await h.mutateAsync();
75
+ }, [t, h]), k = o(() => {
76
+ i(null), typeof window < "u" && localStorage.removeItem(u);
77
+ }, []), b = o(() => {
78
+ l(!0);
79
+ }, []), S = o(() => {
80
+ l(!1);
81
+ }, []), j = {
82
+ cart: A || null,
83
+ cartId: t,
84
+ isLoading: E,
85
+ error: c,
86
+ updateCartMutation: M,
87
+ checkoutMutation: x,
88
+ addItem: P,
89
+ updateItem: N,
90
+ removeItem: R,
91
+ applyDiscount: U,
92
+ removeDiscount: _,
93
+ clearCart: k,
94
+ refetch: r,
95
+ isOpen: d,
96
+ open: b,
97
+ close: S
98
+ };
99
+ return /* @__PURE__ */ L(D.Provider, { value: j, children: [
100
+ a,
101
+ /* @__PURE__ */ O(
102
+ V,
103
+ {
104
+ isOpen: d,
105
+ onClose: S,
106
+ ...g
107
+ }
108
+ )
109
+ ] });
110
+ }
111
+ function rt() {
112
+ const a = G(D);
113
+ if (!a)
114
+ throw new Error("useCart must be used within CartProvider");
115
+ return a;
116
+ }
117
+ export {
118
+ D as CartContext,
119
+ ot as CartProvider,
120
+ rt as useCart
121
+ };
@@ -0,0 +1,21 @@
1
+ import { useMutation as t } from "@tanstack/react-query";
2
+ import { useQueryUnwrapped as u } from "./index61.mjs";
3
+ import { queryKeys as n } from "./index26.mjs";
4
+ import { confirmOrder as i, fetchOrder as m } from "./index24.mjs";
5
+ function y(e, r, o) {
6
+ return u({
7
+ queryKey: n.public.orders.detail(e, r),
8
+ queryFn: () => m(e, r),
9
+ ...o
10
+ });
11
+ }
12
+ function c(e) {
13
+ return t({
14
+ mutationFn: (r) => i(r.orderId, r.token),
15
+ ...e
16
+ });
17
+ }
18
+ export {
19
+ c as useConfirmOrder,
20
+ y as useGetOrder
21
+ };
@@ -0,0 +1,21 @@
1
+ import { useQueryUnwrapped as u } from "./index61.mjs";
2
+ import { queryKeys as t } from "./index26.mjs";
3
+ import { fetchProductsByBrand as o, fetchProductBySlug as c } from "./index22.mjs";
4
+ function n(r, e) {
5
+ return u({
6
+ queryKey: t.public.products.list(r),
7
+ queryFn: () => o(r),
8
+ ...e
9
+ });
10
+ }
11
+ function s(r, e) {
12
+ return u({
13
+ queryKey: t.public.products.detail(r),
14
+ queryFn: () => c(r),
15
+ ...e
16
+ });
17
+ }
18
+ export {
19
+ s as useGetProduct,
20
+ n as useGetProducts
21
+ };
@@ -0,0 +1,13 @@
1
+ import { useQueryUnwrapped as o } from "./index61.mjs";
2
+ import { queryKeys as i } from "./index26.mjs";
3
+ import { fetchDeliveryZones as t } from "./index25.mjs";
4
+ function p(e, r) {
5
+ return o({
6
+ queryKey: i.public.deliveryZones.list(e),
7
+ queryFn: () => t(e),
8
+ ...r
9
+ });
10
+ }
11
+ export {
12
+ p as useGetDeliveryZones
13
+ };
@@ -0,0 +1,6 @@
1
+ const c = "2348125648668", P = "0" + c.slice(3), s = `${P.slice(0, 4)} ${P.slice(4, 7)} ${P.slice(7)}`, t = `https://wa.me/${c}`;
2
+ export {
3
+ t as WHATSAPP_HELP_LINK,
4
+ c as WHATSAPP_HELP_NUMBER,
5
+ s as WHATSAPP_HELP_NUMBER_FORMATTED
6
+ };