@instockng/api-client 1.0.36 → 1.0.37
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.js +1 -1
- package/dist/fetchers/carts.d.ts +19 -0
- package/dist/fetchers/carts.js +1 -1
- package/dist/fetchers/delivery-zones.js +1 -1
- package/dist/fetchers/orders.d.ts +63 -0
- package/dist/fetchers/orders.js +38 -1
- package/dist/fetchers/products.js +1 -1
- package/dist/hooks/admin/customers.d.ts +19 -0
- package/dist/hooks/admin/dispatch-riders.d.ts +59 -0
- package/dist/hooks/admin/dispatch-riders.js +92 -0
- package/dist/hooks/admin/index.d.ts +1 -0
- package/dist/hooks/admin/index.js +1 -0
- package/dist/hooks/admin/orders.d.ts +136 -0
- package/dist/hooks/admin/orders.js +70 -0
- package/dist/hooks/admin/stats.d.ts +26 -0
- package/dist/hooks/admin/stats.js +20 -0
- package/dist/hooks/public/carts.d.ts +19 -0
- package/dist/hooks/public/orders.d.ts +67 -1
- package/dist/hooks/public/orders.js +23 -1
- package/dist/provider.js +1 -1
- package/dist/rpc-client.d.ts +5431 -2539
- package/dist/rpc-client.js +1 -0
- package/dist/utils/query-keys.d.ts +5 -0
- package/dist/utils/query-keys.js +5 -0
- package/package.json +1 -1
|
@@ -32,11 +32,19 @@ export declare function useListOrders(filters?: {
|
|
|
32
32
|
deliveryCharge: number;
|
|
33
33
|
totalPrice: number;
|
|
34
34
|
discountAmount: number;
|
|
35
|
+
amountPaid: number;
|
|
36
|
+
flutterwaveAccountBank: string;
|
|
37
|
+
flutterwaveAccountNumber: string;
|
|
38
|
+
flutterwaveAccountExpiry: string;
|
|
35
39
|
createdAt: string;
|
|
36
40
|
updatedAt: string;
|
|
37
41
|
deletedAt: string;
|
|
38
42
|
prospectSince: string;
|
|
39
43
|
lastRecoveryAttemptAt: string;
|
|
44
|
+
shippedAt: string;
|
|
45
|
+
deliveryConfirmationSentAt: string;
|
|
46
|
+
deliveryConfirmedAt: string;
|
|
47
|
+
deliveryConfirmationAttempts: number;
|
|
40
48
|
brand: {
|
|
41
49
|
id: string;
|
|
42
50
|
name: string;
|
|
@@ -579,8 +587,19 @@ export declare function useListOrders(filters?: {
|
|
|
579
587
|
paystackReference: string | null;
|
|
580
588
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
581
589
|
cancellationReason: string | null;
|
|
590
|
+
shippingMethod: string | null;
|
|
591
|
+
dispatchRiderId: string | null;
|
|
592
|
+
fezTrackingNumber: string | null;
|
|
593
|
+
flutterwaveOrderRef: string | null;
|
|
594
|
+
flutterwaveCustomerId: string | null;
|
|
582
595
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
583
596
|
userActionToken: string;
|
|
597
|
+
labelPrintedAt: string;
|
|
598
|
+
dispatchRider?: {
|
|
599
|
+
id: string;
|
|
600
|
+
name: string;
|
|
601
|
+
phone: string;
|
|
602
|
+
};
|
|
584
603
|
}[];
|
|
585
604
|
pagination: {
|
|
586
605
|
page: number;
|
|
@@ -605,11 +624,19 @@ export declare function useGetOrder(orderId: string, options?: Omit<UseQueryOpti
|
|
|
605
624
|
deliveryCharge: number;
|
|
606
625
|
totalPrice: number;
|
|
607
626
|
discountAmount: number;
|
|
627
|
+
amountPaid: number;
|
|
628
|
+
flutterwaveAccountBank: string;
|
|
629
|
+
flutterwaveAccountNumber: string;
|
|
630
|
+
flutterwaveAccountExpiry: string;
|
|
608
631
|
createdAt: string;
|
|
609
632
|
updatedAt: string;
|
|
610
633
|
deletedAt: string;
|
|
611
634
|
prospectSince: string;
|
|
612
635
|
lastRecoveryAttemptAt: string;
|
|
636
|
+
shippedAt: string;
|
|
637
|
+
deliveryConfirmationSentAt: string;
|
|
638
|
+
deliveryConfirmedAt: string;
|
|
639
|
+
deliveryConfirmationAttempts: number;
|
|
613
640
|
brand: {
|
|
614
641
|
id: string;
|
|
615
642
|
name: string;
|
|
@@ -1152,8 +1179,19 @@ export declare function useGetOrder(orderId: string, options?: Omit<UseQueryOpti
|
|
|
1152
1179
|
paystackReference: string | null;
|
|
1153
1180
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
1154
1181
|
cancellationReason: string | null;
|
|
1182
|
+
shippingMethod: string | null;
|
|
1183
|
+
dispatchRiderId: string | null;
|
|
1184
|
+
fezTrackingNumber: string | null;
|
|
1185
|
+
flutterwaveOrderRef: string | null;
|
|
1186
|
+
flutterwaveCustomerId: string | null;
|
|
1155
1187
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
1156
1188
|
userActionToken: string;
|
|
1189
|
+
labelPrintedAt: string;
|
|
1190
|
+
dispatchRider?: {
|
|
1191
|
+
id: string;
|
|
1192
|
+
name: string;
|
|
1193
|
+
phone: string;
|
|
1194
|
+
};
|
|
1157
1195
|
}, Error>;
|
|
1158
1196
|
/**
|
|
1159
1197
|
* Hook to create a new order using admin RPC
|
|
@@ -1175,11 +1213,19 @@ export declare function useCreateOrder(options?: UseMutationOptions<Awaited<Retu
|
|
|
1175
1213
|
deliveryCharge: number;
|
|
1176
1214
|
totalPrice: number;
|
|
1177
1215
|
discountAmount: number;
|
|
1216
|
+
amountPaid: number;
|
|
1217
|
+
flutterwaveAccountBank: string;
|
|
1218
|
+
flutterwaveAccountNumber: string;
|
|
1219
|
+
flutterwaveAccountExpiry: string;
|
|
1178
1220
|
createdAt: string;
|
|
1179
1221
|
updatedAt: string;
|
|
1180
1222
|
deletedAt: string;
|
|
1181
1223
|
prospectSince: string;
|
|
1182
1224
|
lastRecoveryAttemptAt: string;
|
|
1225
|
+
shippedAt: string;
|
|
1226
|
+
deliveryConfirmationSentAt: string;
|
|
1227
|
+
deliveryConfirmedAt: string;
|
|
1228
|
+
deliveryConfirmationAttempts: number;
|
|
1183
1229
|
brand: {
|
|
1184
1230
|
id: string;
|
|
1185
1231
|
name: string;
|
|
@@ -1722,8 +1768,19 @@ export declare function useCreateOrder(options?: UseMutationOptions<Awaited<Retu
|
|
|
1722
1768
|
paystackReference: string | null;
|
|
1723
1769
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
1724
1770
|
cancellationReason: string | null;
|
|
1771
|
+
shippingMethod: string | null;
|
|
1772
|
+
dispatchRiderId: string | null;
|
|
1773
|
+
fezTrackingNumber: string | null;
|
|
1774
|
+
flutterwaveOrderRef: string | null;
|
|
1775
|
+
flutterwaveCustomerId: string | null;
|
|
1725
1776
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
1726
1777
|
userActionToken: string;
|
|
1778
|
+
labelPrintedAt: string;
|
|
1779
|
+
dispatchRider?: {
|
|
1780
|
+
id: string;
|
|
1781
|
+
name: string;
|
|
1782
|
+
phone: string;
|
|
1783
|
+
};
|
|
1727
1784
|
} | {
|
|
1728
1785
|
error: {
|
|
1729
1786
|
code: string;
|
|
@@ -1746,11 +1803,19 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
1746
1803
|
deliveryCharge: number;
|
|
1747
1804
|
totalPrice: number;
|
|
1748
1805
|
discountAmount: number;
|
|
1806
|
+
amountPaid: number;
|
|
1807
|
+
flutterwaveAccountBank: string;
|
|
1808
|
+
flutterwaveAccountNumber: string;
|
|
1809
|
+
flutterwaveAccountExpiry: string;
|
|
1749
1810
|
createdAt: string;
|
|
1750
1811
|
updatedAt: string;
|
|
1751
1812
|
deletedAt: string;
|
|
1752
1813
|
prospectSince: string;
|
|
1753
1814
|
lastRecoveryAttemptAt: string;
|
|
1815
|
+
shippedAt: string;
|
|
1816
|
+
deliveryConfirmationSentAt: string;
|
|
1817
|
+
deliveryConfirmedAt: string;
|
|
1818
|
+
deliveryConfirmationAttempts: number;
|
|
1754
1819
|
brand: {
|
|
1755
1820
|
id: string;
|
|
1756
1821
|
name: string;
|
|
@@ -2293,8 +2358,19 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
2293
2358
|
paystackReference: string | null;
|
|
2294
2359
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
2295
2360
|
cancellationReason: string | null;
|
|
2361
|
+
shippingMethod: string | null;
|
|
2362
|
+
dispatchRiderId: string | null;
|
|
2363
|
+
fezTrackingNumber: string | null;
|
|
2364
|
+
flutterwaveOrderRef: string | null;
|
|
2365
|
+
flutterwaveCustomerId: string | null;
|
|
2296
2366
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
2297
2367
|
userActionToken: string;
|
|
2368
|
+
labelPrintedAt: string;
|
|
2369
|
+
dispatchRider?: {
|
|
2370
|
+
id: string;
|
|
2371
|
+
name: string;
|
|
2372
|
+
phone: string;
|
|
2373
|
+
};
|
|
2298
2374
|
} | {
|
|
2299
2375
|
error: {
|
|
2300
2376
|
code: string;
|
|
@@ -2343,6 +2419,14 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
2343
2419
|
noteTitle: string | null;
|
|
2344
2420
|
noteContent: string | null;
|
|
2345
2421
|
};
|
|
2422
|
+
dispatchRider: {
|
|
2423
|
+
id: string;
|
|
2424
|
+
name: string;
|
|
2425
|
+
createdAt: string;
|
|
2426
|
+
updatedAt: string;
|
|
2427
|
+
deletedAt: string;
|
|
2428
|
+
phone: string;
|
|
2429
|
+
};
|
|
2346
2430
|
items: {
|
|
2347
2431
|
warehouse: {
|
|
2348
2432
|
id: string;
|
|
@@ -3013,9 +3097,23 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
3013
3097
|
paystackReference: string | null;
|
|
3014
3098
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
3015
3099
|
cancellationReason: string | null;
|
|
3100
|
+
shippingMethod: string | null;
|
|
3101
|
+
dispatchRiderId: string | null;
|
|
3102
|
+
fezTrackingNumber: string | null;
|
|
3103
|
+
amountPaid: string;
|
|
3104
|
+
flutterwaveAccountBank: string | null;
|
|
3105
|
+
flutterwaveAccountNumber: string | null;
|
|
3106
|
+
flutterwaveOrderRef: string | null;
|
|
3107
|
+
flutterwaveCustomerId: string | null;
|
|
3108
|
+
flutterwaveAccountExpiry: string;
|
|
3016
3109
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
3017
3110
|
prospectSince: string;
|
|
3018
3111
|
userActionToken: string;
|
|
3112
|
+
shippedAt: string;
|
|
3113
|
+
labelPrintedAt: string;
|
|
3114
|
+
deliveryConfirmationSentAt: string;
|
|
3115
|
+
deliveryConfirmedAt: string;
|
|
3116
|
+
deliveryConfirmationAttempts: number;
|
|
3019
3117
|
} | {
|
|
3020
3118
|
error: {
|
|
3021
3119
|
code: string;
|
|
@@ -3033,11 +3131,19 @@ export declare function useUpdateOrderStatus(orderId: string, options?: UseMutat
|
|
|
3033
3131
|
deliveryCharge: number;
|
|
3034
3132
|
totalPrice: number;
|
|
3035
3133
|
discountAmount: number;
|
|
3134
|
+
amountPaid: number;
|
|
3135
|
+
flutterwaveAccountBank: string;
|
|
3136
|
+
flutterwaveAccountNumber: string;
|
|
3137
|
+
flutterwaveAccountExpiry: string;
|
|
3036
3138
|
createdAt: string;
|
|
3037
3139
|
updatedAt: string;
|
|
3038
3140
|
deletedAt: string;
|
|
3039
3141
|
prospectSince: string;
|
|
3040
3142
|
lastRecoveryAttemptAt: string;
|
|
3143
|
+
shippedAt: string;
|
|
3144
|
+
deliveryConfirmationSentAt: string;
|
|
3145
|
+
deliveryConfirmedAt: string;
|
|
3146
|
+
deliveryConfirmationAttempts: number;
|
|
3041
3147
|
brand: {
|
|
3042
3148
|
id: string;
|
|
3043
3149
|
name: string;
|
|
@@ -3580,8 +3686,19 @@ export declare function useUpdateOrderStatus(orderId: string, options?: UseMutat
|
|
|
3580
3686
|
paystackReference: string | null;
|
|
3581
3687
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
3582
3688
|
cancellationReason: string | null;
|
|
3689
|
+
shippingMethod: string | null;
|
|
3690
|
+
dispatchRiderId: string | null;
|
|
3691
|
+
fezTrackingNumber: string | null;
|
|
3692
|
+
flutterwaveOrderRef: string | null;
|
|
3693
|
+
flutterwaveCustomerId: string | null;
|
|
3583
3694
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
3584
3695
|
userActionToken: string;
|
|
3696
|
+
labelPrintedAt: string;
|
|
3697
|
+
dispatchRider?: {
|
|
3698
|
+
id: string;
|
|
3699
|
+
name: string;
|
|
3700
|
+
phone: string;
|
|
3701
|
+
};
|
|
3585
3702
|
} | {
|
|
3586
3703
|
error: {
|
|
3587
3704
|
code: string;
|
|
@@ -3605,6 +3722,25 @@ export declare function useUpdateOrderStatus(orderId: string, options?: UseMutat
|
|
|
3605
3722
|
* @param options - React Query mutation options
|
|
3606
3723
|
*/
|
|
3607
3724
|
export declare function useDeleteOrder(orderId: string, options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['orders'][':id']['$delete']>>['json']>>, Error, void>): import("@tanstack/react-query").UseMutationResult<unknown, Error, void, unknown>;
|
|
3725
|
+
/**
|
|
3726
|
+
* Hook to regenerate Flutterwave virtual account for a COD order
|
|
3727
|
+
*
|
|
3728
|
+
* @param orderId - Order UUID
|
|
3729
|
+
* @param options - React Query mutation options
|
|
3730
|
+
*/
|
|
3731
|
+
export declare function useRegenerateAccount(orderId: string, options?: UseMutationOptions<any, Error, void>): import("@tanstack/react-query").UseMutationResult<any, Error, void, unknown>;
|
|
3732
|
+
/**
|
|
3733
|
+
* Hook to send delivery confirmation for a single order
|
|
3734
|
+
*/
|
|
3735
|
+
export declare function useSendDeliveryConfirmation(orderId: string, options?: UseMutationOptions<any, Error, void>): import("@tanstack/react-query").UseMutationResult<any, Error, void, unknown>;
|
|
3736
|
+
/**
|
|
3737
|
+
* Hook to send batch delivery confirmation
|
|
3738
|
+
*/
|
|
3739
|
+
export declare function useBatchDeliveryConfirmation(options?: UseMutationOptions<any, Error, {
|
|
3740
|
+
orderIds: string[];
|
|
3741
|
+
}>): import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
3742
|
+
orderIds: string[];
|
|
3743
|
+
}, unknown>;
|
|
3608
3744
|
/**
|
|
3609
3745
|
* Hook to add a note to an order using admin RPC
|
|
3610
3746
|
*
|
|
@@ -176,6 +176,76 @@ export function useDeleteOrder(orderId, options) {
|
|
|
176
176
|
...options,
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
+
/**
|
|
180
|
+
* Hook to regenerate Flutterwave virtual account for a COD order
|
|
181
|
+
*
|
|
182
|
+
* @param orderId - Order UUID
|
|
183
|
+
* @param options - React Query mutation options
|
|
184
|
+
*/
|
|
185
|
+
export function useRegenerateAccount(orderId, options) {
|
|
186
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
187
|
+
const queryClient = useQueryClient();
|
|
188
|
+
return useMutation({
|
|
189
|
+
mutationFn: async () => {
|
|
190
|
+
const token = await getAuthToken();
|
|
191
|
+
const clients = createAdminRpcClients(baseURL);
|
|
192
|
+
const res = await clients.orders[':id']['regenerate-account'].$post({ param: { id: orderId } }, authHeaders(token));
|
|
193
|
+
if (!res.ok) {
|
|
194
|
+
throw new Error(`Failed to regenerate account: ${res.statusText}`);
|
|
195
|
+
}
|
|
196
|
+
return res.json();
|
|
197
|
+
},
|
|
198
|
+
onSuccess: () => {
|
|
199
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.orders.detail(orderId) });
|
|
200
|
+
},
|
|
201
|
+
...options,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Hook to send delivery confirmation for a single order
|
|
206
|
+
*/
|
|
207
|
+
export function useSendDeliveryConfirmation(orderId, options) {
|
|
208
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
209
|
+
const queryClient = useQueryClient();
|
|
210
|
+
return useMutation({
|
|
211
|
+
mutationFn: async () => {
|
|
212
|
+
const token = await getAuthToken();
|
|
213
|
+
const clients = createAdminRpcClients(baseURL);
|
|
214
|
+
const res = await clients.orders[':id']['send-delivery-confirmation'].$post({ param: { id: orderId } }, authHeaders(token));
|
|
215
|
+
if (!res.ok) {
|
|
216
|
+
throw new Error(`Failed to send delivery confirmation: ${res.statusText}`);
|
|
217
|
+
}
|
|
218
|
+
return res.json();
|
|
219
|
+
},
|
|
220
|
+
onSuccess: () => {
|
|
221
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.orders.detail(orderId) });
|
|
222
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.orders.all });
|
|
223
|
+
},
|
|
224
|
+
...options,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
/**
|
|
228
|
+
* Hook to send batch delivery confirmation
|
|
229
|
+
*/
|
|
230
|
+
export function useBatchDeliveryConfirmation(options) {
|
|
231
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
232
|
+
const queryClient = useQueryClient();
|
|
233
|
+
return useMutation({
|
|
234
|
+
mutationFn: async (data) => {
|
|
235
|
+
const token = await getAuthToken();
|
|
236
|
+
const clients = createAdminRpcClients(baseURL);
|
|
237
|
+
const res = await clients.orders['batch-delivery-confirmation'].$post({ json: data }, authHeaders(token));
|
|
238
|
+
if (!res.ok) {
|
|
239
|
+
throw new Error(`Failed to send batch delivery confirmation: ${res.statusText}`);
|
|
240
|
+
}
|
|
241
|
+
return res.json();
|
|
242
|
+
},
|
|
243
|
+
onSuccess: () => {
|
|
244
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.admin.orders.all });
|
|
245
|
+
},
|
|
246
|
+
...options,
|
|
247
|
+
});
|
|
248
|
+
}
|
|
179
249
|
/**
|
|
180
250
|
* Hook to add a note to an order using admin RPC
|
|
181
251
|
*
|
|
@@ -3,6 +3,13 @@
|
|
|
3
3
|
*/
|
|
4
4
|
import { UseQueryOptions } from '@tanstack/react-query';
|
|
5
5
|
import { createAdminRpcClients } from '../../rpc-client';
|
|
6
|
+
/**
|
|
7
|
+
* Hook to get product order stats grouped by brand
|
|
8
|
+
*/
|
|
9
|
+
export declare function useGetProductOrderStats(params?: {
|
|
10
|
+
statuses?: string;
|
|
11
|
+
period?: string;
|
|
12
|
+
}, options?: Omit<UseQueryOptions<any, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
6
13
|
/**
|
|
7
14
|
* Hook to get dashboard statistics using admin RPC
|
|
8
15
|
*/
|
|
@@ -35,11 +42,19 @@ export declare function useGetStats(params?: {
|
|
|
35
42
|
deliveryCharge: number;
|
|
36
43
|
totalPrice: number;
|
|
37
44
|
discountAmount: number;
|
|
45
|
+
amountPaid: number;
|
|
46
|
+
flutterwaveAccountBank: string;
|
|
47
|
+
flutterwaveAccountNumber: string;
|
|
48
|
+
flutterwaveAccountExpiry: string;
|
|
38
49
|
createdAt: string;
|
|
39
50
|
updatedAt: string;
|
|
40
51
|
deletedAt: string;
|
|
41
52
|
prospectSince: string;
|
|
42
53
|
lastRecoveryAttemptAt: string;
|
|
54
|
+
shippedAt: string;
|
|
55
|
+
deliveryConfirmationSentAt: string;
|
|
56
|
+
deliveryConfirmedAt: string;
|
|
57
|
+
deliveryConfirmationAttempts: number;
|
|
43
58
|
brand: {
|
|
44
59
|
id: string;
|
|
45
60
|
name: string;
|
|
@@ -582,7 +597,18 @@ export declare function useGetStats(params?: {
|
|
|
582
597
|
paystackReference: string | null;
|
|
583
598
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
584
599
|
cancellationReason: string | null;
|
|
600
|
+
shippingMethod: string | null;
|
|
601
|
+
dispatchRiderId: string | null;
|
|
602
|
+
fezTrackingNumber: string | null;
|
|
603
|
+
flutterwaveOrderRef: string | null;
|
|
604
|
+
flutterwaveCustomerId: string | null;
|
|
585
605
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
586
606
|
userActionToken: string;
|
|
607
|
+
labelPrintedAt: string;
|
|
608
|
+
dispatchRider?: {
|
|
609
|
+
id: string;
|
|
610
|
+
name: string;
|
|
611
|
+
phone: string;
|
|
612
|
+
};
|
|
587
613
|
}[];
|
|
588
614
|
}, Error>;
|
|
@@ -5,6 +5,26 @@ import { useQueryUnwrapped } from '../use-query-unwrapped';
|
|
|
5
5
|
import { createAdminRpcClients, authHeaders } from '../../rpc-client';
|
|
6
6
|
import { queryKeys } from '../../utils/query-keys';
|
|
7
7
|
import { useApiConfig } from '../useApiConfig';
|
|
8
|
+
/**
|
|
9
|
+
* Hook to get product order stats grouped by brand
|
|
10
|
+
*/
|
|
11
|
+
export function useGetProductOrderStats(params, options) {
|
|
12
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
13
|
+
return useQueryUnwrapped({
|
|
14
|
+
queryKey: queryKeys.admin.stats.productOrders(params?.statuses, params?.period),
|
|
15
|
+
queryFn: async () => {
|
|
16
|
+
const token = await getAuthToken();
|
|
17
|
+
const clients = createAdminRpcClients(baseURL);
|
|
18
|
+
const res = await clients.stats['product-orders'].$get({ query: params }, authHeaders(token));
|
|
19
|
+
if (!res.ok)
|
|
20
|
+
throw new Error(`Failed to fetch product order stats: ${res.statusText}`);
|
|
21
|
+
return res.json();
|
|
22
|
+
},
|
|
23
|
+
staleTime: 0,
|
|
24
|
+
gcTime: 0,
|
|
25
|
+
...options,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
8
28
|
/**
|
|
9
29
|
* Hook to get dashboard statistics using admin RPC
|
|
10
30
|
*/
|
|
@@ -4511,11 +4511,19 @@ export declare function useCheckoutCart(cartId: string, options?: UseMutationOpt
|
|
|
4511
4511
|
deliveryCharge: number;
|
|
4512
4512
|
totalPrice: number;
|
|
4513
4513
|
discountAmount: number;
|
|
4514
|
+
amountPaid: number;
|
|
4515
|
+
flutterwaveAccountBank: string;
|
|
4516
|
+
flutterwaveAccountNumber: string;
|
|
4517
|
+
flutterwaveAccountExpiry: string;
|
|
4514
4518
|
createdAt: string;
|
|
4515
4519
|
updatedAt: string;
|
|
4516
4520
|
deletedAt: string;
|
|
4517
4521
|
prospectSince: string;
|
|
4518
4522
|
lastRecoveryAttemptAt: string;
|
|
4523
|
+
shippedAt: string;
|
|
4524
|
+
deliveryConfirmationSentAt: string;
|
|
4525
|
+
deliveryConfirmedAt: string;
|
|
4526
|
+
deliveryConfirmationAttempts: number;
|
|
4519
4527
|
brand: {
|
|
4520
4528
|
id: string;
|
|
4521
4529
|
name: string;
|
|
@@ -5058,8 +5066,19 @@ export declare function useCheckoutCart(cartId: string, options?: UseMutationOpt
|
|
|
5058
5066
|
paystackReference: string | null;
|
|
5059
5067
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
5060
5068
|
cancellationReason: string | null;
|
|
5069
|
+
shippingMethod: string | null;
|
|
5070
|
+
dispatchRiderId: string | null;
|
|
5071
|
+
fezTrackingNumber: string | null;
|
|
5072
|
+
flutterwaveOrderRef: string | null;
|
|
5073
|
+
flutterwaveCustomerId: string | null;
|
|
5061
5074
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
5062
5075
|
userActionToken: string;
|
|
5076
|
+
labelPrintedAt: string;
|
|
5077
|
+
dispatchRider?: {
|
|
5078
|
+
id: string;
|
|
5079
|
+
name: string;
|
|
5080
|
+
phone: string;
|
|
5081
|
+
};
|
|
5063
5082
|
}, Error, {
|
|
5064
5083
|
firstName: string;
|
|
5065
5084
|
lastName: string;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* providing end-to-end type safety without code generation.
|
|
6
6
|
*/
|
|
7
7
|
import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
|
|
8
|
-
import { fetchOrder, confirmOrder, fetchOrderRecommendations } from '../../fetchers/orders';
|
|
8
|
+
import { fetchOrder, confirmOrder, confirmDelivery, updateDeliveryAddress, fetchOrderRecommendations } from '../../fetchers/orders';
|
|
9
9
|
/**
|
|
10
10
|
* Hook to get order by ID and token using RPC
|
|
11
11
|
*
|
|
@@ -21,16 +21,26 @@ import { fetchOrder, confirmOrder, fetchOrderRecommendations } from '../../fetch
|
|
|
21
21
|
*/
|
|
22
22
|
export declare function useGetOrder(orderId: string, token: string, options?: Omit<UseQueryOptions<Awaited<ReturnType<typeof fetchOrder>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
|
|
23
23
|
canConfirm: boolean;
|
|
24
|
+
canConfirmDelivery: boolean;
|
|
25
|
+
canUpdateAddress: boolean;
|
|
24
26
|
confirmationMessage: string;
|
|
25
27
|
subtotal: number;
|
|
26
28
|
deliveryCharge: number;
|
|
27
29
|
totalPrice: number;
|
|
28
30
|
discountAmount: number;
|
|
31
|
+
amountPaid: number;
|
|
32
|
+
flutterwaveAccountBank: string;
|
|
33
|
+
flutterwaveAccountNumber: string;
|
|
34
|
+
flutterwaveAccountExpiry: string;
|
|
29
35
|
createdAt: string;
|
|
30
36
|
updatedAt: string;
|
|
31
37
|
deletedAt: string;
|
|
32
38
|
prospectSince: string;
|
|
33
39
|
lastRecoveryAttemptAt: string;
|
|
40
|
+
shippedAt: string;
|
|
41
|
+
deliveryConfirmationSentAt: string;
|
|
42
|
+
deliveryConfirmedAt: string;
|
|
43
|
+
deliveryConfirmationAttempts: number;
|
|
34
44
|
brand: {
|
|
35
45
|
id: string;
|
|
36
46
|
name: string;
|
|
@@ -573,8 +583,19 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
|
|
|
573
583
|
paystackReference: string | null;
|
|
574
584
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
575
585
|
cancellationReason: string | null;
|
|
586
|
+
shippingMethod: string | null;
|
|
587
|
+
dispatchRiderId: string | null;
|
|
588
|
+
fezTrackingNumber: string | null;
|
|
589
|
+
flutterwaveOrderRef: string | null;
|
|
590
|
+
flutterwaveCustomerId: string | null;
|
|
576
591
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
577
592
|
userActionToken: string;
|
|
593
|
+
labelPrintedAt: string;
|
|
594
|
+
dispatchRider?: {
|
|
595
|
+
id: string;
|
|
596
|
+
name: string;
|
|
597
|
+
phone: string;
|
|
598
|
+
};
|
|
578
599
|
}, Error>;
|
|
579
600
|
/**
|
|
580
601
|
* Hook to confirm a prospect order using RPC
|
|
@@ -598,11 +619,19 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
|
|
|
598
619
|
deliveryCharge: number;
|
|
599
620
|
totalPrice: number;
|
|
600
621
|
discountAmount: number;
|
|
622
|
+
amountPaid: number;
|
|
623
|
+
flutterwaveAccountBank: string;
|
|
624
|
+
flutterwaveAccountNumber: string;
|
|
625
|
+
flutterwaveAccountExpiry: string;
|
|
601
626
|
createdAt: string;
|
|
602
627
|
updatedAt: string;
|
|
603
628
|
deletedAt: string;
|
|
604
629
|
prospectSince: string;
|
|
605
630
|
lastRecoveryAttemptAt: string;
|
|
631
|
+
shippedAt: string;
|
|
632
|
+
deliveryConfirmationSentAt: string;
|
|
633
|
+
deliveryConfirmedAt: string;
|
|
634
|
+
deliveryConfirmationAttempts: number;
|
|
606
635
|
brand: {
|
|
607
636
|
id: string;
|
|
608
637
|
name: string;
|
|
@@ -1145,12 +1174,49 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
|
|
|
1145
1174
|
paystackReference: string | null;
|
|
1146
1175
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
1147
1176
|
cancellationReason: string | null;
|
|
1177
|
+
shippingMethod: string | null;
|
|
1178
|
+
dispatchRiderId: string | null;
|
|
1179
|
+
fezTrackingNumber: string | null;
|
|
1180
|
+
flutterwaveOrderRef: string | null;
|
|
1181
|
+
flutterwaveCustomerId: string | null;
|
|
1148
1182
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
1149
1183
|
userActionToken: string;
|
|
1184
|
+
labelPrintedAt: string;
|
|
1185
|
+
dispatchRider?: {
|
|
1186
|
+
id: string;
|
|
1187
|
+
name: string;
|
|
1188
|
+
phone: string;
|
|
1189
|
+
};
|
|
1150
1190
|
}, Error, {
|
|
1151
1191
|
orderId: string;
|
|
1152
1192
|
token: string;
|
|
1153
1193
|
}, unknown>;
|
|
1194
|
+
/**
|
|
1195
|
+
* Hook to confirm delivery details for an order
|
|
1196
|
+
*/
|
|
1197
|
+
export declare function useConfirmDelivery(options?: UseMutationOptions<Awaited<ReturnType<typeof confirmDelivery>>, Error, {
|
|
1198
|
+
orderId: string;
|
|
1199
|
+
token: string;
|
|
1200
|
+
}>): import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
1201
|
+
orderId: string;
|
|
1202
|
+
token: string;
|
|
1203
|
+
}, unknown>;
|
|
1204
|
+
/**
|
|
1205
|
+
* Hook to update delivery address for an order
|
|
1206
|
+
*/
|
|
1207
|
+
export declare function useUpdateDeliveryAddress(options?: UseMutationOptions<Awaited<ReturnType<typeof updateDeliveryAddress>>, Error, {
|
|
1208
|
+
orderId: string;
|
|
1209
|
+
token: string;
|
|
1210
|
+
address?: string;
|
|
1211
|
+
city?: string;
|
|
1212
|
+
phone?: string;
|
|
1213
|
+
}>): import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
1214
|
+
orderId: string;
|
|
1215
|
+
token: string;
|
|
1216
|
+
address?: string;
|
|
1217
|
+
city?: string;
|
|
1218
|
+
phone?: string;
|
|
1219
|
+
}, unknown>;
|
|
1154
1220
|
/**
|
|
1155
1221
|
* Hook to get order recommendations for post-purchase upsell
|
|
1156
1222
|
*
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { useMutation } from '@tanstack/react-query';
|
|
8
8
|
import { useQueryUnwrapped } from '../use-query-unwrapped';
|
|
9
9
|
import { queryKeys } from '../../utils/query-keys';
|
|
10
|
-
import { fetchOrder, confirmOrder, fetchOrderRecommendations } from '../../fetchers/orders';
|
|
10
|
+
import { fetchOrder, confirmOrder, confirmDelivery, updateDeliveryAddress, fetchOrderRecommendations } from '../../fetchers/orders';
|
|
11
11
|
/**
|
|
12
12
|
* Hook to get order by ID and token using RPC
|
|
13
13
|
*
|
|
@@ -48,6 +48,28 @@ export function useConfirmOrder(options) {
|
|
|
48
48
|
...options,
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Hook to confirm delivery details for an order
|
|
53
|
+
*/
|
|
54
|
+
export function useConfirmDelivery(options) {
|
|
55
|
+
return useMutation({
|
|
56
|
+
mutationFn: (data) => confirmDelivery(data.orderId, data.token),
|
|
57
|
+
...options,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Hook to update delivery address for an order
|
|
62
|
+
*/
|
|
63
|
+
export function useUpdateDeliveryAddress(options) {
|
|
64
|
+
return useMutation({
|
|
65
|
+
mutationFn: (data) => updateDeliveryAddress(data.orderId, data.token, {
|
|
66
|
+
address: data.address,
|
|
67
|
+
city: data.city,
|
|
68
|
+
phone: data.phone,
|
|
69
|
+
}),
|
|
70
|
+
...options,
|
|
71
|
+
});
|
|
72
|
+
}
|
|
51
73
|
/**
|
|
52
74
|
* Hook to get order recommendations for post-purchase upsell
|
|
53
75
|
*
|
package/dist/provider.js
CHANGED
|
@@ -18,7 +18,7 @@ const ApiClientContext = createContext(null);
|
|
|
18
18
|
* </ApiClientProvider>
|
|
19
19
|
* ```
|
|
20
20
|
*/
|
|
21
|
-
export function ApiClientProvider({ children, baseURL = 'https://oms-api.instock.
|
|
21
|
+
export function ApiClientProvider({ children, baseURL = 'https://oms-api.instock.ng', getAuthToken, onError, queryClient: externalQueryClient }) {
|
|
22
22
|
// Initialize client synchronously on first render
|
|
23
23
|
const config = {
|
|
24
24
|
baseURL,
|