@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,112 @@
1
+ import { jsxs as s, jsx as t, Fragment as u } from "react/jsx-runtime";
2
+ import { useState as f } from "react";
3
+ import { Card as P, CardContent as S, CardFooter as j } from "./index12.mjs";
4
+ import { Button as I } from "./index11.mjs";
5
+ import { Badge as p } from "./index13.mjs";
6
+ import { Package as O, ShoppingCart as q } from "lucide-react";
7
+ import { cn as g, formatCurrency as h } from "./index17.mjs";
8
+ function D({
9
+ product: r,
10
+ onAddToCart: o,
11
+ showStock: b = !0,
12
+ className: x,
13
+ imageClassName: N,
14
+ disableAddToCart: v = !1,
15
+ isAddingToCart: n = !1,
16
+ onClick: i
17
+ }) {
18
+ var d;
19
+ const [c, y] = f(
20
+ ((d = r.variants[0]) == null ? void 0 : d.id) || ""
21
+ ), [m, k] = f(1), a = r.variants.find((e) => e.id === c), C = r.variants.length > 1, l = a ? a.stock === void 0 || a.stock > 0 : !1, w = (e) => {
22
+ e.stopPropagation(), a && o && o(a.id, m);
23
+ };
24
+ return /* @__PURE__ */ s(
25
+ P,
26
+ {
27
+ className: g(
28
+ "group overflow-hidden transition-all hover:shadow-lg",
29
+ i && "cursor-pointer",
30
+ x
31
+ ),
32
+ onClick: i,
33
+ children: [
34
+ /* @__PURE__ */ s("div", { className: "relative aspect-square overflow-hidden bg-gray-100", children: [
35
+ r.imageUrl ? /* @__PURE__ */ t(
36
+ "img",
37
+ {
38
+ src: r.imageUrl,
39
+ alt: r.name,
40
+ className: g(
41
+ "h-full w-full object-cover transition-transform group-hover:scale-105",
42
+ N
43
+ )
44
+ }
45
+ ) : /* @__PURE__ */ t("div", { className: "flex h-full w-full items-center justify-center", children: /* @__PURE__ */ t(O, { className: "h-16 w-16 text-gray-400" }) }),
46
+ !l && /* @__PURE__ */ t(p, { className: "absolute right-2 top-2 bg-red-600", children: "Out of Stock" }),
47
+ b && l && (a == null ? void 0 : a.stock) !== void 0 && a.stock < 10 && /* @__PURE__ */ s(p, { className: "absolute right-2 top-2 bg-orange-600", children: [
48
+ "Only ",
49
+ a.stock,
50
+ " left"
51
+ ] })
52
+ ] }),
53
+ /* @__PURE__ */ s(S, { className: "p-4", children: [
54
+ /* @__PURE__ */ t("h3", { className: "mb-1 font-semibold line-clamp-2", children: r.name }),
55
+ r.description && /* @__PURE__ */ t("p", { className: "mb-2 text-sm text-gray-600 line-clamp-2", children: r.description }),
56
+ C && /* @__PURE__ */ s("div", { className: "mb-3", children: [
57
+ /* @__PURE__ */ t("label", { className: "mb-1 block text-xs font-medium text-gray-700", children: "Select Option" }),
58
+ /* @__PURE__ */ t(
59
+ "select",
60
+ {
61
+ value: c,
62
+ onChange: (e) => {
63
+ e.stopPropagation(), y(e.target.value);
64
+ },
65
+ className: "w-full rounded-md border border-gray-300 px-2 py-1 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500",
66
+ onClick: (e) => e.stopPropagation(),
67
+ children: r.variants.map((e) => /* @__PURE__ */ s("option", { value: e.id, children: [
68
+ e.name,
69
+ " - ",
70
+ h(e.price)
71
+ ] }, e.id))
72
+ }
73
+ )
74
+ ] }),
75
+ /* @__PURE__ */ t("div", { className: "mb-3 text-2xl font-bold text-blue-600", children: a && h(a.price) }),
76
+ /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
77
+ /* @__PURE__ */ t("label", { className: "text-xs font-medium text-gray-700", children: "Qty:" }),
78
+ /* @__PURE__ */ t(
79
+ "input",
80
+ {
81
+ type: "number",
82
+ min: "1",
83
+ max: (a == null ? void 0 : a.stock) || 999,
84
+ value: m,
85
+ onChange: (e) => {
86
+ e.stopPropagation(), k(Math.max(1, parseInt(e.target.value) || 1));
87
+ },
88
+ onClick: (e) => e.stopPropagation(),
89
+ className: "w-20 rounded-md border border-gray-300 px-2 py-1 text-sm focus:border-blue-500 focus:outline-none focus:ring-1 focus:ring-blue-500"
90
+ }
91
+ )
92
+ ] })
93
+ ] }),
94
+ /* @__PURE__ */ t(j, { className: "p-4 pt-0", children: /* @__PURE__ */ t(
95
+ I,
96
+ {
97
+ onClick: w,
98
+ disabled: v || !l || n,
99
+ className: "w-full",
100
+ children: n ? /* @__PURE__ */ t(u, { children: "Adding..." }) : /* @__PURE__ */ s(u, { children: [
101
+ /* @__PURE__ */ t(q, { className: "mr-2 h-4 w-4" }),
102
+ "Add to Cart"
103
+ ] })
104
+ }
105
+ ) })
106
+ ]
107
+ }
108
+ );
109
+ }
110
+ export {
111
+ D as ProductCard
112
+ };
@@ -0,0 +1,76 @@
1
+ import { useQueryClient as d, useMutation as v } from "@tanstack/react-query";
2
+ import { useQueryUnwrapped as l } from "./index61.mjs";
3
+ import { createAdminRpcClients as u, authHeaders as c } from "./index21.mjs";
4
+ import { queryKeys as s } from "./index26.mjs";
5
+ import { useApiConfig as y } from "./index19.mjs";
6
+ function m(n, r) {
7
+ const { baseURL: o, authToken: t } = y();
8
+ return l({
9
+ queryKey: s.admin.inventory.list(n),
10
+ queryFn: async () => {
11
+ const e = await u(o).inventory.index.$get({ query: n }, c(t));
12
+ if (!e.ok) throw new Error(`Failed to fetch inventory: ${e.statusText}`);
13
+ return e.json();
14
+ },
15
+ ...r
16
+ });
17
+ }
18
+ function T(n) {
19
+ const { baseURL: r, authToken: o } = y(), t = d();
20
+ return v({
21
+ mutationFn: async (a) => {
22
+ const i = await u(r).inventory.adjust.$post({ json: a }, c(o));
23
+ if (!i.ok) throw new Error(`Failed to adjust inventory: ${i.statusText}`);
24
+ return i.json();
25
+ },
26
+ onSuccess: () => {
27
+ t.invalidateQueries({ queryKey: s.admin.inventory.all }), t.invalidateQueries({ queryKey: s.admin.variants.all }), t.invalidateQueries({ queryKey: s.admin.warehouses.all });
28
+ },
29
+ ...n
30
+ });
31
+ }
32
+ function j(n) {
33
+ const { baseURL: r, authToken: o } = y(), t = d();
34
+ return v({
35
+ mutationFn: async (a) => {
36
+ const i = await u(r).inventory.transfer.$post({ json: a }, c(o));
37
+ if (!i.ok) throw new Error(`Failed to transfer inventory: ${i.statusText}`);
38
+ return i.json();
39
+ },
40
+ onSuccess: () => {
41
+ t.invalidateQueries({ queryKey: s.admin.inventory.all }), t.invalidateQueries({ queryKey: s.admin.warehouses.all });
42
+ },
43
+ ...n
44
+ });
45
+ }
46
+ function F(n, r) {
47
+ const { baseURL: o, authToken: t } = y();
48
+ return l({
49
+ queryKey: s.admin.inventory.transactions(n),
50
+ queryFn: async () => {
51
+ const e = await u(o).inventory.transactions.$get({ query: n }, c(t));
52
+ if (!e.ok) throw new Error(`Failed to fetch inventory transactions: ${e.statusText}`);
53
+ return e.json();
54
+ },
55
+ ...r
56
+ });
57
+ }
58
+ function $(n, r) {
59
+ const { baseURL: o, authToken: t } = y();
60
+ return l({
61
+ queryKey: s.admin.inventory.lowStock(n == null ? void 0 : n.brandId),
62
+ queryFn: async () => {
63
+ const e = await u(o).inventory["low-stock"].$get({ query: n }, c(t));
64
+ if (!e.ok) throw new Error(`Failed to fetch low stock alerts: ${e.statusText}`);
65
+ return e.json();
66
+ },
67
+ ...r
68
+ });
69
+ }
70
+ export {
71
+ T as useAdjustInventory,
72
+ F as useGetInventoryTransactions,
73
+ $ as useGetLowStockVariants,
74
+ m as useListInventory,
75
+ j as useTransferInventory
76
+ };
@@ -0,0 +1,20 @@
1
+ import { useQueryUnwrapped as i } from "./index61.mjs";
2
+ import { createAdminRpcClients as n, authHeaders as u } from "./index21.mjs";
3
+ import { queryKeys as m } from "./index26.mjs";
4
+ import { useApiConfig as a } from "./index19.mjs";
5
+ function h(e, t) {
6
+ const { baseURL: s, authToken: o } = a();
7
+ return i({
8
+ queryKey: m.admin.customers.history(e),
9
+ queryFn: async () => {
10
+ const r = await n(s).customers.history.$get({ query: { phone: e } }, u(o));
11
+ if (!r.ok) throw new Error(`Failed to fetch customer history: ${r.statusText}`);
12
+ return r.json();
13
+ },
14
+ enabled: !!e,
15
+ ...t
16
+ });
17
+ }
18
+ export {
19
+ h as useGetCustomerHistory
20
+ };
@@ -0,0 +1,19 @@
1
+ import { useQueryUnwrapped as s } from "./index61.mjs";
2
+ import { createAdminRpcClients as i, authHeaders as u } from "./index21.mjs";
3
+ import { queryKeys as c } from "./index26.mjs";
4
+ import { useApiConfig as d } from "./index19.mjs";
5
+ function h(t, r) {
6
+ const { baseURL: n, authToken: o } = d();
7
+ return s({
8
+ queryKey: c.admin.stats.overview(t == null ? void 0 : t.brandId),
9
+ queryFn: async () => {
10
+ const e = await i(n).stats.index.$get({ query: t }, u(o));
11
+ if (!e.ok) throw new Error(`Failed to fetch statistics: ${e.statusText}`);
12
+ return e.json();
13
+ },
14
+ ...r
15
+ });
16
+ }
17
+ export {
18
+ h as useGetStats
19
+ };
@@ -0,0 +1,64 @@
1
+ import { useQueryClient as l, useMutation as y } from "@tanstack/react-query";
2
+ import { useQueryUnwrapped as c } from "./index61.mjs";
3
+ import { createAdminRpcClients as s, authHeaders as o } from "./index21.mjs";
4
+ import { queryKeys as i } from "./index26.mjs";
5
+ import { useApiConfig as u } from "./index19.mjs";
6
+ function m(e, n) {
7
+ const { baseURL: a, authToken: r } = u();
8
+ return c({
9
+ queryKey: i.admin.abandonedCarts.list(e),
10
+ queryFn: async () => {
11
+ const t = await s(a).abandonedCarts.index.$get({ query: e }, o(r));
12
+ if (!t.ok) throw new Error(`Failed to fetch abandoned carts: ${t.statusText}`);
13
+ return t.json();
14
+ },
15
+ ...n
16
+ });
17
+ }
18
+ function p(e, n) {
19
+ const { baseURL: a, authToken: r } = u();
20
+ return c({
21
+ queryKey: i.admin.abandonedCarts.stats(e == null ? void 0 : e.brandId),
22
+ queryFn: async () => {
23
+ const t = await s(a).abandonedCarts.stats.$get({ query: e }, o(r));
24
+ if (!t.ok) throw new Error(`Failed to fetch abandoned cart stats: ${t.statusText}`);
25
+ return t.json();
26
+ },
27
+ ...n
28
+ });
29
+ }
30
+ function q(e, n) {
31
+ const { baseURL: a, authToken: r } = u();
32
+ return c({
33
+ queryKey: i.admin.abandonedCarts.detail(e),
34
+ queryFn: async () => {
35
+ const t = await s(a).abandonedCarts[":id"].$get(
36
+ { param: { id: e } },
37
+ o(r)
38
+ );
39
+ if (!t.ok) throw new Error(`Failed to fetch abandoned cart: ${t.statusText}`);
40
+ return t.json();
41
+ },
42
+ ...n
43
+ });
44
+ }
45
+ function k(e) {
46
+ const { baseURL: n, authToken: a } = u(), r = l();
47
+ return y({
48
+ mutationFn: async () => {
49
+ const t = await s(n).abandonedCarts.cleanup.$post({}, o(a));
50
+ if (!t.ok) throw new Error(`Failed to cleanup expired carts: ${t.statusText}`);
51
+ return t.json();
52
+ },
53
+ onSuccess: () => {
54
+ r.invalidateQueries({ queryKey: i.admin.abandonedCarts.all });
55
+ },
56
+ ...e
57
+ });
58
+ }
59
+ export {
60
+ k as useCleanupExpiredCarts,
61
+ q as useGetAbandonedCart,
62
+ p as useGetAbandonedCartStats,
63
+ m as useListAbandonedCarts
64
+ };
@@ -0,0 +1,131 @@
1
+ import { useQueryClient as l, useMutation as y } from "@tanstack/react-query";
2
+ import { useQueryUnwrapped as C } from "./index61.mjs";
3
+ import { createAdminRpcClients as c, authHeaders as a } from "./index21.mjs";
4
+ import { queryKeys as r } from "./index26.mjs";
5
+ import { useApiConfig as d } from "./index19.mjs";
6
+ function p(e, n) {
7
+ const { baseURL: s, authToken: i } = d();
8
+ return C({
9
+ queryKey: r.admin.discountCodes.list(e),
10
+ queryFn: async () => {
11
+ const t = await c(s).discountCodes.index.$get({ query: e }, a(i));
12
+ if (!t.ok) throw new Error(`Failed to fetch discount codes: ${t.statusText}`);
13
+ return t.json();
14
+ },
15
+ ...n
16
+ });
17
+ }
18
+ function F(e, n) {
19
+ const { baseURL: s, authToken: i } = d();
20
+ return C({
21
+ queryKey: r.admin.discountCodes.detail(e),
22
+ queryFn: async () => {
23
+ const t = await c(s).discountCodes[":id"].$get(
24
+ { param: { id: e } },
25
+ a(i)
26
+ );
27
+ if (!t.ok) throw new Error(`Failed to fetch discount code: ${t.statusText}`);
28
+ return t.json();
29
+ },
30
+ ...n
31
+ });
32
+ }
33
+ function T(e) {
34
+ const { baseURL: n, authToken: s } = d(), i = l();
35
+ return y({
36
+ mutationFn: async (o) => {
37
+ const u = await c(n).discountCodes.index.$post({ json: o }, a(s));
38
+ if (!u.ok) throw new Error(`Failed to create discount code: ${u.statusText}`);
39
+ return u.json();
40
+ },
41
+ onSuccess: () => {
42
+ i.invalidateQueries({ queryKey: r.admin.discountCodes.all });
43
+ },
44
+ ...e
45
+ });
46
+ }
47
+ function $(e, n) {
48
+ const { baseURL: s, authToken: i } = d(), o = l();
49
+ return y({
50
+ mutationFn: async (t) => {
51
+ const w = await c(s).discountCodes[":id"].$patch(
52
+ { json: t, param: { id: e } },
53
+ a(i)
54
+ );
55
+ if (!w.ok) throw new Error(`Failed to update discount code: ${w.statusText}`);
56
+ return w.json();
57
+ },
58
+ onSuccess: () => {
59
+ o.invalidateQueries({ queryKey: r.admin.discountCodes.detail(e) }), o.invalidateQueries({ queryKey: r.admin.discountCodes.all });
60
+ },
61
+ ...n
62
+ });
63
+ }
64
+ function v(e, n) {
65
+ const { baseURL: s, authToken: i } = d(), o = l();
66
+ return y({
67
+ mutationFn: async () => {
68
+ const u = await c(s).discountCodes[":id"].$delete(
69
+ { param: { id: e } },
70
+ a(i)
71
+ );
72
+ if (!u.ok) throw new Error(`Failed to delete discount code: ${u.statusText}`);
73
+ return u.json();
74
+ },
75
+ onSuccess: () => {
76
+ o.invalidateQueries({ queryKey: r.admin.discountCodes.all });
77
+ },
78
+ ...n
79
+ });
80
+ }
81
+ function j(e, n) {
82
+ const { baseURL: s, authToken: i } = d();
83
+ return C({
84
+ queryKey: r.admin.discountCodes.analytics(e),
85
+ queryFn: async () => {
86
+ const t = await c(s).discountCodes[":id"].analytics.$get(
87
+ { param: { id: e } },
88
+ a(i)
89
+ );
90
+ if (!t.ok) throw new Error(`Failed to fetch discount code analytics: ${t.statusText}`);
91
+ return t.json();
92
+ },
93
+ ...n
94
+ });
95
+ }
96
+ function x(e) {
97
+ const { baseURL: n, authToken: s } = d(), i = l();
98
+ return y({
99
+ mutationFn: async (o) => {
100
+ const u = await c(n).discountCodes["bulk-generate"].$post({ json: o }, a(s));
101
+ if (!u.ok) throw new Error(`Failed to bulk generate discount codes: ${u.statusText}`);
102
+ return u.json();
103
+ },
104
+ onSuccess: () => {
105
+ i.invalidateQueries({ queryKey: r.admin.discountCodes.all });
106
+ },
107
+ ...e
108
+ });
109
+ }
110
+ function b(e) {
111
+ const { baseURL: n, authToken: s } = d();
112
+ return C({
113
+ queryKey: r.admin.discountCodes.overviewStats(),
114
+ queryFn: async () => {
115
+ const o = await c(n).discountCodes.stats.overview.$get({}, a(s));
116
+ if (!o.ok) throw new Error(`Failed to fetch discount code overview stats: ${o.statusText}`);
117
+ return o.json();
118
+ },
119
+ ...e
120
+ });
121
+ }
122
+ export {
123
+ x as useBulkGenerateDiscountCodes,
124
+ T as useCreateDiscountCode,
125
+ v as useDeleteDiscountCode,
126
+ F as useGetDiscountCode,
127
+ j as useGetDiscountCodeAnalytics,
128
+ b as useGetDiscountCodeOverviewStats,
129
+ p as useListDiscountCodes,
130
+ $ as useUpdateDiscountCode
131
+ };
@@ -0,0 +1,135 @@
1
+ import { useQueryClient as y, useMutation as v } from "@tanstack/react-query";
2
+ import { useQueryUnwrapped as m } from "./index61.mjs";
3
+ import { createAdminRpcClients as u, authHeaders as l } from "./index21.mjs";
4
+ import { queryKeys as o } from "./index26.mjs";
5
+ import { useApiConfig as c } from "./index19.mjs";
6
+ function p(t) {
7
+ const { baseURL: s, authToken: i } = c();
8
+ return m({
9
+ queryKey: o.admin.deliveryZones.states.list(),
10
+ queryFn: async () => {
11
+ const e = await u(s).deliveryZones.states.$get({}, l(i));
12
+ if (!e.ok) throw new Error(`Failed to fetch states: ${e.statusText}`);
13
+ return e.json();
14
+ },
15
+ ...t
16
+ });
17
+ }
18
+ function k(t) {
19
+ const { baseURL: s, authToken: i } = c(), r = y();
20
+ return v({
21
+ mutationFn: async (e) => {
22
+ const n = await u(s).deliveryZones.states.$post({ json: e }, l(i));
23
+ if (!n.ok) throw new Error(`Failed to create state: ${n.statusText}`);
24
+ return n.json();
25
+ },
26
+ onSuccess: () => {
27
+ r.invalidateQueries({ queryKey: o.admin.deliveryZones.states.all });
28
+ },
29
+ ...t
30
+ });
31
+ }
32
+ function F(t, s) {
33
+ const { baseURL: i, authToken: r } = c(), e = y();
34
+ return v({
35
+ mutationFn: async (a) => {
36
+ const d = await u(i).deliveryZones.states[":id"].$patch(
37
+ { json: a, param: { id: t } },
38
+ l(r)
39
+ );
40
+ if (!d.ok) throw new Error(`Failed to update state: ${d.statusText}`);
41
+ return d.json();
42
+ },
43
+ onSuccess: () => {
44
+ e.invalidateQueries({ queryKey: o.admin.deliveryZones.states.detail(t) }), e.invalidateQueries({ queryKey: o.admin.deliveryZones.states.all });
45
+ },
46
+ ...s
47
+ });
48
+ }
49
+ function T(t, s) {
50
+ const { baseURL: i, authToken: r } = c(), e = y();
51
+ return v({
52
+ mutationFn: async () => {
53
+ const n = await u(i).deliveryZones.states[":id"].$delete(
54
+ { param: { id: t } },
55
+ l(r)
56
+ );
57
+ if (!n.ok) throw new Error(`Failed to delete state: ${n.statusText}`);
58
+ return n.json();
59
+ },
60
+ onSuccess: () => {
61
+ e.invalidateQueries({ queryKey: o.admin.deliveryZones.states.all }), e.invalidateQueries({ queryKey: o.admin.deliveryZones.zones.all });
62
+ },
63
+ ...s
64
+ });
65
+ }
66
+ function $(t, s) {
67
+ const { baseURL: i, authToken: r } = c();
68
+ return m({
69
+ queryKey: o.admin.deliveryZones.zones.list(t),
70
+ queryFn: async () => {
71
+ const a = await u(i).deliveryZones.zones.$get({ query: t }, l(r));
72
+ if (!a.ok) throw new Error(`Failed to fetch delivery zones: ${a.statusText}`);
73
+ return a.json();
74
+ },
75
+ ...s
76
+ });
77
+ }
78
+ function z(t) {
79
+ const { baseURL: s, authToken: i } = c(), r = y();
80
+ return v({
81
+ mutationFn: async (e) => {
82
+ const n = await u(s).deliveryZones.zones.$post({ json: e }, l(i));
83
+ if (!n.ok) throw new Error(`Failed to create delivery zone: ${n.statusText}`);
84
+ return n.json();
85
+ },
86
+ onSuccess: () => {
87
+ r.invalidateQueries({ queryKey: o.admin.deliveryZones.zones.all }), r.invalidateQueries({ queryKey: o.admin.deliveryZones.states.all });
88
+ },
89
+ ...t
90
+ });
91
+ }
92
+ function K(t, s) {
93
+ const { baseURL: i, authToken: r } = c(), e = y();
94
+ return v({
95
+ mutationFn: async (a) => {
96
+ const d = await u(i).deliveryZones.zones[":id"].$patch(
97
+ { json: a, param: { id: t } },
98
+ l(r)
99
+ );
100
+ if (!d.ok) throw new Error(`Failed to update delivery zone: ${d.statusText}`);
101
+ return d.json();
102
+ },
103
+ onSuccess: () => {
104
+ e.invalidateQueries({ queryKey: o.admin.deliveryZones.zones.detail(t) }), e.invalidateQueries({ queryKey: o.admin.deliveryZones.zones.all });
105
+ },
106
+ ...s
107
+ });
108
+ }
109
+ function j(t, s) {
110
+ const { baseURL: i, authToken: r } = c(), e = y();
111
+ return v({
112
+ mutationFn: async () => {
113
+ const n = await u(i).deliveryZones.zones[":id"].$delete(
114
+ { param: { id: t } },
115
+ l(r)
116
+ );
117
+ if (!n.ok) throw new Error(`Failed to delete delivery zone: ${n.statusText}`);
118
+ return n.json();
119
+ },
120
+ onSuccess: () => {
121
+ e.invalidateQueries({ queryKey: o.admin.deliveryZones.zones.all });
122
+ },
123
+ ...s
124
+ });
125
+ }
126
+ export {
127
+ z as useCreateDeliveryZone,
128
+ k as useCreateState,
129
+ j as useDeleteDeliveryZone,
130
+ T as useDeleteState,
131
+ $ as useListDeliveryZones,
132
+ p as useListStates,
133
+ K as useUpdateDeliveryZone,
134
+ F as useUpdateState
135
+ };
@@ -0,0 +1,77 @@
1
+ function c(e) {
2
+ this._maxSize = e, this.clear();
3
+ }
4
+ c.prototype.clear = function() {
5
+ this._size = 0, this._values = /* @__PURE__ */ Object.create(null);
6
+ };
7
+ c.prototype.get = function(e) {
8
+ return this._values[e];
9
+ };
10
+ c.prototype.set = function(e, t) {
11
+ return this._size >= this._maxSize && this.clear(), e in this._values || this._size++, this._values[e] = t;
12
+ };
13
+ var d = /[^.^\]^[]+|(?=\[\]|\.\.)/g, C = /^\d+$/, m = /^\d/, A = /[~`!#$%\^&*+=\-\[\]\\';,/{}|\\":<>\?]/g, x = /^\s*(['"]?)(.*?)(\1)\s*$/, h = 512, E = new c(h), v = new c(h), g = new c(h), I = {
14
+ Cache: c,
15
+ split: l,
16
+ normalizePath: f,
17
+ setter: function(e) {
18
+ var t = f(e);
19
+ return v.get(e) || v.set(e, function(s, n) {
20
+ for (var r = 0, o = t.length, u = s; r < o - 1; ) {
21
+ var a = t[r];
22
+ if (a === "__proto__" || a === "constructor" || a === "prototype")
23
+ return s;
24
+ u = u[t[r++]];
25
+ }
26
+ u[t[r]] = n;
27
+ });
28
+ },
29
+ getter: function(e, t) {
30
+ var i = f(e);
31
+ return g.get(e) || g.set(e, function(n) {
32
+ for (var r = 0, o = i.length; r < o; )
33
+ if (n != null || !t) n = n[i[r++]];
34
+ else return;
35
+ return n;
36
+ });
37
+ },
38
+ join: function(e) {
39
+ return e.reduce(function(t, i) {
40
+ return t + (_(i) || C.test(i) ? "[" + i + "]" : (t ? "." : "") + i);
41
+ }, "");
42
+ },
43
+ forEach: function(e, t, i) {
44
+ y(Array.isArray(e) ? e : l(e), t, i);
45
+ }
46
+ };
47
+ function f(e) {
48
+ return E.get(e) || E.set(
49
+ e,
50
+ l(e).map(function(t) {
51
+ return t.replace(x, "$2");
52
+ })
53
+ );
54
+ }
55
+ function l(e) {
56
+ return e.match(d) || [""];
57
+ }
58
+ function y(e, t, i) {
59
+ var s = e.length, n, r, o, u;
60
+ for (r = 0; r < s; r++)
61
+ n = e[r], n && (S(n) && (n = '"' + n + '"'), u = _(n), o = !u && /^\d+$/.test(n), t.call(i, n, u, o, r, e));
62
+ }
63
+ function _(e) {
64
+ return typeof e == "string" && e && ["'", '"'].indexOf(e.charAt(0)) !== -1;
65
+ }
66
+ function z(e) {
67
+ return e.match(m) && !e.match(C);
68
+ }
69
+ function G(e) {
70
+ return A.test(e);
71
+ }
72
+ function S(e) {
73
+ return !_(e) && (z(e) || G(e));
74
+ }
75
+ export {
76
+ I as p
77
+ };
@@ -0,0 +1,17 @@
1
+ const c = /[A-Z\xc0-\xd6\xd8-\xde]?[a-z\xdf-\xf6\xf8-\xff]+(?:['’](?:d|ll|m|re|s|t|ve))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde]|$)|(?:[A-Z\xc0-\xd6\xd8-\xde]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:D|LL|M|RE|S|T|VE))?(?=[\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000]|[A-Z\xc0-\xd6\xd8-\xde](?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])|$)|[A-Z\xc0-\xd6\xd8-\xde]?(?:[a-z\xdf-\xf6\xf8-\xff]|[^\ud800-\udfff\xac\xb1\xd7\xf7\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\xbf\u2000-\u206f \t\x0b\f\xa0\ufeff\n\r\u2028\u2029\u1680\u180e\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200a\u202f\u205f\u3000\d+\u2700-\u27bfa-z\xdf-\xf6\xf8-\xffA-Z\xc0-\xd6\xd8-\xde])+(?:['’](?:d|ll|m|re|s|t|ve))?|[A-Z\xc0-\xd6\xd8-\xde]+(?:['’](?:D|LL|M|RE|S|T|VE))?|\d*(?:1ST|2ND|3RD|(?![123])\dTH)(?=\b|[a-z_])|\d*(?:1st|2nd|3rd|(?![123])\dth)(?=\b|[A-Z_])|\d+|(?:[\u2700-\u27bf]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?(?:\u200d(?:[^\ud800-\udfff]|(?:\ud83c[\udde6-\uddff]){2}|[\ud800-\udbff][\udc00-\udfff])[\ufe0e\ufe0f]?(?:[\u0300-\u036f\ufe20-\ufe2f\u20d0-\u20ff]|\ud83c[\udffb-\udfff])?)*/g, x = (u) => u.match(c) || [], d = (u) => u[0].toUpperCase() + u.slice(1), a = (u, f) => x(u).join(f).toLowerCase(), b = (u) => x(u).reduce(
2
+ (f, e) => `${f}${f ? e[0].toUpperCase() + e.slice(1).toLowerCase() : e.toLowerCase()}`,
3
+ ""
4
+ ), s = (u) => d(b(u)), t = (u) => a(u, "_"), o = (u) => a(u, "-"), n = (u) => d(a(u, " ")), r = (u) => x(u).map(d).join(" ");
5
+ var C = {
6
+ words: x,
7
+ upperFirst: d,
8
+ camelCase: b,
9
+ pascalCase: s,
10
+ snakeCase: t,
11
+ kebabCase: o,
12
+ sentenceCase: n,
13
+ titleCase: r
14
+ };
15
+ export {
16
+ C as t
17
+ };