@instockng/api-client 1.0.34 → 1.0.36
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/dist/backend-types.d.ts +1 -1
- package/dist/fetchers/brands.d.ts +1 -0
- package/dist/fetchers/carts.d.ts +185 -152
- package/dist/fetchers/delivery-zones.d.ts +0 -1
- package/dist/fetchers/orders.d.ts +55 -30
- package/dist/hooks/admin/abandoned-carts.d.ts +36 -34
- package/dist/hooks/admin/brands.d.ts +4 -0
- package/dist/hooks/admin/customers.d.ts +14 -14
- package/dist/hooks/admin/delivery-zones.d.ts +12 -8
- package/dist/hooks/admin/discount-codes.d.ts +20 -15
- package/dist/hooks/admin/index.d.ts +1 -0
- package/dist/hooks/admin/index.js +1 -0
- package/dist/hooks/admin/orders.d.ts +79 -78
- package/dist/hooks/admin/products.d.ts +54 -4
- package/dist/hooks/admin/sales.d.ts +46 -0
- package/dist/hooks/admin/sales.js +180 -0
- package/dist/hooks/admin/stats.d.ts +14 -14
- package/dist/hooks/admin/variants.d.ts +13 -6
- package/dist/hooks/admin/variants.js +6 -5
- package/dist/hooks/admin/warehouses.d.ts +7 -6
- package/dist/hooks/public/brands.d.ts +1 -0
- package/dist/hooks/public/carts.d.ts +185 -152
- package/dist/hooks/public/delivery-zones.d.ts +0 -1
- package/dist/hooks/public/orders.d.ts +55 -30
- package/dist/rpc-client.d.ts +1121 -427
- package/dist/rpc-client.js +1 -0
- package/dist/rpc-types.d.ts +81 -6
- package/dist/utils/query-keys.d.ts +6 -0
- package/dist/utils/query-keys.js +6 -0
- package/package.json +1 -1
|
@@ -4,6 +4,10 @@
|
|
|
4
4
|
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
5
5
|
import { createAdminRpcClients } from '../../rpc-client';
|
|
6
6
|
export declare function useListProducts(brandId?: string, options?: Omit<UseQueryOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['products']['index']['$get']>>['json']>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
|
|
7
|
+
isOnSale: boolean;
|
|
8
|
+
saleId: string;
|
|
9
|
+
saleName: string;
|
|
10
|
+
saleEndsAt: string;
|
|
7
11
|
id: string;
|
|
8
12
|
name: string;
|
|
9
13
|
slug: string;
|
|
@@ -164,6 +168,7 @@ export declare function useListProducts(brandId?: string, options?: Omit<UseQuer
|
|
|
164
168
|
metaPixelId: string;
|
|
165
169
|
tiktokPixelId: string;
|
|
166
170
|
paystackPublicKey: string;
|
|
171
|
+
freeShippingThreshold: number;
|
|
167
172
|
createdAt: string;
|
|
168
173
|
updatedAt: string;
|
|
169
174
|
deletedAt: string;
|
|
@@ -174,10 +179,11 @@ export declare function useListProducts(brandId?: string, options?: Omit<UseQuer
|
|
|
174
179
|
price: number;
|
|
175
180
|
compareAtPrice: number;
|
|
176
181
|
deletedAt: string;
|
|
182
|
+
thumbnailUrl: string;
|
|
183
|
+
originalPrice: number;
|
|
177
184
|
id: string;
|
|
178
185
|
name: string | null;
|
|
179
186
|
isActive: boolean;
|
|
180
|
-
thumbnailUrl: string | null;
|
|
181
187
|
productId: string;
|
|
182
188
|
sku: string;
|
|
183
189
|
trackInventory: boolean;
|
|
@@ -474,13 +480,36 @@ export declare function useListProducts(brandId?: string, options?: Omit<UseQuer
|
|
|
474
480
|
flat?: boolean;
|
|
475
481
|
};
|
|
476
482
|
};
|
|
483
|
+
sales: {
|
|
484
|
+
sale: {
|
|
485
|
+
id: string;
|
|
486
|
+
name: string;
|
|
487
|
+
createdAt: string;
|
|
488
|
+
updatedAt: string;
|
|
489
|
+
deletedAt: string;
|
|
490
|
+
isActive: boolean;
|
|
491
|
+
brandId: string;
|
|
492
|
+
discountType: import("@prisma/client").$Enums.DiscountType;
|
|
493
|
+
discountValue: string;
|
|
494
|
+
startDate: string;
|
|
495
|
+
endDate: string;
|
|
496
|
+
};
|
|
497
|
+
id: string;
|
|
498
|
+
createdAt: string;
|
|
499
|
+
productId: string;
|
|
500
|
+
saleId: string;
|
|
501
|
+
}[];
|
|
477
502
|
createdAt: string;
|
|
478
503
|
updatedAt: string;
|
|
479
504
|
deletedAt: string;
|
|
480
|
-
brandId: string;
|
|
481
505
|
isActive: boolean;
|
|
506
|
+
brandId: string;
|
|
482
507
|
}[], Error>;
|
|
483
508
|
export declare function useGetProduct(productId: string, options?: Omit<UseQueryOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['products'][':id']['$get']>>['json']>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
|
|
509
|
+
isOnSale: boolean;
|
|
510
|
+
saleId: string;
|
|
511
|
+
saleName: string;
|
|
512
|
+
saleEndsAt: string;
|
|
484
513
|
id: string;
|
|
485
514
|
name: string;
|
|
486
515
|
slug: string;
|
|
@@ -641,6 +670,7 @@ export declare function useGetProduct(productId: string, options?: Omit<UseQuery
|
|
|
641
670
|
metaPixelId: string;
|
|
642
671
|
tiktokPixelId: string;
|
|
643
672
|
paystackPublicKey: string;
|
|
673
|
+
freeShippingThreshold: number;
|
|
644
674
|
createdAt: string;
|
|
645
675
|
updatedAt: string;
|
|
646
676
|
deletedAt: string;
|
|
@@ -651,10 +681,11 @@ export declare function useGetProduct(productId: string, options?: Omit<UseQuery
|
|
|
651
681
|
price: number;
|
|
652
682
|
compareAtPrice: number;
|
|
653
683
|
deletedAt: string;
|
|
684
|
+
thumbnailUrl: string;
|
|
685
|
+
originalPrice: number;
|
|
654
686
|
id: string;
|
|
655
687
|
name: string | null;
|
|
656
688
|
isActive: boolean;
|
|
657
|
-
thumbnailUrl: string | null;
|
|
658
689
|
productId: string;
|
|
659
690
|
sku: string;
|
|
660
691
|
trackInventory: boolean;
|
|
@@ -951,11 +982,30 @@ export declare function useGetProduct(productId: string, options?: Omit<UseQuery
|
|
|
951
982
|
flat?: boolean;
|
|
952
983
|
};
|
|
953
984
|
};
|
|
985
|
+
sales: {
|
|
986
|
+
sale: {
|
|
987
|
+
id: string;
|
|
988
|
+
name: string;
|
|
989
|
+
createdAt: string;
|
|
990
|
+
updatedAt: string;
|
|
991
|
+
deletedAt: string;
|
|
992
|
+
isActive: boolean;
|
|
993
|
+
brandId: string;
|
|
994
|
+
discountType: import("@prisma/client").$Enums.DiscountType;
|
|
995
|
+
discountValue: string;
|
|
996
|
+
startDate: string;
|
|
997
|
+
endDate: string;
|
|
998
|
+
};
|
|
999
|
+
id: string;
|
|
1000
|
+
createdAt: string;
|
|
1001
|
+
productId: string;
|
|
1002
|
+
saleId: string;
|
|
1003
|
+
}[];
|
|
954
1004
|
createdAt: string;
|
|
955
1005
|
updatedAt: string;
|
|
956
1006
|
deletedAt: string;
|
|
957
|
-
brandId: string;
|
|
958
1007
|
isActive: boolean;
|
|
1008
|
+
brandId: string;
|
|
959
1009
|
}, Error>;
|
|
960
1010
|
export declare function useCreateProduct(options?: UseMutationOptions<any, Error, any>): import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
|
|
961
1011
|
export declare function useUpdateProduct(productId: string, options?: UseMutationOptions<any, Error, any>): import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe admin RPC hooks for sales management
|
|
3
|
+
*/
|
|
4
|
+
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
5
|
+
/**
|
|
6
|
+
* Hook to list sales using admin RPC
|
|
7
|
+
*/
|
|
8
|
+
export declare function useListSales(params?: {
|
|
9
|
+
page?: number;
|
|
10
|
+
limit?: number;
|
|
11
|
+
brandId?: string;
|
|
12
|
+
status?: 'active' | 'scheduled' | 'ended' | 'inactive';
|
|
13
|
+
search?: string;
|
|
14
|
+
}, options?: Omit<UseQueryOptions<any, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
15
|
+
/**
|
|
16
|
+
* Hook to get sale by ID using admin RPC
|
|
17
|
+
*/
|
|
18
|
+
export declare function useGetSale(saleId: string, options?: Omit<UseQueryOptions<any, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
19
|
+
/**
|
|
20
|
+
* Hook to create a sale using admin RPC
|
|
21
|
+
*/
|
|
22
|
+
export declare function useCreateSale(options?: UseMutationOptions<any, Error, any>): import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
|
|
23
|
+
/**
|
|
24
|
+
* Hook to update a sale using admin RPC
|
|
25
|
+
*/
|
|
26
|
+
export declare function useUpdateSale(saleId: string, options?: UseMutationOptions<any, Error, any>): import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
|
|
27
|
+
/**
|
|
28
|
+
* Hook to delete a sale using admin RPC
|
|
29
|
+
*/
|
|
30
|
+
export declare function useDeleteSale(saleId: string, options?: UseMutationOptions<void, Error, void>): import("@tanstack/react-query").UseMutationResult<void, Error, void, unknown>;
|
|
31
|
+
/**
|
|
32
|
+
* Hook to add products to a sale using admin RPC
|
|
33
|
+
*/
|
|
34
|
+
export declare function useAddProductsToSale(saleId: string, options?: UseMutationOptions<any, Error, {
|
|
35
|
+
productIds: string[];
|
|
36
|
+
}>): import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
37
|
+
productIds: string[];
|
|
38
|
+
}, unknown>;
|
|
39
|
+
/**
|
|
40
|
+
* Hook to remove a product from a sale using admin RPC
|
|
41
|
+
*/
|
|
42
|
+
export declare function useRemoveProductFromSale(saleId: string, options?: UseMutationOptions<void, Error, string>): import("@tanstack/react-query").UseMutationResult<void, Error, string, unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* Hook to get sales overview stats using admin RPC
|
|
45
|
+
*/
|
|
46
|
+
export declare function useGetSalesOverviewStats(options?: Omit<UseQueryOptions<any, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type-safe admin RPC hooks for sales management
|
|
3
|
+
*/
|
|
4
|
+
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
5
|
+
import { useQueryUnwrapped } from '../use-query-unwrapped';
|
|
6
|
+
import { createAdminRpcClients, authHeaders } from '../../rpc-client';
|
|
7
|
+
import { queryKeys } from '../../utils/query-keys';
|
|
8
|
+
import { useApiConfig } from '../useApiConfig';
|
|
9
|
+
/**
|
|
10
|
+
* Hook to list sales using admin RPC
|
|
11
|
+
*/
|
|
12
|
+
export function useListSales(params, options) {
|
|
13
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
14
|
+
return useQueryUnwrapped({
|
|
15
|
+
queryKey: queryKeys.admin.sales.list(params),
|
|
16
|
+
queryFn: async () => {
|
|
17
|
+
const token = await getAuthToken();
|
|
18
|
+
const clients = createAdminRpcClients(baseURL);
|
|
19
|
+
const res = await clients.sales.index.$get({ query: params }, authHeaders(token));
|
|
20
|
+
if (!res.ok)
|
|
21
|
+
throw new Error(`Failed to fetch sales: ${res.statusText}`);
|
|
22
|
+
return res.json();
|
|
23
|
+
},
|
|
24
|
+
...options,
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Hook to get sale by ID using admin RPC
|
|
29
|
+
*/
|
|
30
|
+
export function useGetSale(saleId, options) {
|
|
31
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
32
|
+
return useQueryUnwrapped({
|
|
33
|
+
queryKey: queryKeys.admin.sales.detail(saleId),
|
|
34
|
+
queryFn: async () => {
|
|
35
|
+
const token = await getAuthToken();
|
|
36
|
+
const clients = createAdminRpcClients(baseURL);
|
|
37
|
+
const res = await clients.sales[':id'].$get({ param: { id: saleId } }, authHeaders(token));
|
|
38
|
+
if (!res.ok)
|
|
39
|
+
throw new Error(`Failed to fetch sale: ${res.statusText}`);
|
|
40
|
+
return res.json();
|
|
41
|
+
},
|
|
42
|
+
enabled: !!saleId,
|
|
43
|
+
...options,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Hook to create a sale using admin RPC
|
|
48
|
+
*/
|
|
49
|
+
export function useCreateSale(options) {
|
|
50
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
51
|
+
const queryClient = useQueryClient();
|
|
52
|
+
return useMutation({
|
|
53
|
+
mutationFn: async (data) => {
|
|
54
|
+
const token = await getAuthToken();
|
|
55
|
+
const clients = createAdminRpcClients(baseURL);
|
|
56
|
+
const res = await clients.sales.index.$post({ json: data }, authHeaders(token));
|
|
57
|
+
if (!res.ok) {
|
|
58
|
+
const errorData = await res.json();
|
|
59
|
+
throw new Error(errorData?.error?.message || `Failed to create sale: ${res.statusText}`);
|
|
60
|
+
}
|
|
61
|
+
return res.json();
|
|
62
|
+
},
|
|
63
|
+
onSuccess: () => {
|
|
64
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.sales.all });
|
|
65
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.products.all });
|
|
66
|
+
},
|
|
67
|
+
...options,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Hook to update a sale using admin RPC
|
|
72
|
+
*/
|
|
73
|
+
export function useUpdateSale(saleId, options) {
|
|
74
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
75
|
+
const queryClient = useQueryClient();
|
|
76
|
+
return useMutation({
|
|
77
|
+
mutationFn: async (data) => {
|
|
78
|
+
const token = await getAuthToken();
|
|
79
|
+
const clients = createAdminRpcClients(baseURL);
|
|
80
|
+
const res = await clients.sales[':id'].$patch({ json: data, param: { id: saleId } }, authHeaders(token));
|
|
81
|
+
if (!res.ok) {
|
|
82
|
+
const errorData = await res.json();
|
|
83
|
+
throw new Error(errorData?.error?.message || `Failed to update sale: ${res.statusText}`);
|
|
84
|
+
}
|
|
85
|
+
return res.json();
|
|
86
|
+
},
|
|
87
|
+
onSuccess: () => {
|
|
88
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.sales.detail(saleId) });
|
|
89
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.sales.all });
|
|
90
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.products.all });
|
|
91
|
+
},
|
|
92
|
+
...options,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Hook to delete a sale using admin RPC
|
|
97
|
+
*/
|
|
98
|
+
export function useDeleteSale(saleId, options) {
|
|
99
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
100
|
+
const queryClient = useQueryClient();
|
|
101
|
+
return useMutation({
|
|
102
|
+
mutationFn: async () => {
|
|
103
|
+
const token = await getAuthToken();
|
|
104
|
+
const clients = createAdminRpcClients(baseURL);
|
|
105
|
+
const res = await clients.sales[':id'].$delete({ param: { id: saleId } }, authHeaders(token));
|
|
106
|
+
if (!res.ok)
|
|
107
|
+
throw new Error(`Failed to delete sale: ${res.statusText}`);
|
|
108
|
+
},
|
|
109
|
+
onSuccess: () => {
|
|
110
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.sales.all });
|
|
111
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.products.all });
|
|
112
|
+
},
|
|
113
|
+
...options,
|
|
114
|
+
});
|
|
115
|
+
}
|
|
116
|
+
/**
|
|
117
|
+
* Hook to add products to a sale using admin RPC
|
|
118
|
+
*/
|
|
119
|
+
export function useAddProductsToSale(saleId, options) {
|
|
120
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
121
|
+
const queryClient = useQueryClient();
|
|
122
|
+
return useMutation({
|
|
123
|
+
mutationFn: async (data) => {
|
|
124
|
+
const token = await getAuthToken();
|
|
125
|
+
const clients = createAdminRpcClients(baseURL);
|
|
126
|
+
const res = await clients.sales[':id']['products'].$post({ json: data, param: { id: saleId } }, authHeaders(token));
|
|
127
|
+
if (!res.ok) {
|
|
128
|
+
const errorData = await res.json();
|
|
129
|
+
throw new Error(errorData?.error?.message || `Failed to add products to sale: ${res.statusText}`);
|
|
130
|
+
}
|
|
131
|
+
return res.json();
|
|
132
|
+
},
|
|
133
|
+
onSuccess: () => {
|
|
134
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.sales.detail(saleId) });
|
|
135
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.sales.all });
|
|
136
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.products.all });
|
|
137
|
+
},
|
|
138
|
+
...options,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Hook to remove a product from a sale using admin RPC
|
|
143
|
+
*/
|
|
144
|
+
export function useRemoveProductFromSale(saleId, options) {
|
|
145
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
146
|
+
const queryClient = useQueryClient();
|
|
147
|
+
return useMutation({
|
|
148
|
+
mutationFn: async (productId) => {
|
|
149
|
+
const token = await getAuthToken();
|
|
150
|
+
const clients = createAdminRpcClients(baseURL);
|
|
151
|
+
const res = await clients.sales[':id']['products'][':productId'].$delete({ param: { id: saleId, productId } }, authHeaders(token));
|
|
152
|
+
if (!res.ok)
|
|
153
|
+
throw new Error(`Failed to remove product from sale: ${res.statusText}`);
|
|
154
|
+
},
|
|
155
|
+
onSuccess: () => {
|
|
156
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.sales.detail(saleId) });
|
|
157
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.sales.all });
|
|
158
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.products.all });
|
|
159
|
+
},
|
|
160
|
+
...options,
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Hook to get sales overview stats using admin RPC
|
|
165
|
+
*/
|
|
166
|
+
export function useGetSalesOverviewStats(options) {
|
|
167
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
168
|
+
return useQueryUnwrapped({
|
|
169
|
+
queryKey: queryKeys.admin.sales.overviewStats(),
|
|
170
|
+
queryFn: async () => {
|
|
171
|
+
const token = await getAuthToken();
|
|
172
|
+
const clients = createAdminRpcClients(baseURL);
|
|
173
|
+
const res = await clients.sales['stats']['overview'].$get({}, authHeaders(token));
|
|
174
|
+
if (!res.ok)
|
|
175
|
+
throw new Error(`Failed to fetch sales stats: ${res.statusText}`);
|
|
176
|
+
return res.json();
|
|
177
|
+
},
|
|
178
|
+
...options,
|
|
179
|
+
});
|
|
180
|
+
}
|
|
@@ -41,19 +41,19 @@ export declare function useGetStats(params?: {
|
|
|
41
41
|
prospectSince: string;
|
|
42
42
|
lastRecoveryAttemptAt: string;
|
|
43
43
|
brand: {
|
|
44
|
-
createdAt: string;
|
|
45
|
-
updatedAt: string;
|
|
46
|
-
deletedAt: string;
|
|
47
44
|
id: string;
|
|
48
45
|
name: string;
|
|
49
46
|
slug: string;
|
|
50
|
-
logoUrl: string
|
|
47
|
+
logoUrl: string;
|
|
51
48
|
siteUrl: string;
|
|
52
49
|
domain: string;
|
|
53
|
-
metaPixelId: string
|
|
54
|
-
tiktokPixelId: string
|
|
55
|
-
paystackPublicKey: string
|
|
56
|
-
|
|
50
|
+
metaPixelId: string;
|
|
51
|
+
tiktokPixelId: string;
|
|
52
|
+
paystackPublicKey: string;
|
|
53
|
+
freeShippingThreshold: number;
|
|
54
|
+
createdAt: string;
|
|
55
|
+
updatedAt: string;
|
|
56
|
+
deletedAt: string;
|
|
57
57
|
};
|
|
58
58
|
deliveryZone: {
|
|
59
59
|
deliveryCost: number;
|
|
@@ -71,6 +71,7 @@ export declare function useGetStats(params?: {
|
|
|
71
71
|
};
|
|
72
72
|
id: string;
|
|
73
73
|
name: string;
|
|
74
|
+
isActive: boolean;
|
|
74
75
|
brandId: string | null;
|
|
75
76
|
stateId: string;
|
|
76
77
|
allowCOD: boolean;
|
|
@@ -79,7 +80,6 @@ export declare function useGetStats(params?: {
|
|
|
79
80
|
estimatedDays: number | null;
|
|
80
81
|
noteTitle: string | null;
|
|
81
82
|
noteContent: string | null;
|
|
82
|
-
isActive: boolean;
|
|
83
83
|
};
|
|
84
84
|
items: {
|
|
85
85
|
priceAtPurchase: number;
|
|
@@ -95,8 +95,8 @@ export declare function useGetStats(params?: {
|
|
|
95
95
|
id: string;
|
|
96
96
|
name: string;
|
|
97
97
|
slug: string;
|
|
98
|
-
brandId: string;
|
|
99
98
|
isActive: boolean;
|
|
99
|
+
brandId: string;
|
|
100
100
|
description: string | null;
|
|
101
101
|
thumbnailUrl: string | null;
|
|
102
102
|
quantityDiscounts: string | number | boolean | {
|
|
@@ -539,8 +539,8 @@ export declare function useGetStats(params?: {
|
|
|
539
539
|
id: string;
|
|
540
540
|
name: string | null;
|
|
541
541
|
isActive: boolean;
|
|
542
|
-
thumbnailUrl: string | null;
|
|
543
542
|
productId: string;
|
|
543
|
+
thumbnailUrl: string | null;
|
|
544
544
|
sku: string;
|
|
545
545
|
compareAtPrice: string;
|
|
546
546
|
trackInventory: boolean;
|
|
@@ -552,16 +552,16 @@ export declare function useGetStats(params?: {
|
|
|
552
552
|
deletedAt: string;
|
|
553
553
|
id: string;
|
|
554
554
|
name: string;
|
|
555
|
+
state: string | null;
|
|
555
556
|
isActive: boolean;
|
|
556
557
|
address: string | null;
|
|
557
558
|
city: string | null;
|
|
558
|
-
state: string | null;
|
|
559
559
|
};
|
|
560
560
|
id: string;
|
|
561
|
-
orderId: string;
|
|
562
561
|
variantId: string;
|
|
563
|
-
warehouseId: string | null;
|
|
564
562
|
quantity: number;
|
|
563
|
+
orderId: string;
|
|
564
|
+
warehouseId: string | null;
|
|
565
565
|
}[];
|
|
566
566
|
email: string | null;
|
|
567
567
|
id: string;
|
|
@@ -15,10 +15,11 @@ export declare function useSearchVariants(params?: {
|
|
|
15
15
|
price: number;
|
|
16
16
|
compareAtPrice: number;
|
|
17
17
|
deletedAt: string;
|
|
18
|
+
thumbnailUrl: string;
|
|
19
|
+
originalPrice: number;
|
|
18
20
|
id: string;
|
|
19
21
|
name: string | null;
|
|
20
22
|
isActive: boolean;
|
|
21
|
-
thumbnailUrl: string | null;
|
|
22
23
|
productId: string;
|
|
23
24
|
sku: string;
|
|
24
25
|
trackInventory: boolean;
|
|
@@ -33,10 +34,11 @@ export declare function useListProductVariants(productId: string, options?: Omit
|
|
|
33
34
|
price: number;
|
|
34
35
|
compareAtPrice: number;
|
|
35
36
|
deletedAt: string;
|
|
37
|
+
thumbnailUrl: string;
|
|
38
|
+
originalPrice: number;
|
|
36
39
|
id: string;
|
|
37
40
|
name: string | null;
|
|
38
41
|
isActive: boolean;
|
|
39
|
-
thumbnailUrl: string | null;
|
|
40
42
|
productId: string;
|
|
41
43
|
sku: string;
|
|
42
44
|
trackInventory: boolean;
|
|
@@ -51,10 +53,11 @@ export declare function useCreateVariant(productId: string, options?: UseMutatio
|
|
|
51
53
|
price: number;
|
|
52
54
|
compareAtPrice: number;
|
|
53
55
|
deletedAt: string;
|
|
56
|
+
thumbnailUrl: string;
|
|
57
|
+
originalPrice: number;
|
|
54
58
|
id: string;
|
|
55
59
|
name: string | null;
|
|
56
60
|
isActive: boolean;
|
|
57
|
-
thumbnailUrl: string | null;
|
|
58
61
|
productId: string;
|
|
59
62
|
sku: string;
|
|
60
63
|
trackInventory: boolean;
|
|
@@ -68,16 +71,19 @@ export declare function useCreateVariant(productId: string, options?: UseMutatio
|
|
|
68
71
|
/**
|
|
69
72
|
* Hook to update a variant using admin RPC
|
|
70
73
|
*/
|
|
71
|
-
export declare function useUpdateVariant(
|
|
74
|
+
export declare function useUpdateVariant(productId: string, options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['variants']['products'][':productId']['variants'][':variantId']['$patch']>>['json']>>, Error, {
|
|
75
|
+
variantId: string;
|
|
76
|
+
} & any>): import("@tanstack/react-query").UseMutationResult<{
|
|
72
77
|
createdAt: string;
|
|
73
78
|
updatedAt: string;
|
|
74
79
|
price: number;
|
|
75
80
|
compareAtPrice: number;
|
|
76
81
|
deletedAt: string;
|
|
82
|
+
thumbnailUrl: string;
|
|
83
|
+
originalPrice: number;
|
|
77
84
|
id: string;
|
|
78
85
|
name: string | null;
|
|
79
86
|
isActive: boolean;
|
|
80
|
-
thumbnailUrl: string | null;
|
|
81
87
|
productId: string;
|
|
82
88
|
sku: string;
|
|
83
89
|
trackInventory: boolean;
|
|
@@ -98,10 +104,11 @@ export declare function useGetVariantInventory(variantId: string, options?: Omit
|
|
|
98
104
|
price: number;
|
|
99
105
|
compareAtPrice: number;
|
|
100
106
|
deletedAt: string;
|
|
107
|
+
thumbnailUrl: string;
|
|
108
|
+
originalPrice: number;
|
|
101
109
|
id: string;
|
|
102
110
|
name: string | null;
|
|
103
111
|
isActive: boolean;
|
|
104
|
-
thumbnailUrl: string | null;
|
|
105
112
|
productId: string;
|
|
106
113
|
sku: string;
|
|
107
114
|
trackInventory: boolean;
|
|
@@ -67,21 +67,22 @@ export function useCreateVariant(productId, options) {
|
|
|
67
67
|
/**
|
|
68
68
|
* Hook to update a variant using admin RPC
|
|
69
69
|
*/
|
|
70
|
-
export function useUpdateVariant(
|
|
70
|
+
export function useUpdateVariant(productId, options) {
|
|
71
71
|
const { baseURL, getAuthToken } = useApiConfig();
|
|
72
72
|
const queryClient = useQueryClient();
|
|
73
73
|
return useMutation({
|
|
74
|
-
mutationFn: async (data) => {
|
|
74
|
+
mutationFn: async ({ variantId, ...data }) => {
|
|
75
75
|
const token = await getAuthToken();
|
|
76
76
|
const clients = createAdminRpcClients(baseURL);
|
|
77
|
-
const res = await clients.variants[':
|
|
77
|
+
const res = await clients.variants.products[':productId'].variants[':variantId'].$patch({ json: data, param: { productId, variantId } }, authHeaders(token));
|
|
78
78
|
if (!res.ok)
|
|
79
79
|
throw new Error(`Failed to update variant: ${res.statusText}`);
|
|
80
80
|
return res.json();
|
|
81
81
|
},
|
|
82
|
-
onSuccess: () => {
|
|
83
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.admin.variants.detail(variantId) });
|
|
82
|
+
onSuccess: (_data, variables) => {
|
|
83
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.variants.detail(variables.variantId) });
|
|
84
84
|
queryClient.invalidateQueries({ queryKey: queryKeys.admin.variants.all });
|
|
85
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.products.detail(productId) });
|
|
85
86
|
},
|
|
86
87
|
...options,
|
|
87
88
|
});
|
|
@@ -12,10 +12,10 @@ export declare function useListWarehouses(options?: Omit<UseQueryOptions<Awaited
|
|
|
12
12
|
createdAt: string;
|
|
13
13
|
updatedAt: string;
|
|
14
14
|
deletedAt: string;
|
|
15
|
+
state: string | null;
|
|
15
16
|
isActive: boolean;
|
|
16
17
|
address: string | null;
|
|
17
18
|
city: string | null;
|
|
18
|
-
state: string | null;
|
|
19
19
|
}[], Error>;
|
|
20
20
|
/**
|
|
21
21
|
* Hook to create a warehouse using admin RPC
|
|
@@ -26,10 +26,10 @@ export declare function useCreateWarehouse(options?: UseMutationOptions<Awaited<
|
|
|
26
26
|
createdAt: string;
|
|
27
27
|
updatedAt: string;
|
|
28
28
|
deletedAt: string;
|
|
29
|
+
state: string | null;
|
|
29
30
|
isActive: boolean;
|
|
30
31
|
address: string | null;
|
|
31
32
|
city: string | null;
|
|
32
|
-
state: string | null;
|
|
33
33
|
} | {
|
|
34
34
|
error: {
|
|
35
35
|
code: string;
|
|
@@ -45,10 +45,10 @@ export declare function useUpdateWarehouse(warehouseId: string, options?: UseMut
|
|
|
45
45
|
createdAt: string;
|
|
46
46
|
updatedAt: string;
|
|
47
47
|
deletedAt: string;
|
|
48
|
+
state: string | null;
|
|
48
49
|
isActive: boolean;
|
|
49
50
|
address: string | null;
|
|
50
51
|
city: string | null;
|
|
51
|
-
state: string | null;
|
|
52
52
|
} | {
|
|
53
53
|
error: {
|
|
54
54
|
code: string;
|
|
@@ -74,6 +74,7 @@ export declare function useGetWarehouseInventory(warehouseId: string, options?:
|
|
|
74
74
|
tiktokPixelId: string | null;
|
|
75
75
|
paystackPublicKey: string | null;
|
|
76
76
|
paystackSecretKey: string | null;
|
|
77
|
+
freeShippingThreshold: string;
|
|
77
78
|
createdAt: string;
|
|
78
79
|
updatedAt: string;
|
|
79
80
|
deletedAt: string;
|
|
@@ -84,8 +85,8 @@ export declare function useGetWarehouseInventory(warehouseId: string, options?:
|
|
|
84
85
|
createdAt: string;
|
|
85
86
|
updatedAt: string;
|
|
86
87
|
deletedAt: string;
|
|
87
|
-
brandId: string;
|
|
88
88
|
isActive: boolean;
|
|
89
|
+
brandId: string;
|
|
89
90
|
description: string | null;
|
|
90
91
|
thumbnailUrl: string | null;
|
|
91
92
|
quantityDiscounts: string | number | boolean | {
|
|
@@ -531,8 +532,8 @@ export declare function useGetWarehouseInventory(warehouseId: string, options?:
|
|
|
531
532
|
updatedAt: string;
|
|
532
533
|
deletedAt: string;
|
|
533
534
|
isActive: boolean;
|
|
534
|
-
thumbnailUrl: string | null;
|
|
535
535
|
productId: string;
|
|
536
|
+
thumbnailUrl: string | null;
|
|
536
537
|
sku: string;
|
|
537
538
|
price: string;
|
|
538
539
|
compareAtPrice: string;
|
|
@@ -550,10 +551,10 @@ export declare function useGetWarehouseInventory(warehouseId: string, options?:
|
|
|
550
551
|
createdAt: string;
|
|
551
552
|
updatedAt: string;
|
|
552
553
|
deletedAt: string;
|
|
554
|
+
state: string | null;
|
|
553
555
|
isActive: boolean;
|
|
554
556
|
address: string | null;
|
|
555
557
|
city: string | null;
|
|
556
|
-
state: string | null;
|
|
557
558
|
};
|
|
558
559
|
inventory: {
|
|
559
560
|
variantId: string;
|