@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.
@@ -7,4 +7,4 @@
7
7
  * These types provide end-to-end type safety between the backend API
8
8
  * and the frontend hooks/fetchers.
9
9
  */
10
- export type { CartsRPC, OrdersRPC, ProductsRPC, DeliveryZonesRPC, BrandsRPC, AdminOrdersRPC, AdminBrandsRPC, AdminProductsRPC, AdminVariantsRPC, AdminWarehousesRPC, AdminInventoryRPC, AdminCustomersRPC, AdminStatsRPC, AdminAbandonedCartsRPC, AdminDiscountCodesRPC, AdminDeliveryZonesRPC, ProductAddonsRPC, AdminProductAddonsRPC, AdminMediaRPC, AdminSalesRPC, } from '../../../apps/backend/src/http-app';
10
+ export type { CartsRPC, OrdersRPC, ProductsRPC, DeliveryZonesRPC, BrandsRPC, AdminOrdersRPC, AdminBrandsRPC, AdminProductsRPC, AdminVariantsRPC, AdminWarehousesRPC, AdminInventoryRPC, AdminCustomersRPC, AdminStatsRPC, AdminAbandonedCartsRPC, AdminDiscountCodesRPC, AdminDeliveryZonesRPC, ProductAddonsRPC, AdminProductAddonsRPC, AdminMediaRPC, AdminSalesRPC, AdminDispatchRidersRPC, } from '../../../apps/backend/src/http-app';
@@ -5,7 +5,7 @@
5
5
  * They can also be imported directly in Server Components.
6
6
  */
7
7
  import { createRpcClients } from '../rpc-client';
8
- const API_URL = 'https://oms-api.instock.com.ng';
8
+ const API_URL = 'https://oms-api.instock.ng';
9
9
  /**
10
10
  * Fetch brand configuration by slug
11
11
  *
@@ -4449,11 +4449,19 @@ export declare function checkoutCart(cartId: string, checkoutData: {
4449
4449
  deliveryCharge: number;
4450
4450
  totalPrice: number;
4451
4451
  discountAmount: number;
4452
+ amountPaid: number;
4453
+ flutterwaveAccountBank: string;
4454
+ flutterwaveAccountNumber: string;
4455
+ flutterwaveAccountExpiry: string;
4452
4456
  createdAt: string;
4453
4457
  updatedAt: string;
4454
4458
  deletedAt: string;
4455
4459
  prospectSince: string;
4456
4460
  lastRecoveryAttemptAt: string;
4461
+ shippedAt: string;
4462
+ deliveryConfirmationSentAt: string;
4463
+ deliveryConfirmedAt: string;
4464
+ deliveryConfirmationAttempts: number;
4457
4465
  brand: {
4458
4466
  id: string;
4459
4467
  name: string;
@@ -4996,8 +5004,19 @@ export declare function checkoutCart(cartId: string, checkoutData: {
4996
5004
  paystackReference: string | null;
4997
5005
  status: import("@prisma/client").$Enums.OrderStatus;
4998
5006
  cancellationReason: string | null;
5007
+ shippingMethod: string | null;
5008
+ dispatchRiderId: string | null;
5009
+ fezTrackingNumber: string | null;
5010
+ flutterwaveOrderRef: string | null;
5011
+ flutterwaveCustomerId: string | null;
4999
5012
  prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
5000
5013
  userActionToken: string;
5014
+ labelPrintedAt: string;
5015
+ dispatchRider?: {
5016
+ id: string;
5017
+ name: string;
5018
+ phone: string;
5019
+ };
5001
5020
  }>;
5002
5021
  /**
5003
5022
  * Initiate checkout tracking
@@ -4,7 +4,7 @@
4
4
  * They can also be imported directly in Server Components.
5
5
  */
6
6
  import { createRpcClients } from '../rpc-client';
