@instockng/api-client 1.0.35 → 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.
Files changed (37) hide show
  1. package/dist/backend-types.d.ts +1 -1
  2. package/dist/fetchers/brands.d.ts +1 -0
  3. package/dist/fetchers/brands.js +1 -1
  4. package/dist/fetchers/carts.d.ts +132 -112
  5. package/dist/fetchers/carts.js +1 -1
  6. package/dist/fetchers/delivery-zones.d.ts +0 -1
  7. package/dist/fetchers/delivery-zones.js +1 -1
  8. package/dist/fetchers/orders.d.ts +94 -30
  9. package/dist/fetchers/orders.js +38 -1
  10. package/dist/fetchers/products.js +1 -1
  11. package/dist/hooks/admin/abandoned-carts.d.ts +24 -24
  12. package/dist/hooks/admin/brands.d.ts +4 -0
  13. package/dist/hooks/admin/customers.d.ts +33 -14
  14. package/dist/hooks/admin/delivery-zones.d.ts +12 -8
  15. package/dist/hooks/admin/discount-codes.d.ts +20 -15
  16. package/dist/hooks/admin/dispatch-riders.d.ts +59 -0
  17. package/dist/hooks/admin/dispatch-riders.js +92 -0
  18. package/dist/hooks/admin/index.d.ts +1 -0
  19. package/dist/hooks/admin/index.js +1 -0
  20. package/dist/hooks/admin/orders.d.ts +215 -78
  21. package/dist/hooks/admin/orders.js +70 -0
  22. package/dist/hooks/admin/products.d.ts +6 -4
  23. package/dist/hooks/admin/stats.d.ts +40 -14
  24. package/dist/hooks/admin/stats.js +20 -0
  25. package/dist/hooks/admin/warehouses.d.ts +7 -6
  26. package/dist/hooks/public/brands.d.ts +1 -0
  27. package/dist/hooks/public/carts.d.ts +132 -112
  28. package/dist/hooks/public/delivery-zones.d.ts +0 -1
  29. package/dist/hooks/public/orders.d.ts +98 -31
  30. package/dist/hooks/public/orders.js +23 -1
  31. package/dist/provider.js +1 -1
  32. package/dist/rpc-client.d.ts +6684 -3768
  33. package/dist/rpc-client.js +1 -0
  34. package/dist/rpc-types.d.ts +9 -6
  35. package/dist/utils/query-keys.d.ts +5 -0
  36. package/dist/utils/query-keys.js +5 -0
  37. package/package.json +1 -1
@@ -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
  *
