@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
@@ -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,30 +21,40 @@ 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
- createdAt: string;
36
- updatedAt: string;
37
- deletedAt: string;
38
45
  id: string;
39
46
  name: string;
40
47
  slug: string;
41
- logoUrl: string | null;
48
+ logoUrl: string;
42
49
  siteUrl: string;
43
50
  domain: string;
44
- metaPixelId: string | null;
45
- tiktokPixelId: string | null;
46
- paystackPublicKey: string | null;
47
- paystackSecretKey: string | null;
51
+ metaPixelId: string;
52
+ tiktokPixelId: string;
53
+ paystackPublicKey: string;
54
+ freeShippingThreshold: number;
55
+ createdAt: string;
56
+ updatedAt: string;
57
+ deletedAt: string;
48
58
  };
49
59
  deliveryZone: {
50
60
  deliveryCost: number;
@@ -62,6 +72,7 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
62
72
  };
63
73
  id: string;
64
74
  name: string;
75
+ isActive: boolean;
65
76
  brandId: string | null;
66
77
  stateId: string;
67
78
  allowCOD: boolean;
@@ -70,7 +81,6 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
70
81
  estimatedDays: number | null;
71
82
  noteTitle: string | null;
72
83
  noteContent: string | null;
73
- isActive: boolean;
74
84
  };
75
85
  items: {
76
86
  priceAtPurchase: number;
@@ -86,8 +96,8 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
86
96
  id: string;
87
97
  name: string;
88
98
  slug: string;
89
- brandId: string;
90
99
  isActive: boolean;
100
+ brandId: string;
91
101
  description: string | null;
92
102
  thumbnailUrl: string | null;
93
103
  quantityDiscounts: string | number | boolean | {
@@ -530,8 +540,8 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
530
540
  id: string;
531
541
  name: string | null;
532
542
  isActive: boolean;
533
- thumbnailUrl: string | null;
534
543
  productId: string;
544
+ thumbnailUrl: string | null;
535
545
  sku: string;
536
546
  compareAtPrice: string;
537
547
  trackInventory: boolean;
@@ -543,16 +553,16 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
543
553
  deletedAt: string;
544
554
  id: string;
545
555
  name: string;
556
+ state: string | null;
546
557
  isActive: boolean;
547
558
  address: string | null;
548
559
  city: string | null;
549
- state: string | null;
550
560
  };
551
561
  id: string;
552
- orderId: string;
553
562
  variantId: string;
554
- warehouseId: string | null;
555
563
  quantity: number;
564
+ orderId: string;
565
+ warehouseId: string | null;
556
566
  }[];
557
567
  email: string | null;
558
568
  id: 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,25 +619,33 @@ 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
- createdAt: string;
608
- updatedAt: string;
609
- deletedAt: string;
610
636
  id: string;
611
637
  name: string;
612
638
  slug: string;
613
- logoUrl: string | null;
639
+ logoUrl: string;
614
640
  siteUrl: string;
615
641
  domain: string;
616
- metaPixelId: string | null;
617
- tiktokPixelId: string | null;
618
- paystackPublicKey: string | null;
619
- paystackSecretKey: string | null;
642
+ metaPixelId: string;
643
+ tiktokPixelId: string;
644
+ paystackPublicKey: string;
645
+ freeShippingThreshold: number;
646
+ createdAt: string;
647
+ updatedAt: string;
648
+ deletedAt: string;
620
649
  };
621
650
  deliveryZone: {
622
651
  deliveryCost: number;
@@ -634,6 +663,7 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
634
663
  };
635
664
  id: string;
636
665
  name: string;
666
+ isActive: boolean;
637
667
  brandId: string | null;
638
668
  stateId: string;
639
669
  allowCOD: boolean;
@@ -642,7 +672,6 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
642
672
  estimatedDays: number | null;
643
673
  noteTitle: string | null;
644
674
  noteContent: string | null;
645
- isActive: boolean;
646
675
  };
647
676
  items: {
648
677
  priceAtPurchase: number;
@@ -658,8 +687,8 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
658
687
  id: string;
659
688
  name: string;
660
689
  slug: string;
661
- brandId: string;
662
690
  isActive: boolean;
691
+ brandId: string;
663
692
  description: string | null;
664
693
  thumbnailUrl: string | null;
665
694
  quantityDiscounts: string | number | boolean | {
@@ -1102,8 +1131,8 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
1102
1131
  id: string;
1103
1132
  name: string | null;
1104
1133
  isActive: boolean;
1105
- thumbnailUrl: string | null;
1106
1134
  productId: string;
1135
+ thumbnailUrl: string | null;
1107
1136
  sku: string;
1108
1137
  compareAtPrice: string;
1109
1138
  trackInventory: boolean;
@@ -1115,16 +1144,16 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
1115
1144
  deletedAt: string;
1116
1145
  id: string;
1117
1146
  name: string;
1147
+ state: string | null;
1118
1148
  isActive: boolean;
1119
1149
  address: string | null;
1120
1150
  city: string | null;
1121
- state: string | null;
1122
1151
  };
1123
1152
  id: string;
1124
- orderId: string;
1125
1153
  variantId: string;
1126
- warehouseId: string | null;
1127
1154
  quantity: number;
1155
+ orderId: string;
1156
+ warehouseId: string | null;
1128
1157
  }[];
1129
1158
  email: string | null;
1130
1159
  id: 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
  *
@@ -1330,6 +1396,7 @@ export declare function useGetOrderRecommendations(orderId: string | null | unde
1330
1396
  metaPixelId: string;
1331
1397
  tiktokPixelId: string;
1332
1398
  paystackPublicKey: string;
1399
+ freeShippingThreshold: number;
1333
1400
  createdAt: string;
1334
1401
  updatedAt: string;
1335
1402
  deletedAt: string;
@@ -1648,8 +1715,8 @@ export declare function useGetOrderRecommendations(orderId: string | null | unde
1648
1715
  createdAt: string;
1649
1716
  updatedAt: string;
1650
1717
  deletedAt: string;
1651
- brandId: string;
1652
1718
  isActive: boolean;
1719
+ brandId: string;
1653
1720
  discountType: import("@prisma/client").$Enums.DiscountType;
1654
1721
  discountValue: string;
1655
1722
  startDate: string;
@@ -1663,6 +1730,6 @@ export declare function useGetOrderRecommendations(orderId: string | null | unde
1663
1730
  createdAt: string;
1664
1731
  updatedAt: string;
1665
1732
  deletedAt: string;
1666
- brandId: string;
1667
1733
  isActive: boolean;
1734
+ brandId: string;
1668
1735
  }[], Error>;
@@ -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.com.ng', getAuthToken, onError, queryClient: externalQueryClient }) {
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,