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