@instockng/storefront-ui 1.0.9 → 1.0.11

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 (104) hide show
  1. package/README.md +26 -0
  2. package/dist/components/Checkout.d.ts.map +1 -1
  3. package/dist/contexts/CartContext.d.ts.map +1 -1
  4. package/dist/index10.mjs +144 -141
  5. package/dist/index101.mjs +1 -1
  6. package/dist/index102.mjs +3 -3
  7. package/dist/index103.mjs +3 -3
  8. package/dist/index105.mjs +1 -1
  9. package/dist/index111.mjs +1 -1
  10. package/dist/index20.mjs +2 -2
  11. package/dist/index21.mjs +1 -1
  12. package/dist/index28.mjs +11 -11
  13. package/dist/index29.mjs +1 -1
  14. package/dist/index3.mjs +88 -74
  15. package/dist/index30.mjs +1 -1
  16. package/dist/index31.mjs +1 -1
  17. package/dist/index32.mjs +1 -1
  18. package/dist/index37.mjs +1 -1
  19. package/dist/index41.mjs +36 -23
  20. package/dist/index42.mjs +44 -36
  21. package/dist/index43.mjs +99 -44
  22. package/dist/index44.mjs +112 -99
  23. package/dist/index45.mjs +44 -80
  24. package/dist/index46.mjs +64 -53
  25. package/dist/index47.mjs +66 -49
  26. package/dist/index48.mjs +54 -73
  27. package/dist/index49.mjs +52 -63
  28. package/dist/index50.mjs +14 -70
  29. package/dist/index51.mjs +13 -14
  30. package/dist/index52.mjs +58 -13
  31. package/dist/index53.mjs +101 -34
  32. package/dist/index54.mjs +99 -95
  33. package/dist/index55.mjs +22 -132
  34. package/dist/index58.mjs +2 -2
  35. package/dist/index59.mjs +4 -3
  36. package/dist/index60.mjs +4 -2
  37. package/dist/index61.mjs +2 -5
  38. package/dist/index62.mjs +30 -231
  39. package/dist/index63.mjs +42 -5
  40. package/dist/index64.mjs +228 -127
  41. package/dist/index65.mjs +4 -66
  42. package/dist/index66.mjs +124 -77
  43. package/dist/index67.mjs +65 -26
  44. package/dist/index68.mjs +84 -6
  45. package/dist/index69.mjs +26 -72
  46. package/dist/index70.mjs +8 -3
  47. package/dist/index71.mjs +75 -2
  48. package/dist/index72.mjs +3 -82
  49. package/dist/index73.mjs +2 -54
  50. package/dist/index74.mjs +82 -5
  51. package/dist/index75.mjs +53 -4
  52. package/dist/index76.mjs +5 -178
  53. package/dist/index77.mjs +5 -53
  54. package/dist/index78.mjs +178 -68
  55. package/dist/index79.mjs +50 -31
  56. package/dist/index80.mjs +69 -43
  57. package/dist/index81.mjs +2 -2
  58. package/dist/index82.mjs +1 -1
  59. package/dist/index83.mjs +6 -6
  60. package/dist/index84.mjs +2 -2
  61. package/dist/index85.mjs +2 -2
  62. package/dist/index87.mjs +2 -2
  63. package/dist/index88.mjs +2 -2
  64. package/dist/index89.mjs +1 -1
  65. package/dist/index91.mjs +4 -4
  66. package/dist/index92.mjs +3 -3
  67. package/dist/index93.mjs +30 -12
  68. package/dist/index94.mjs +11 -7
  69. package/dist/index95.mjs +3 -30
  70. package/dist/index96.mjs +3 -10
  71. package/dist/index97.mjs +13 -4
  72. package/dist/index98.mjs +7 -4
  73. package/dist/index99.mjs +1 -1
  74. package/dist/styles.css +1 -0
  75. package/package.json +14 -13
  76. package/src/components/CartItem.stories.tsx +94 -0
  77. package/src/components/CartItem.tsx +141 -0
  78. package/src/components/Checkout.stories.tsx +380 -0
  79. package/src/components/Checkout.tsx +954 -0
  80. package/src/components/DiscountCodeInput.stories.tsx +76 -0
  81. package/src/components/DiscountCodeInput.tsx +162 -0
  82. package/src/components/OrderConfirmation.stories.tsx +142 -0
  83. package/src/components/OrderConfirmation.tsx +301 -0
  84. package/src/components/ProductCard.stories.tsx +112 -0
  85. package/src/components/ProductCard.tsx +195 -0
  86. package/src/components/ProductGrid.stories.tsx +137 -0
  87. package/src/components/ProductGrid.tsx +141 -0
  88. package/src/components/ShoppingCart.stories.tsx +459 -0
  89. package/src/components/ShoppingCart.tsx +262 -0
  90. package/src/components/ui/badge.tsx +37 -0
  91. package/src/components/ui/button.tsx +71 -0
  92. package/src/components/ui/card.tsx +79 -0
  93. package/src/components/ui/form-input.tsx +78 -0
  94. package/src/components/ui/form-select.tsx +73 -0
  95. package/src/components/ui/modal.tsx +181 -0
  96. package/src/contexts/CartContext.tsx +305 -0
  97. package/src/hooks/usePaystackPayment.ts +137 -0
  98. package/src/index.ts +51 -0
  99. package/src/lib/utils.ts +45 -0
  100. package/src/paystack.svg +67 -0
  101. package/src/providers/StorefrontProvider.tsx +70 -0
  102. package/src/styles.css +1 -0
  103. package/src/test-utils/MockCartProvider.tsx +424 -0
  104. package/src/vite-env.d.ts +12 -0