7
- const API_URL = 'https://oms-api.instock.com.ng';
7
+ const API_URL = 'https://oms-api.instock.ng';
8
8
  /**
9
9
  * Fetch a cart by ID
10
10
  *
@@ -5,7 +5,7 @@
5
5
  * They can also be imported directly in Server Components.
6
6
  */
7
7
  import { createRpcClients } from '../rpc-client';
8
- const API_URL = 'https://oms-api.instock.com.ng';
8
+ const API_URL = 'https://oms-api.instock.ng';
9
9
  /**
10
10
  * Fetch delivery zones
11
11
  *
@@ -13,16 +13,26 @@
13
13
  */
14
14
  export declare function fetchOrder(orderId: string, token: string): Promise<{
15
15
  canConfirm: boolean;
16
+ canConfirmDelivery: boolean;
17
+ canUpdateAddress: boolean;
16
18
  confirmationMessage: string;
17
19
  subtotal: number;
18
20
  deliveryCharge: number;
19
21
  totalPrice: number;
20
22
  discountAmount: number;
23
+ amountPaid: number;
24
+ flutterwaveAccountBank: string;
25
+ flutterwaveAccountNumber: string;
26
+ flutterwaveAccountExpiry: string;
21
27
  createdAt: string;
22
28
  updatedAt: string;
23
29
  deletedAt: string;
24
30
  prospectSince: string;
25
31
  lastRecoveryAttemptAt: string;
32
+ shippedAt: string;
33
+ deliveryConfirmationSentAt: string;
34
+ deliveryConfirmedAt: string;
35
+ deliveryConfirmationAttempts: number;
26
36
  brand: {
27
37
  id: string;
28
38
  name: string;
@@ -565,8 +575,19 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
565
575
  paystackReference: string | null;
566
576
  status: import("@prisma/client").$Enums.OrderStatus;
567
577
  cancellationReason: string | null;
578
+ shippingMethod: string | null;
579
+ dispatchRiderId: string | null;
580
+ fezTrackingNumber: string | null;
581
+ flutterwaveOrderRef: string | null;
582
+ flutterwaveCustomerId: string | null;
568
583
  prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
569
584
  userActionToken: string;
585
+ labelPrintedAt: string;
586
+ dispatchRider?: {
587
+ id: string;
588
+ name: string;
589
+ phone: string;
590
+ };
570
591
  }>;
571
592
  /**
572
593
  * Confirm a prospect order
@@ -580,11 +601,19 @@ export declare function confirmOrder(orderId: string, token: string): Promise<{
580
601
  deliveryCharge: number;
581
602
  totalPrice: number;
582
603
  discountAmount: number;
604
+ amountPaid: number;
605
+ flutterwaveAccountBank: string;
606
+ flutterwaveAccountNumber: string;
607
+ flutterwaveAccountExpiry: string;
583
608
  createdAt: string;
584
609
  updatedAt: string;
585
610
  deletedAt: string;
586
611
  prospectSince: string;
587
612
  lastRecoveryAttemptAt: string;
613
+ shippedAt: string;
614
+ deliveryConfirmationSentAt: string;
615
+ deliveryConfirmedAt: string;
616
+ deliveryConfirmationAttempts: number;
588
617
  brand: {
589
618
  id: string;
590
619
  name: string;
@@ -1127,9 +1156,43 @@ export declare function confirmOrder(orderId: string, token: string): Promise<{
1127
1156
  paystackReference: string | null;
1128
1157
  status: import("@prisma/client").$Enums.OrderStatus;
1129
1158
  cancellationReason: string | null;
1159
+ shippingMethod: string | null;
1160
+ dispatchRiderId: string | null;
1161
+ fezTrackingNumber: string | null;
1162
+ flutterwaveOrderRef: string | null;
1163
+ flutterwaveCustomerId: string | null;
1130
1164
  prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
1131
1165
  userActionToken: string;
1166
+ labelPrintedAt: string;
1167
+ dispatchRider?: {
1168
+ id: string;
1169
+ name: string;
1170
+ phone: string;
1171
+ };
1132
1172
  }>;
1173
+ /**
1174
+ * Confirm delivery details for an order
1175
+ *
1176
+ * @param orderId - Order UUID
1177
+ * @param token - User action token
1178
+ * @returns Updated order
1179
+ */
1180
+ export declare function confirmDelivery(orderId: string, token: string): Promise<any>;
1181
+ /**
1182
+ * Update delivery address for an order
1183
+ *
1184
+ * @param orderId - Order UUID
1185
+ * @param token - User action token
1186
+ * @param address - Updated address
1187
+ * @param city - Updated city
1188
+ * @param phone - Updated phone
1189
+ * @returns Updated order
1190
+ */
1191
+ export declare function updateDeliveryAddress(orderId: string, token: string, updates: {
1192
+ address?: string;
1193
+ city?: string;
1194
+ phone?: string;
1195
+ }): Promise<any>;
1133
1196
  /**
1134
1197
  * Fetch order recommendations for post-purchase upsell
1135
1198
  *
@@ -5,7 +5,7 @@
5
5
  * They can also be imported directly in Server Components.
6
6
  */
7
7
  import { createRpcClients } from '../rpc-client';
8
- const API_URL = 'https://oms-api.instock.com.ng';
8
+ const API_URL = 'https://oms-api.instock.ng';
9
9
  /**
10
10
  * Fetch an order by ID and token
11
11
  *
@@ -40,6 +40,43 @@ export async function confirmOrder(orderId, token) {
40
40
  }
41
41
  return res.json();
42
42
  }
43
+ /**
44
+ * Confirm delivery details for an order
45
+ *
46
+ * @param orderId - Order UUID
47
+ * @param token - User action token
48
+ * @returns Updated order
49
+ */
50
+ export async function confirmDelivery(orderId, token) {
51
+ const clients = createRpcClients(API_URL);
52
+ const res = await clients.orders['confirm-delivery'].$post({
53
+ json: { orderId, token },
54
+ });
55
+ if (!res.ok) {
56
+ throw new Error(`Failed to confirm delivery: ${res.statusText}`);
57
+ }
58
+ return res.json();
59
+ }
60
+ /**
61
+ * Update delivery address for an order
62
+ *
63
+ * @param orderId - Order UUID
64
+ * @param token - User action token
65
+ * @param address - Updated address
66
+ * @param city - Updated city
67
+ * @param phone - Updated phone
68
+ * @returns Updated order
69
+ */
70
+ export async function updateDeliveryAddress(orderId, token, updates) {
71
+ const clients = createRpcClients(API_URL);
72
+ const res = await clients.orders['update-delivery-address'].$post({
73
+ json: { orderId, token, ...updates },
74
+ });
75
+ if (!res.ok) {
76
+ throw new Error(`Failed to update delivery address: ${res.statusText}`);
77
+ }
78
+ return res.json();
79
+ }
43
80
  /**
44
81
  * Fetch order recommendations for post-purchase upsell
45
82
  *
@@ -5,7 +5,7 @@
5
5
  * They can also be imported directly in Server Components.
6
6
  */
7
7
  import { createRpcClients } from '../rpc-client';
8
- const API_URL = 'https://oms-api.instock.com.ng';
8
+ const API_URL = 'https://oms-api.instock.ng';
9
9
  /**
10
10
  * Fetch products by brand slug
11
11
  *
@@ -22,11 +22,19 @@ export declare function useGetCustomerHistory(phone: string, options?: Omit<UseQ
22
22
  deliveryCharge: number;
23
23
  totalPrice: number;
24
24
  discountAmount: number;
25
+ amountPaid: number;
26
+ flutterwaveAccountBank: string;
27
+ flutterwaveAccountNumber: string;
28
+ flutterwaveAccountExpiry: string;
25
29
  createdAt: string;
26
30
  updatedAt: string;
27
31
  deletedAt: string;
28
32
  prospectSince: string;
29
33
  lastRecoveryAttemptAt: string;
34
+ shippedAt: string;
35
+ deliveryConfirmationSentAt: string;
36
+ deliveryConfirmedAt: string;
37
+ deliveryConfirmationAttempts: number;
30
38
  brand: {
31
39
  id: string;
32
40
  name: string;
@@ -569,7 +577,18 @@ export declare function useGetCustomerHistory(phone: string, options?: Omit<UseQ
569
577
  paystackReference: string | null;
570
578
  status: import("@prisma/client").$Enums.OrderStatus;
571
579
  cancellationReason: string | null;
580
+ shippingMethod: string | null;
581
+ dispatchRiderId: string | null;
582
+ fezTrackingNumber: string | null;
583
+ flutterwaveOrderRef: string | null;
584
+ flutterwaveCustomerId: string | null;
572
585
  prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
573
586
  userActionToken: string;
587
+ labelPrintedAt: string;
588
+ dispatchRider?: {
589
+ id: string;
590
+ name: string;
591
+ phone: string;
592
+ };
574
593
  }[];
575
594
  }, Error>;
@@ -0,0 +1,59 @@
1
+ /**
2
+ * Type-safe admin RPC hooks for dispatch rider management
3
+ */
4
+ import { UseQueryOptions, UseMutationOptions } from '@tanstack/react-query';
5
+ import { createAdminRpcClients } from '../../rpc-client';
6
+ /**
7
+ * Hook to list all dispatch riders using admin RPC
8
+ */
9
+ export declare function useListDispatchRiders(options?: Omit<UseQueryOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['dispatchRiders']['index']['$get']>>['json']>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
10
+ id: string;
11
+ name: string;
12
+ createdAt: string;
13
+ updatedAt: string;
14
+ deletedAt: string;
15
+ phone: string;
16
+ }[], Error>;
17
+ /**
18
+ * Hook to create a dispatch rider using admin RPC
19
+ */
20
+ export declare function useCreateDispatchRider(options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['dispatchRiders']['index']['$post']>>['json']>>, Error, any>): import("@tanstack/react-query").UseMutationResult<{
21
+ id: string;
22
+ name: string;
23
+ createdAt: string;
24
+ updatedAt: string;
25
+ deletedAt: string;
26
+ phone: string;
27
+ } | {
28
+ error: {
29
+ code: string;
30
+ message: string;
31
+ };
32
+ }, Error, any, unknown>;
33
+ /**
34
+ * Hook to update a dispatch rider using admin RPC
35
+ */
36
+ export declare function useUpdateDispatchRider(riderId: string, options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['dispatchRiders'][':id']['$patch']>>['json']>>, Error, any>): import("@tanstack/react-query").UseMutationResult<{
37
+ id: string;
38
+ name: string;
39
+ createdAt: string;
40
+ updatedAt: string;
41
+ deletedAt: string;
42
+ phone: string;
43
+ } | {
44
+ error: {
45
+ code: string;
46
+ message: string;
47
+ };
48
+ }, Error, any, unknown>;
49
+ /**
50
+ * Hook to delete a dispatch rider using admin RPC
51
+ */
52
+ export declare function useDeleteDispatchRider(riderId: string, options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['dispatchRiders'][':id']['$delete']>>['json']>>, Error, void>): import("@tanstack/react-query").UseMutationResult<{
53
+ success: true;
54
+ } | {
55
+ error: {
56
+ code: string;
57
+ message: string;
58
+ };
59
+ }, Error, void, unknown>;
@@ -0,0 +1,92 @@
1
+ /**
2
+ * Type-safe admin RPC hooks for dispatch rider 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 all dispatch riders using admin RPC
11
+ */
12
+ export function useListDispatchRiders(options) {
13
+ const { baseURL, getAuthToken } = useApiConfig();
14
+ return useQueryUnwrapped({
15
+ queryKey: queryKeys.admin.dispatchRiders.list(),
16
+ queryFn: async () => {
17
+ const token = await getAuthToken();
18
+ const clients = createAdminRpcClients(baseURL);
19
+ const res = await clients.dispatchRiders.index.$get({}, authHeaders(token));
20
+ if (!res.ok)
21
+ throw new Error(`Failed to fetch dispatch riders: ${res.statusText}`);
22
+ return res.json();
23
+ },
24
+ ...options,
25
+ });
26
+ }
27
+ /**
28
+ * Hook to create a dispatch rider using admin RPC
29
+ */
30
+ export function useCreateDispatchRider(options) {
31
+ const { baseURL, getAuthToken } = useApiConfig();
32
+ const queryClient = useQueryClient();
33
+ return useMutation({
34
+ ...options,
35
+ mutationFn: async (data) => {
36
+ const token = await getAuthToken();
37
+ const clients = createAdminRpcClients(baseURL);
38
+ const res = await clients.dispatchRiders.index.$post({ json: data }, authHeaders(token));
39
+ if (!res.ok)
40
+ throw new Error(`Failed to create dispatch rider: ${res.statusText}`);
41
+ return res.json();
42
+ },
43
+ onSuccess: (...args) => {
44
+ queryClient.invalidateQueries({ queryKey: queryKeys.admin.dispatchRiders.all });
45
+ options?.onSuccess?.(...args);
46
+ },
47
+ });
48
+ }
49
+ /**
50
+ * Hook to update a dispatch rider using admin RPC
51
+ */
52
+ export function useUpdateDispatchRider(riderId, options) {
53
+ const { baseURL, getAuthToken } = useApiConfig();
54
+ const queryClient = useQueryClient();
55
+ return useMutation({
56
+ ...options,
57
+ mutationFn: async (data) => {
58
+ const token = await getAuthToken();
59
+ const clients = createAdminRpcClients(baseURL);
60
+ const res = await clients.dispatchRiders[':id'].$patch({ json: data, param: { id: riderId } }, authHeaders(token));
61
+ if (!res.ok)
62
+ throw new Error(`Failed to update dispatch rider: ${res.statusText}`);
63
+ return res.json();
64
+ },
65
+ onSuccess: (...args) => {
66
+ queryClient.invalidateQueries({ queryKey: queryKeys.admin.dispatchRiders.all });
67
+ options?.onSuccess?.(...args);
68
+ },
69
+ });
70
+ }
71
+ /**
72
+ * Hook to delete a dispatch rider using admin RPC
73
+ */
74
+ export function useDeleteDispatchRider(riderId, options) {
75
+ const { baseURL, getAuthToken } = useApiConfig();
76
+ const queryClient = useQueryClient();
77
+ return useMutation({
78
+ ...options,
79
+ mutationFn: async () => {
80
+ const token = await getAuthToken();
81
+ const clients = createAdminRpcClients(baseURL);
82
+ const res = await clients.dispatchRiders[':id'].$delete({ param: { id: riderId } }, authHeaders(token));
83
+ if (!res.ok)
84
+ throw new Error(`Failed to delete dispatch rider: ${res.statusText}`);
85
+ return res.json();
86
+ },
87
+ onSuccess: (...args) => {
88
+ queryClient.invalidateQueries({ queryKey: queryKeys.admin.dispatchRiders.all });
89
+ options?.onSuccess?.(...args);
90
+ },
91
+ });
92
+ }
@@ -16,3 +16,4 @@ export * from './warehouses';
16
16
  export * from './abandoned-carts';
17
17
  export * from './media';
18
18
  export * from './sales';
19
+ export * from './dispatch-riders';
@@ -16,3 +16,4 @@ export * from './warehouses';
16
16
  export * from './abandoned-carts';
17
17
  export * from './media';
18
18
  export * from './sales';
19
+ export * from './dispatch-riders';