@@ -168,6 +168,7 @@ export declare function useListProducts(brandId?: string, options?: Omit<UseQuer
168
168
  metaPixelId: string;
169
169
  tiktokPixelId: string;
170
170
  paystackPublicKey: string;
171
+ freeShippingThreshold: number;
171
172
  createdAt: string;
172
173
  updatedAt: string;
173
174
  deletedAt: string;
@@ -486,8 +487,8 @@ export declare function useListProducts(brandId?: string, options?: Omit<UseQuer
486
487
  createdAt: string;
487
488
  updatedAt: string;
488
489
  deletedAt: string;
489
- brandId: string;
490
490
  isActive: boolean;
491
+ brandId: string;
491
492
  discountType: import("@prisma/client").$Enums.DiscountType;
492
493
  discountValue: string;
493
494
  startDate: string;
@@ -501,8 +502,8 @@ export declare function useListProducts(brandId?: string, options?: Omit<UseQuer
501
502
  createdAt: string;
502
503
  updatedAt: string;
503
504
  deletedAt: string;
504
- brandId: string;
505
505
  isActive: boolean;
506
+ brandId: string;
506
507
  }[], Error>;
507
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<{
508
509
  isOnSale: boolean;
@@ -669,6 +670,7 @@ export declare function useGetProduct(productId: string, options?: Omit<UseQuery
669
670
  metaPixelId: string;
670
671
  tiktokPixelId: string;
671
672
  paystackPublicKey: string;
673
+ freeShippingThreshold: number;
672
674
  createdAt: string;
673
675
  updatedAt: string;
674
676
  deletedAt: string;
@@ -987,8 +989,8 @@ export declare function useGetProduct(productId: string, options?: Omit<UseQuery
987
989
  createdAt: string;
988
990
  updatedAt: string;
989
991
  deletedAt: string;
990
- brandId: string;
991
992
  isActive: boolean;
993
+ brandId: string;
992
994
  discountType: import("@prisma/client").$Enums.DiscountType;
993
995
  discountValue: string;
994
996
  startDate: string;
@@ -1002,8 +1004,8 @@ export declare function useGetProduct(productId: string, options?: Omit<UseQuery
1002
1004
  createdAt: string;
1003
1005
  updatedAt: string;
1004
1006
  deletedAt: string;
1005
- brandId: string;
1006
1007
  isActive: boolean;
1008
+ brandId: string;
1007
1009
  }, Error>;
1008
1010
  export declare function useCreateProduct(options?: UseMutationOptions<any, Error, any>): import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
1009
1011
  export declare function useUpdateProduct(productId: string, options?: UseMutationOptions<any, Error, any>): import("@tanstack/react-query").UseMutationResult<any, Error, any, unknown>;
@@ -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,25 +42,33 @@ 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
- createdAt: string;
45
- updatedAt: string;
46
- deletedAt: string;
47
59
  id: string;
48
60
  name: string;
49
61
  slug: string;
50
- logoUrl: string | null;
62
+ logoUrl: string;
51
63
  siteUrl: string;
52
64
  domain: string;
53
- metaPixelId: string | null;
54
- tiktokPixelId: string | null;
55
- paystackPublicKey: string | null;
56
- paystackSecretKey: string | null;
65
+ metaPixelId: string;
66
+ tiktokPixelId: string;
67
+ paystackPublicKey: string;
68
+ freeShippingThreshold: number;
69
+ createdAt: string;
70
+ updatedAt: string;
71
+ deletedAt: string;
57
72
  };
58
73
  deliveryZone: {
59
74
  deliveryCost: number;
@@ -71,6 +86,7 @@ export declare function useGetStats(params?: {
71
86
  };
72
87
  id: string;
73
88
  name: string;
89
+ isActive: boolean;
74
90
  brandId: string | null;
75
91
  stateId: string;
76
92
  allowCOD: boolean;
@@ -79,7 +95,6 @@ export declare function useGetStats(params?: {
79
95
  estimatedDays: number | null;
80
96
  noteTitle: string | null;
81
97
  noteContent: string | null;
82
- isActive: boolean;
83
98
  };
84
99
  items: {
85
100
  priceAtPurchase: number;
@@ -95,8 +110,8 @@ export declare function useGetStats(params?: {
95
110
  id: string;
96
111
  name: string;
97
112
  slug: string;
98
- brandId: string;
99
113
  isActive: boolean;
114
+ brandId: string;
100
115
  description: string | null;
101
116
  thumbnailUrl: string | null;
102
117
  quantityDiscounts: string | number | boolean | {
@@ -539,8 +554,8 @@ export declare function useGetStats(params?: {
539
554
  id: string;
540
555
  name: string | null;
541
556
  isActive: boolean;
542
- thumbnailUrl: string | null;
543
557
  productId: string;
558
+ thumbnailUrl: string | null;
544
559
  sku: string;
545
560
  compareAtPrice: string;
546
561
  trackInventory: boolean;
@@ -552,16 +567,16 @@ export declare function useGetStats(params?: {
552
567
  deletedAt: string;
553
568
  id: string;
554
569
  name: string;
570
+ state: string | null;
555
571
  isActive: boolean;
556
572
  address: string | null;
557
573
  city: string | null;
558
- state: string | null;
559
574
  };
560
575
  id: string;
561
- orderId: string;
562
576
  variantId: string;
563
- warehouseId: string | null;
564
577
  quantity: number;
578
+ orderId: string;
579
+ warehouseId: string | null;
565
580
  }[];
566
581
  email: string | null;
567
582
  id: 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
  */
@@ -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;
@@ -30,6 +30,7 @@ export declare function useGetBrand(slug: string, options?: Omit<UseQueryOptions
30
30
  metaPixelId: string;
31
31
  tiktokPixelId: string;
32
32
  paystackPublicKey: string;
33
+ freeShippingThreshold: string;
33
34
  createdAt: string;
34
35
  updatedAt: string;
35
36
  }, Error>;