package/dist/index46.mjs CHANGED
@@ -1,79 +1,90 @@
1
1
  'use client';
2
- import { useQueryClient as y, useMutation as m } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as b } from "./index61.mjs";
4
- import { createAdminRpcClients as u, authHeaders as c } from "./index21.mjs";
5
- import { queryKeys as o } from "./index26.mjs";
2
+ import { useQueryClient as p, useMutation as y } from "@tanstack/react-query";
3
+ import { useQueryUnwrapped as m } from "./index59.mjs";
4
+ import { createAdminRpcClients as a, authHeaders as c } from "./index21.mjs";
5
+ import { queryKeys as i } from "./index26.mjs";
6
6
  import { useApiConfig as d } from "./index19.mjs";
7
- function k(e) {
8
- const { baseURL: t, authToken: r } = d();
9
- return b({
10
- queryKey: o.admin.brands.list(),
7
+ function F(t, n) {
8
+ const { baseURL: r, authToken: s } = d();
9
+ return m({
10
+ queryKey: i.admin.products.list(t),
11
11
  queryFn: async () => {
12
- const n = await u(t).brands.index.$get({}, c(r));
13
- if (!n.ok) throw new Error(`Failed to fetch brands: ${n.statusText}`);
14
- return n.json();
12
+ const e = await a(r).products.index.$get(
13
+ t ? { query: { brandId: t } } : {},
14
+ c(s)
15
+ );
16
+ if (!e.ok) throw new Error(`Failed to fetch products: ${e.statusText}`);
17
+ return e.json();
15
18
  },
16
- ...e
19
+ ...n
17
20
  });
18
21
  }
19
- function F(e, t) {
22
+ function T(t, n) {
20
23
  const { baseURL: r, authToken: s } = d();
21
- return b({
22
- queryKey: o.admin.brands.detail(e),
24
+ return m({
25
+ queryKey: i.admin.products.detail(t),
23
26
  queryFn: async () => {
24
- const i = await u(r).brands[":id"].$get({ param: { id: e } }, c(s));
25
- if (!i.ok) throw new Error(`Failed to fetch brand: ${i.statusText}`);
26
- return i.json();
27
+ const e = await a(r).products[":id"].$get(
28
+ { param: { id: t } },
29
+ c(s)
30
+ );
31
+ if (!e.ok) throw new Error(`Failed to fetch product: ${e.statusText}`);
32
+ return e.json();
27
33
  },
28
- ...t
34
+ ...n
29
35
  });
30
36
  }
31
- function T(e) {
32
- const { baseURL: t, authToken: r } = d(), s = y();
33
- return m({
34
- mutationFn: async (n) => {
35
- const a = await u(t).brands.index.$post({ json: n }, c(r));
36
- if (!a.ok) throw new Error(`Failed to create brand: ${a.statusText}`);
37
- return a.json();
38
- },
39
- onSuccess: () => {
40
- s.invalidateQueries({ queryKey: o.admin.brands.all });
37
+ function $(t) {
38
+ const { baseURL: n, authToken: r } = d(), s = p();
39
+ return y({
40
+ mutationFn: async (o) => {
41
+ const u = await a(n).products.index.$post(
42
+ { json: o },
43
+ c(r)
44
+ );
45
+ if (!u.ok) throw new Error(`Failed to create product: ${u.statusText}`);
46
+ return u.json();
41
47
  },
42
- ...e
48
+ onSuccess: () => s.invalidateQueries({ queryKey: i.admin.products.all }),
49
+ ...t
43
50
  });
44
51
  }
45
- function $(e, t) {
46
- const { baseURL: r, authToken: s } = d(), n = y();
47
- return m({
48
- mutationFn: async (i) => {
49
- const l = await u(r).brands[":id"].$patch({ json: i, param: { id: e } }, c(s));
50
- if (!l.ok) throw new Error(`Failed to update brand: ${l.statusText}`);
52
+ function x(t, n) {
53
+ const { baseURL: r, authToken: s } = d(), o = p();
54
+ return y({
55
+ mutationFn: async (e) => {
56
+ const l = await a(r).products[":id"].$patch(
57
+ { param: { id: t }, json: e },
58
+ c(s)
59
+ );
60
+ if (!l.ok) throw new Error(`Failed to update product: ${l.statusText}`);
51
61
  return l.json();
52
62
  },
53
63
  onSuccess: () => {
54
- n.invalidateQueries({ queryKey: o.admin.brands.detail(e) }), n.invalidateQueries({ queryKey: o.admin.brands.all });
64
+ o.invalidateQueries({ queryKey: i.admin.products.detail(t) }), o.invalidateQueries({ queryKey: i.admin.products.all });
55
65
  },
56
- ...t
66
+ ...n
57
67
  });
58
68
  }
59
- function x(e, t) {
60
- const { baseURL: r, authToken: s } = d(), n = y();
61
- return m({
69
+ function j(t, n) {
70
+ const { baseURL: r, authToken: s } = d(), o = p();
71
+ return y({
62
72
  mutationFn: async () => {
63
- const a = await u(r).brands[":id"].$delete({ param: { id: e } }, c(s));
64
- if (!a.ok) throw new Error(`Failed to delete brand: ${a.statusText}`);
65
- return a.json();
73
+ const u = await a(r).products[":id"].$delete(
74
+ { param: { id: t } },
75
+ c(s)
76
+ );
77
+ if (!u.ok) throw new Error(`Failed to delete product: ${u.statusText}`);
78
+ return u.json();
66
79
  },
67
- onSuccess: () => {
68
- n.invalidateQueries({ queryKey: o.admin.brands.all });
69
- },
70
- ...t
80
+ onSuccess: () => o.invalidateQueries({ queryKey: i.admin.products.all }),
81
+ ...n
71
82
  });
72
83
  }
73
84
  export {
74
- T as useCreateBrand,
75
- x as useDeleteBrand,
76
- F as useGetBrand,
77
- k as useListBrands,
78
- $ as useUpdateBrand
85
+ $ as useCreateProduct,
86
+ j as useDeleteProduct,
87
+ T as useGetProduct,
88
+ F as useListProducts,
89
+ x as useUpdateProduct
79
90
  };
package/dist/index47.mjs CHANGED
@@ -1,90 +1,107 @@
1
1
  'use client';
2
- import { useQueryClient as p, useMutation as y } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as m } from "./index61.mjs";
4
- import { createAdminRpcClients as a, authHeaders as c } from "./index21.mjs";
2
+ import { useQueryClient as y, useMutation as v } from "@tanstack/react-query";
3
+ import { useQueryUnwrapped as m } from "./index59.mjs";
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";
7
- function F(t, n) {
8
- const { baseURL: r, authToken: s } = d();
7
+ function k(t, n) {
8
+ const { baseURL: a, authToken: r } = d();
9
9
  return m({
10
- queryKey: i.admin.products.list(t),
10
+ queryKey: i.admin.variants.search(t),
11
11
  queryFn: async () => {
12
- const e = await a(r).products.index.$get(
13
- t ? { query: { brandId: t } } : {},
14
- c(s)
15
- );
16
- if (!e.ok) throw new Error(`Failed to fetch products: ${e.statusText}`);
12
+ const e = await u(a).variants.index.$get({ query: t }, c(r));
13
+ if (!e.ok) throw new Error(`Failed to search variants: ${e.statusText}`);
17
14
  return e.json();
18
15
  },
19
16
  ...n
20
17
  });
21
18
  }
22
- function T(t, n) {
23
- const { baseURL: r, authToken: s } = d();
19
+ function F(t, n) {
20
+ const { baseURL: a, authToken: r } = d();
24
21
  return m({
25
- queryKey: i.admin.products.detail(t),
22
+ queryKey: i.admin.variants.byProduct(t),
26
23
  queryFn: async () => {
27
- const e = await a(r).products[":id"].$get(
28
- { param: { id: t } },
29
- c(s)
24
+ const e = await u(a).variants.products[":productId"].variants.$get(
25
+ { param: { productId: t } },
26
+ c(r)
30
27
  );
31
- if (!e.ok) throw new Error(`Failed to fetch product: ${e.statusText}`);
28
+ if (!e.ok) throw new Error(`Failed to fetch product variants: ${e.statusText}`);
32
29
  return e.json();
33
30
  },
34
31
  ...n
35
32
  });
36
33
  }
37
- function $(t) {
38
- const { baseURL: n, authToken: r } = d(), s = p();
39
- return y({
40
- mutationFn: async (o) => {
41
- const u = await a(n).products.index.$post(
42
- { json: o },
34
+ function T(t, n) {
35
+ const { baseURL: a, authToken: r } = d(), s = y();
36
+ return v({
37
+ mutationFn: async (e) => {
38
+ const o = await u(a).variants.products[":productId"].variants.$post(
39
+ { json: e, param: { productId: t } },
43
40
  c(r)
44
41
  );
45
- if (!u.ok) throw new Error(`Failed to create product: ${u.statusText}`);
46
- return u.json();
42
+ if (!o.ok) throw new Error(`Failed to create variant: ${o.statusText}`);
43
+ return o.json();
44
+ },
45
+ onSuccess: () => {
46
+ s.invalidateQueries({ queryKey: i.admin.variants.all }), s.invalidateQueries({ queryKey: i.admin.products.detail(t) });
47
47
  },
48
- onSuccess: () => s.invalidateQueries({ queryKey: i.admin.products.all }),
49
- ...t
48
+ ...n
50
49
  });
51
50
  }
52
- function x(t, n) {
53
- const { baseURL: r, authToken: s } = d(), o = p();
54
- return y({
51
+ function $(t, n) {
52
+ const { baseURL: a, authToken: r } = d(), s = y();
53
+ return v({
55
54
  mutationFn: async (e) => {
56
- const l = await a(r).products[":id"].$patch(
57
- { param: { id: t }, json: e },
58
- c(s)
55
+ const o = await u(a).variants[":id"].$patch(
56
+ { json: e, param: { id: t } },
57
+ c(r)
59
58
  );
60
- if (!l.ok) throw new Error(`Failed to update product: ${l.statusText}`);
61
- return l.json();
59
+ if (!o.ok) throw new Error(`Failed to update variant: ${o.statusText}`);
60
+ return o.json();
62
61
  },
63
62
  onSuccess: () => {
64
- o.invalidateQueries({ queryKey: i.admin.products.detail(t) }), o.invalidateQueries({ queryKey: i.admin.products.all });
63
+ s.invalidateQueries({ queryKey: i.admin.variants.detail(t) }), s.invalidateQueries({ queryKey: i.admin.variants.all });
64
+ },
65
+ ...n
66
+ });
67
+ }
68
+ function K(t, n) {
69
+ const { baseURL: a, authToken: r } = d();
70
+ return m({
71
+ queryKey: i.admin.variants.inventory(t),
72
+ queryFn: async () => {
73
+ const e = await u(a).variants[":id"].inventory.$get(
74
+ { param: { id: t } },
75
+ c(r)
76
+ );
77
+ if (!e.ok) throw new Error(`Failed to fetch variant inventory: ${e.statusText}`);
78
+ return e.json();
65
79
  },
66
80
  ...n
67
81
  });
68
82
  }
69
83
  function j(t, n) {
70
- const { baseURL: r, authToken: s } = d(), o = p();
71
- return y({
84
+ const { baseURL: a, authToken: r } = d(), s = y();
85
+ return v({
72
86
  mutationFn: async () => {
73
- const u = await a(r).products[":id"].$delete(
87
+ const l = await u(a).variants[":id"].$delete(
74
88
  { param: { id: t } },
75
- c(s)
89
+ c(r)
76
90
  );
77
- if (!u.ok) throw new Error(`Failed to delete product: ${u.statusText}`);
78
- return u.json();
91
+ if (!l.ok) throw new Error(`Failed to delete variant: ${l.statusText}`);
92
+ return l.json();
93
+ },
94
+ onSuccess: () => {
95
+ s.invalidateQueries({ queryKey: i.admin.variants.all });
79
96
  },
80
- onSuccess: () => o.invalidateQueries({ queryKey: i.admin.products.all }),
81
97
  ...n
82
98
  });
83
99
  }
84
100
  export {
85
- $ as useCreateProduct,
86
- j as useDeleteProduct,
87
- T as useGetProduct,
88
- F as useListProducts,
89
- x as useUpdateProduct
101
+ T as useCreateVariant,
102
+ j as useDeleteVariant,
103
+ K as useGetVariantInventory,
104
+ F as useListProductVariants,
105
+ k as useSearchVariants,
106
+ $ as useUpdateVariant
90
107
  };
package/dist/index48.mjs CHANGED
@@ -1,107 +1,88 @@
1
1
  'use client';
2
- import { useQueryClient as y, useMutation as v } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as m } from "./index61.mjs";
4
- import { createAdminRpcClients as u, authHeaders as c } from "./index21.mjs";
5
- import { queryKeys as i } from "./index26.mjs";
6
- import { useApiConfig as d } from "./index19.mjs";
7
- function k(t, n) {
8
- const { baseURL: a, authToken: r } = d();
9
- return m({
10
- queryKey: i.admin.variants.search(t),
2
+ import { useQueryClient as w, useMutation as y } from "@tanstack/react-query";
3
+ import { useQueryUnwrapped as d } from "./index59.mjs";
4
+ import { createAdminRpcClients as i, authHeaders as c } from "./index21.mjs";
5
+ import { queryKeys as u } from "./index26.mjs";
6
+ import { useApiConfig as l } from "./index19.mjs";
7
+ function F(e) {
8
+ const { baseURL: s, authToken: n } = l();
9
+ return d({
10
+ queryKey: u.admin.warehouses.list(),
11
11
  queryFn: async () => {
12
- const e = await u(a).variants.index.$get({ query: t }, c(r));
13
- if (!e.ok) throw new Error(`Failed to search variants: ${e.statusText}`);
14
- return e.json();
12
+ const t = await i(s).warehouses.index.$get({}, c(n));
13
+ if (!t.ok) throw new Error(`Failed to fetch warehouses: ${t.statusText}`);
14
+ return t.json();
15
15
  },
16
- ...n
16
+ ...e
17
17
  });
18
18
  }
19
- function F(t, n) {
20
- const { baseURL: a, authToken: r } = d();
21
- return m({
22
- queryKey: i.admin.variants.byProduct(t),
23
- queryFn: async () => {
24
- const e = await u(a).variants.products[":productId"].variants.$get(
25
- { param: { productId: t } },
26
- c(r)
27
- );
28
- if (!e.ok) throw new Error(`Failed to fetch product variants: ${e.statusText}`);
29
- return e.json();
30
- },
31
- ...n
32
- });
33
- }
34
- function T(t, n) {
35
- const { baseURL: a, authToken: r } = d(), s = y();
36
- return v({
37
- mutationFn: async (e) => {
38
- const o = await u(a).variants.products[":productId"].variants.$post(
39
- { json: e, param: { productId: t } },
40
- c(r)
41
- );
42
- if (!o.ok) throw new Error(`Failed to create variant: ${o.statusText}`);
19
+ function T(e) {
20
+ const { baseURL: s, authToken: n } = l(), r = w();
21
+ return y({
22
+ mutationFn: async (t) => {
23
+ const o = await i(s).warehouses.index.$post({ json: t }, c(n));
24
+ if (!o.ok) throw new Error(`Failed to create warehouse: ${o.statusText}`);
43
25
  return o.json();
44
26
  },
45
27
  onSuccess: () => {
46
- s.invalidateQueries({ queryKey: i.admin.variants.all }), s.invalidateQueries({ queryKey: i.admin.products.detail(t) });
28
+ r.invalidateQueries({ queryKey: u.admin.warehouses.all });
47
29
  },
48
- ...n
30
+ ...e
49
31
  });
50
32
  }
51
- function $(t, n) {
52
- const { baseURL: a, authToken: r } = d(), s = y();
53
- return v({
54
- mutationFn: async (e) => {
55
- const o = await u(a).variants[":id"].$patch(
56
- { json: e, param: { id: t } },
33
+ function $(e, s) {
34
+ const { baseURL: n, authToken: r } = l(), t = w();
35
+ return y({
36
+ mutationFn: async (a) => {
37
+ const h = await i(n).warehouses[":id"].$patch(
38
+ { json: a, param: { id: e } },
57
39
  c(r)
58
40
  );
59
- if (!o.ok) throw new Error(`Failed to update variant: ${o.statusText}`);
60
- return o.json();
41
+ if (!h.ok) throw new Error(`Failed to update warehouse: ${h.statusText}`);
42
+ return h.json();
61
43
  },
62
44
  onSuccess: () => {
63
- s.invalidateQueries({ queryKey: i.admin.variants.detail(t) }), s.invalidateQueries({ queryKey: i.admin.variants.all });
45
+ t.invalidateQueries({ queryKey: u.admin.warehouses.detail(e) }), t.invalidateQueries({ queryKey: u.admin.warehouses.all });
64
46
  },
65
- ...n
47
+ ...s
66
48
  });
67
49
  }
68
- function K(t, n) {
69
- const { baseURL: a, authToken: r } = d();
70
- return m({
71
- queryKey: i.admin.variants.inventory(t),
50
+ function v(e, s) {
51
+ const { baseURL: n, authToken: r } = l();
52
+ return d({
53
+ queryKey: u.admin.warehouses.inventory(e),
72
54
  queryFn: async () => {
73
- const e = await u(a).variants[":id"].inventory.$get(
74
- { param: { id: t } },
55
+ const a = await i(n).warehouses[":id"].inventory.$get(
56
+ { param: { id: e } },
75
57
  c(r)
76
58
  );
77
- if (!e.ok) throw new Error(`Failed to fetch variant inventory: ${e.statusText}`);
78
- return e.json();
59
+ if (!a.ok) throw new Error(`Failed to fetch warehouse inventory: ${a.statusText}`);
60
+ return a.json();
79
61
  },
80
- ...n
62
+ ...s
81
63
  });
82
64
  }
83
- function j(t, n) {
84
- const { baseURL: a, authToken: r } = d(), s = y();
85
- return v({
65
+ function x(e, s) {
66
+ const { baseURL: n, authToken: r } = l(), t = w();
67
+ return y({
86
68
  mutationFn: async () => {
87
- const l = await u(a).variants[":id"].$delete(
88
- { param: { id: t } },
69
+ const o = await i(n).warehouses[":id"].$delete(
70
+ { param: { id: e } },
89
71
  c(r)
90
72
  );
91
- if (!l.ok) throw new Error(`Failed to delete variant: ${l.statusText}`);
92
- return l.json();
73
+ if (!o.ok) throw new Error(`Failed to delete warehouse: ${o.statusText}`);
74
+ return o.json();
93
75
  },
94
76
  onSuccess: () => {
95
- s.invalidateQueries({ queryKey: i.admin.variants.all });
77
+ t.invalidateQueries({ queryKey: u.admin.warehouses.all });
96
78
  },
97
- ...n
79
+ ...s
98
80
  });
99
81
  }
100
82
  export {
101
- T as useCreateVariant,
102
- j as useDeleteVariant,
103
- K as useGetVariantInventory,
104
- F as useListProductVariants,
105
- k as useSearchVariants,
106
- $ as useUpdateVariant
83
+ T as useCreateWarehouse,
84
+ x as useDeleteWarehouse,
85
+ v as useGetWarehouseInventory,
86
+ F as useListWarehouses,
87
+ $ as useUpdateWarehouse
107
88
  };
package/dist/index49.mjs CHANGED
@@ -1,88 +1,77 @@
1
1
  'use client';
2
- import { useQueryClient as w, useMutation as y } from "@tanstack/react-query";
3
- import { useQueryUnwrapped as d } from "./index61.mjs";
4
- import { createAdminRpcClients as i, authHeaders as c } from "./index21.mjs";
5
- import { queryKeys as u } from "./index26.mjs";
6
- import { useApiConfig as l } from "./index19.mjs";
7
- function F(e) {
8
- const { baseURL: s, authToken: n } = l();
9
- return d({
10
- queryKey: u.admin.warehouses.list(),
2
+ import { useQueryClient as d, useMutation as v } from "@tanstack/react-query";
3
+ import { useQueryUnwrapped as l } from "./index59.mjs";
4
+ import { createAdminRpcClients as u, authHeaders as c } from "./index21.mjs";
5
+ import { queryKeys as s } from "./index26.mjs";
6
+ import { useApiConfig as y } from "./index19.mjs";
7
+ function m(n, r) {
8
+ const { baseURL: o, authToken: t } = y();
9
+ return l({
10
+ queryKey: s.admin.inventory.list(n),
11
11
  queryFn: async () => {
12
- const t = await i(s).warehouses.index.$get({}, c(n));
13
- if (!t.ok) throw new Error(`Failed to fetch warehouses: ${t.statusText}`);
14
- return t.json();
12
+ const e = await u(o).inventory.index.$get({ query: n }, c(t));
13
+ if (!e.ok) throw new Error(`Failed to fetch inventory: ${e.statusText}`);
14
+ return e.json();
15
15
  },
16
- ...e
16
+ ...r
17
17
  });
18
18
  }
19
- function T(e) {
20
- const { baseURL: s, authToken: n } = l(), r = w();
21
- return y({
22
- mutationFn: async (t) => {
23
- const o = await i(s).warehouses.index.$post({ json: t }, c(n));
24
- if (!o.ok) throw new Error(`Failed to create warehouse: ${o.statusText}`);
25
- return o.json();
19
+ function T(n) {
20
+ const { baseURL: r, authToken: o } = y(), t = d();
21
+ return v({
22
+ mutationFn: async (a) => {
23
+ const i = await u(r).inventory.adjust.$post({ json: a }, c(o));
24
+ if (!i.ok) throw new Error(`Failed to adjust inventory: ${i.statusText}`);
25
+ return i.json();
26
26
  },
27
27
  onSuccess: () => {
28
- r.invalidateQueries({ queryKey: u.admin.warehouses.all });
28
+ t.invalidateQueries({ queryKey: s.admin.inventory.all }), t.invalidateQueries({ queryKey: s.admin.variants.all }), t.invalidateQueries({ queryKey: s.admin.warehouses.all });
29
29
  },
30
- ...e
30
+ ...n
31
31
  });
32
32
  }
33
- function $(e, s) {
34
- const { baseURL: n, authToken: r } = l(), t = w();
35
- return y({
33
+ function j(n) {
34
+ const { baseURL: r, authToken: o } = y(), t = d();
35
+ return v({
36
36
  mutationFn: async (a) => {
37
- const h = await i(n).warehouses[":id"].$patch(
38
- { json: a, param: { id: e } },
39
- c(r)
40
- );
41
- if (!h.ok) throw new Error(`Failed to update warehouse: ${h.statusText}`);
42
- return h.json();
37
+ const i = await u(r).inventory.transfer.$post({ json: a }, c(o));
38
+ if (!i.ok) throw new Error(`Failed to transfer inventory: ${i.statusText}`);
39
+ return i.json();
43
40
  },
44
41
  onSuccess: () => {
45
- t.invalidateQueries({ queryKey: u.admin.warehouses.detail(e) }), t.invalidateQueries({ queryKey: u.admin.warehouses.all });
42
+ t.invalidateQueries({ queryKey: s.admin.inventory.all }), t.invalidateQueries({ queryKey: s.admin.warehouses.all });
46
43
  },
47
- ...s
44
+ ...n
48
45
  });
49
46
  }
50
- function v(e, s) {
51
- const { baseURL: n, authToken: r } = l();
52
- return d({
53
- queryKey: u.admin.warehouses.inventory(e),
47
+ function F(n, r) {
48
+ const { baseURL: o, authToken: t } = y();
49
+ return l({
50
+ queryKey: s.admin.inventory.transactions(n),
54
51
  queryFn: async () => {
55
- const a = await i(n).warehouses[":id"].inventory.$get(
56
- { param: { id: e } },
57
- c(r)
58
- );
59
- if (!a.ok) throw new Error(`Failed to fetch warehouse inventory: ${a.statusText}`);
60
- return a.json();
52
+ const e = await u(o).inventory.transactions.$get({ query: n }, c(t));
53
+ if (!e.ok) throw new Error(`Failed to fetch inventory transactions: ${e.statusText}`);
54
+ return e.json();
61
55
  },
62
- ...s
56
+ ...r
63
57
  });
64
58
  }
65
- function x(e, s) {
66
- const { baseURL: n, authToken: r } = l(), t = w();
67
- return y({
68
- mutationFn: async () => {
69
- const o = await i(n).warehouses[":id"].$delete(
70
- { param: { id: e } },
71
- c(r)
72
- );
73
- if (!o.ok) throw new Error(`Failed to delete warehouse: ${o.statusText}`);
74
- return o.json();
75
- },
76
- onSuccess: () => {
77
- t.invalidateQueries({ queryKey: u.admin.warehouses.all });
59
+ function $(n, r) {
60
+ const { baseURL: o, authToken: t } = y();
61
+ return l({
62
+ queryKey: s.admin.inventory.lowStock(n == null ? void 0 : n.brandId),
63
+ queryFn: async () => {
64
+ const e = await u(o).inventory["low-stock"].$get({ query: n }, c(t));
65
+ if (!e.ok) throw new Error(`Failed to fetch low stock alerts: ${e.statusText}`);
66
+ return e.json();
78
67
  },
79
- ...s
68
+ ...r
80
69
  });
81
70
  }
82
71
  export {
83
- T as useCreateWarehouse,
84
- x as useDeleteWarehouse,
85
- v as useGetWarehouseInventory,
86
- F as useListWarehouses,
87
- $ as useUpdateWarehouse
72
+ T as useAdjustInventory,
73
+ F as useGetInventoryTransactions,
74
+ $ as useGetLowStockVariants,
75
+ m as useListInventory,
76
+ j as useTransferInventory
88
77
  };