@instockng/api-client 1.0.36 → 1.0.39
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 +586 -1
- package/dist/fetchers/carts.js +19 -3
- package/dist/fetchers/delivery-zones.js +1 -1
- package/dist/fetchers/orders.d.ts +82 -0
- package/dist/fetchers/orders.js +38 -1
- package/dist/fetchers/products.js +1 -1
- package/dist/hooks/admin/abandoned-carts.d.ts +8 -0
- package/dist/hooks/admin/brands.d.ts +4 -0
- package/dist/hooks/admin/customers.d.ts +27 -0
- package/dist/hooks/admin/delivery-zones.d.ts +4 -0
- package/dist/hooks/admin/discount-codes.d.ts +5 -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 +191 -0
- package/dist/hooks/admin/orders.js +93 -0
- package/dist/hooks/admin/products.d.ts +6 -0
- package/dist/hooks/admin/stats.d.ts +34 -0
- package/dist/hooks/admin/stats.js +20 -0
- package/dist/hooks/admin/variants.d.ts +10 -0
- package/dist/hooks/admin/warehouses.d.ts +2 -0
- package/dist/hooks/public/carts.d.ts +585 -1
- package/dist/hooks/public/carts.js +20 -2
- package/dist/hooks/public/orders.d.ts +86 -1
- package/dist/hooks/public/orders.js +23 -1
- package/dist/provider.js +1 -1
- package/dist/rpc-client.d.ts +5456 -1769
- package/dist/rpc-client.js +1 -0
- package/dist/rpc-types.d.ts +9 -0
- package/dist/utils/query-keys.d.ts +7 -0
- package/dist/utils/query-keys.js +7 -0
- package/package.json +7 -8
package/dist/fetchers/carts.js
CHANGED
|
@@ -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.
|
|
7
|
+
const API_URL = 'https://oms-api.instock.ng';
|
|
8
8
|
/**
|
|
9
9
|
* Fetch a cart by ID
|
|
10
10
|
*
|
|
@@ -68,12 +68,12 @@ export async function updateCart(cartId, data) {
|
|
|
68
68
|
* @param ttclid - TikTok Click ID (URL parameter) (optional)
|
|
69
69
|
* @returns Updated cart
|
|
70
70
|
*/
|
|
71
|
-
export async function addCartItem(cartId, sku, quantity, fbc, fbp, ttp, ttclid) {
|
|
71
|
+
export async function addCartItem(cartId, sku, quantity, fbc, fbp, ttp, ttclid, fromUpsell, upsellDiscountPercent) {
|
|
72
72
|
const clients = createRpcClients(API_URL);
|
|
73
73
|
const res = await clients.carts[':id'].items.$post({
|
|
74
74
|
param: { id: cartId },
|
|
75
75
|
// @ts-expect-error - Hono RPC type inference issue
|
|
76
|
-
json: { sku, quantity, fbc, fbp, ttp, ttclid },
|
|
76
|
+
json: { sku, quantity, fbc, fbp, ttp, ttclid, fromUpsell, upsellDiscountPercent },
|
|
77
77
|
});
|
|
78
78
|
if (!res.ok) {
|
|
79
79
|
throw new Error(`Failed to add item to cart: ${res.statusText}`);
|
|
@@ -190,6 +190,22 @@ export async function initiateCheckout(cartId, data) {
|
|
|
190
190
|
}
|
|
191
191
|
return res.json();
|
|
192
192
|
}
|
|
193
|
+
/**
|
|
194
|
+
* Fetch discounted upsell add-ons for a cart
|
|
195
|
+
*
|
|
196
|
+
* @param cartId - Cart UUID
|
|
197
|
+
* @returns Array of cart items with their discounted add-on products
|
|
198
|
+
*/
|
|
199
|
+
export async function fetchCartUpsellAddons(cartId) {
|
|
200
|
+
const clients = createRpcClients(API_URL);
|
|
201
|
+
const res = await clients.carts[':id']['upsell-addons'].$get({
|
|
202
|
+
param: { id: cartId },
|
|
203
|
+
});
|
|
204
|
+
if (!res.ok) {
|
|
205
|
+
throw new Error(`Failed to fetch upsell add-ons: ${res.statusText}`);
|
|
206
|
+
}
|
|
207
|
+
return res.json();
|
|
208
|
+
}
|
|
193
209
|
/**
|
|
194
210
|
* Fetch recommended products for a cart
|
|
195
211
|
*
|
|
@@ -13,16 +13,30 @@
|
|
|
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;
|
|
20
|
+
totalCost: number;
|
|
21
|
+
totalProfit: number;
|
|
22
|
+
profitMargin: number;
|
|
18
23
|
deliveryCharge: number;
|
|
19
24
|
totalPrice: number;
|
|
20
25
|
discountAmount: number;
|
|
26
|
+
amountPaid: number;
|
|
27
|
+
flutterwaveAccountBank: string;
|
|
28
|
+
flutterwaveAccountNumber: string;
|
|
29
|
+
flutterwaveAccountExpiry: string;
|
|
21
30
|
createdAt: string;
|
|
22
31
|
updatedAt: string;
|
|
23
32
|
deletedAt: string;
|
|
24
33
|
prospectSince: string;
|
|
25
34
|
lastRecoveryAttemptAt: string;
|
|
35
|
+
shippedAt: string;
|
|
36
|
+
deliveryConfirmationSentAt: string;
|
|
37
|
+
deliveryConfirmedAt: string;
|
|
38
|
+
deliveryConfirmationAttempts: number;
|
|
39
|
+
needsManualCall: boolean;
|
|
26
40
|
brand: {
|
|
27
41
|
id: string;
|
|
28
42
|
name: string;
|
|
@@ -34,6 +48,7 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
|
|
|
34
48
|
tiktokPixelId: string;
|
|
35
49
|
paystackPublicKey: string;
|
|
36
50
|
freeShippingThreshold: number;
|
|
51
|
+
upsellDiscountPercent: number;
|
|
37
52
|
createdAt: string;
|
|
38
53
|
updatedAt: string;
|
|
39
54
|
deletedAt: string;
|
|
@@ -66,6 +81,8 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
|
|
|
66
81
|
};
|
|
67
82
|
items: {
|
|
68
83
|
priceAtPurchase: number;
|
|
84
|
+
costAtPurchase: number;
|
|
85
|
+
itemProfit: number;
|
|
69
86
|
variant: {
|
|
70
87
|
price: number;
|
|
71
88
|
createdAt: string;
|
|
@@ -525,6 +542,7 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
|
|
|
525
542
|
productId: string;
|
|
526
543
|
thumbnailUrl: string | null;
|
|
527
544
|
sku: string;
|
|
545
|
+
costPrice: string;
|
|
528
546
|
compareAtPrice: string;
|
|
529
547
|
trackInventory: boolean;
|
|
530
548
|
lowStockThreshold: number | null;
|
|
@@ -565,8 +583,19 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
|
|
|
565
583
|
paystackReference: string | null;
|
|
566
584
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
567
585
|
cancellationReason: string | null;
|
|
586
|
+
shippingMethod: string | null;
|
|
587
|
+
dispatchRiderId: string | null;
|
|
588
|
+
fezTrackingNumber: string | null;
|
|
589
|
+
flutterwaveOrderRef: string | null;
|
|
590
|
+
flutterwaveCustomerId: string | null;
|
|
568
591
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
569
592
|
userActionToken: string;
|
|
593
|
+
labelPrintedAt: string;
|
|
594
|
+
dispatchRider?: {
|
|
595
|
+
id: string;
|
|
596
|
+
name: string;
|
|
597
|
+
phone: string;
|
|
598
|
+
};
|
|
570
599
|
}>;
|
|
571
600
|
/**
|
|
572
601
|
* Confirm a prospect order
|
|
@@ -577,14 +606,26 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
|
|
|
577
606
|
*/
|
|
578
607
|
export declare function confirmOrder(orderId: string, token: string): Promise<{
|
|
579
608
|
subtotal: number;
|
|
609
|
+
totalCost: number;
|
|
610
|
+
totalProfit: number;
|
|
611
|
+
profitMargin: number;
|
|
580
612
|
deliveryCharge: number;
|
|
581
613
|
totalPrice: number;
|
|
582
614
|
discountAmount: number;
|
|
615
|
+
amountPaid: number;
|
|
616
|
+
flutterwaveAccountBank: string;
|
|
617
|
+
flutterwaveAccountNumber: string;
|
|
618
|
+
flutterwaveAccountExpiry: string;
|
|
583
619
|
createdAt: string;
|
|
584
620
|
updatedAt: string;
|
|
585
621
|
deletedAt: string;
|
|
586
622
|
prospectSince: string;
|
|
587
623
|
lastRecoveryAttemptAt: string;
|
|
624
|
+
shippedAt: string;
|
|
625
|
+
deliveryConfirmationSentAt: string;
|
|
626
|
+
deliveryConfirmedAt: string;
|
|
627
|
+
deliveryConfirmationAttempts: number;
|
|
628
|
+
needsManualCall: boolean;
|
|
588
629
|
brand: {
|
|
589
630
|
id: string;
|
|
590
631
|
name: string;
|
|
@@ -596,6 +637,7 @@ export declare function confirmOrder(orderId: string, token: string): Promise<{
|
|
|
596
637
|
tiktokPixelId: string;
|
|
597
638
|
paystackPublicKey: string;
|
|
598
639
|
freeShippingThreshold: number;
|
|
640
|
+
upsellDiscountPercent: number;
|
|
599
641
|
createdAt: string;
|
|
600
642
|
updatedAt: string;
|
|
601
643
|
deletedAt: string;
|
|
@@ -628,6 +670,8 @@ export declare function confirmOrder(orderId: string, token: string): Promise<{
|
|
|
628
670
|
};
|
|
629
671
|
items: {
|
|
630
672
|
priceAtPurchase: number;
|
|
673
|
+
costAtPurchase: number;
|
|
674
|
+
itemProfit: number;
|
|
631
675
|
variant: {
|
|
632
676
|
price: number;
|
|
633
677
|
createdAt: string;
|
|
@@ -1087,6 +1131,7 @@ export declare function confirmOrder(orderId: string, token: string): Promise<{
|
|
|
1087
1131
|
productId: string;
|
|
1088
1132
|
thumbnailUrl: string | null;
|
|
1089
1133
|
sku: string;
|
|
1134
|
+
costPrice: string;
|
|
1090
1135
|
compareAtPrice: string;
|
|
1091
1136
|
trackInventory: boolean;
|
|
1092
1137
|
lowStockThreshold: number | null;
|
|
@@ -1127,9 +1172,43 @@ export declare function confirmOrder(orderId: string, token: string): Promise<{
|
|
|
1127
1172
|
paystackReference: string | null;
|
|
1128
1173
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
1129
1174
|
cancellationReason: string | null;
|
|
1175
|
+
shippingMethod: string | null;
|
|
1176
|
+
dispatchRiderId: string | null;
|
|
1177
|
+
fezTrackingNumber: string | null;
|
|
1178
|
+
flutterwaveOrderRef: string | null;
|
|
1179
|
+
flutterwaveCustomerId: string | null;
|
|
1130
1180
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
1131
1181
|
userActionToken: string;
|
|
1182
|
+
labelPrintedAt: string;
|
|
1183
|
+
dispatchRider?: {
|
|
1184
|
+
id: string;
|
|
1185
|
+
name: string;
|
|
1186
|
+
phone: string;
|
|
1187
|
+
};
|
|
1132
1188
|
}>;
|
|
1189
|
+
/**
|
|
1190
|
+
* Confirm delivery details for an order
|
|
1191
|
+
*
|
|
1192
|
+
* @param orderId - Order UUID
|
|
1193
|
+
* @param token - User action token
|
|
1194
|
+
* @returns Updated order
|
|
1195
|
+
*/
|
|
1196
|
+
export declare function confirmDelivery(orderId: string, token: string): Promise<any>;
|
|
1197
|
+
/**
|
|
1198
|
+
* Update delivery address for an order
|
|
1199
|
+
*
|
|
1200
|
+
* @param orderId - Order UUID
|
|
1201
|
+
* @param token - User action token
|
|
1202
|
+
* @param address - Updated address
|
|
1203
|
+
* @param city - Updated city
|
|
1204
|
+
* @param phone - Updated phone
|
|
1205
|
+
* @returns Updated order
|
|
1206
|
+
*/
|
|
1207
|
+
export declare function updateDeliveryAddress(orderId: string, token: string, updates: {
|
|
1208
|
+
address?: string;
|
|
1209
|
+
city?: string;
|
|
1210
|
+
phone?: string;
|
|
1211
|
+
}): Promise<any>;
|
|
1133
1212
|
/**
|
|
1134
1213
|
* Fetch order recommendations for post-purchase upsell
|
|
1135
1214
|
*
|
|
@@ -1304,6 +1383,7 @@ export declare function fetchOrderRecommendations(orderId: string, token: string
|
|
|
1304
1383
|
tiktokPixelId: string;
|
|
1305
1384
|
paystackPublicKey: string;
|
|
1306
1385
|
freeShippingThreshold: number;
|
|
1386
|
+
upsellDiscountPercent: number;
|
|
1307
1387
|
createdAt: string;
|
|
1308
1388
|
updatedAt: string;
|
|
1309
1389
|
deletedAt: string;
|
|
@@ -1312,9 +1392,11 @@ export declare function fetchOrderRecommendations(orderId: string, token: string
|
|
|
1312
1392
|
createdAt: string;
|
|
1313
1393
|
updatedAt: string;
|
|
1314
1394
|
price: number;
|
|
1395
|
+
costPrice: number;
|
|
1315
1396
|
compareAtPrice: number;
|
|
1316
1397
|
deletedAt: string;
|
|
1317
1398
|
thumbnailUrl: string;
|
|
1399
|
+
rawThumbnailUrl: string;
|
|
1318
1400
|
originalPrice: number;
|
|
1319
1401
|
id: string;
|
|
1320
1402
|
name: string | null;
|
package/dist/fetchers/orders.js
CHANGED
|
@@ -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.
|
|
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
|
*
|
|
@@ -23,6 +23,7 @@ export declare function useListAbandonedCarts(params?: {
|
|
|
23
23
|
tiktokPixelId: string;
|
|
24
24
|
paystackPublicKey: string;
|
|
25
25
|
freeShippingThreshold: number;
|
|
26
|
+
upsellDiscountPercent: number;
|
|
26
27
|
createdAt: string;
|
|
27
28
|
updatedAt: string;
|
|
28
29
|
deletedAt: string;
|
|
@@ -514,9 +515,11 @@ export declare function useListAbandonedCarts(params?: {
|
|
|
514
515
|
createdAt: string;
|
|
515
516
|
updatedAt: string;
|
|
516
517
|
price: number;
|
|
518
|
+
costPrice: number;
|
|
517
519
|
compareAtPrice: number;
|
|
518
520
|
deletedAt: string;
|
|
519
521
|
thumbnailUrl: string;
|
|
522
|
+
rawThumbnailUrl: string;
|
|
520
523
|
originalPrice: number;
|
|
521
524
|
id: string;
|
|
522
525
|
name: string | null;
|
|
@@ -527,6 +530,7 @@ export declare function useListAbandonedCarts(params?: {
|
|
|
527
530
|
lowStockThreshold: number | null;
|
|
528
531
|
};
|
|
529
532
|
quantity: number;
|
|
533
|
+
priceOverride: number;
|
|
530
534
|
basePrice: number;
|
|
531
535
|
discountPercent: number;
|
|
532
536
|
finalPrice: number;
|
|
@@ -585,6 +589,7 @@ export declare function useGetAbandonedCart(cartId: string, options?: Omit<UseQu
|
|
|
585
589
|
tiktokPixelId: string;
|
|
586
590
|
paystackPublicKey: string;
|
|
587
591
|
freeShippingThreshold: number;
|
|
592
|
+
upsellDiscountPercent: number;
|
|
588
593
|
createdAt: string;
|
|
589
594
|
updatedAt: string;
|
|
590
595
|
deletedAt: string;
|
|
@@ -1076,9 +1081,11 @@ export declare function useGetAbandonedCart(cartId: string, options?: Omit<UseQu
|
|
|
1076
1081
|
createdAt: string;
|
|
1077
1082
|
updatedAt: string;
|
|
1078
1083
|
price: number;
|
|
1084
|
+
costPrice: number;
|
|
1079
1085
|
compareAtPrice: number;
|
|
1080
1086
|
deletedAt: string;
|
|
1081
1087
|
thumbnailUrl: string;
|
|
1088
|
+
rawThumbnailUrl: string;
|
|
1082
1089
|
originalPrice: number;
|
|
1083
1090
|
id: string;
|
|
1084
1091
|
name: string | null;
|
|
@@ -1089,6 +1096,7 @@ export declare function useGetAbandonedCart(cartId: string, options?: Omit<UseQu
|
|
|
1089
1096
|
lowStockThreshold: number | null;
|
|
1090
1097
|
};
|
|
1091
1098
|
quantity: number;
|
|
1099
|
+
priceOverride: number;
|
|
1092
1100
|
basePrice: number;
|
|
1093
1101
|
discountPercent: number;
|
|
1094
1102
|
finalPrice: number;
|
|
@@ -18,6 +18,7 @@ export declare function useListBrands(options?: Omit<UseQueryOptions<Awaited<Ret
|
|
|
18
18
|
paystackPublicKey: string | null;
|
|
19
19
|
paystackSecretKey: string | null;
|
|
20
20
|
freeShippingThreshold: string;
|
|
21
|
+
upsellDiscountPercent: number;
|
|
21
22
|
createdAt: string;
|
|
22
23
|
updatedAt: string;
|
|
23
24
|
deletedAt: string;
|
|
@@ -37,6 +38,7 @@ export declare function useGetBrand(brandId: string, options?: Omit<UseQueryOpti
|
|
|
37
38
|
paystackPublicKey: string | null;
|
|
38
39
|
paystackSecretKey: string | null;
|
|
39
40
|
freeShippingThreshold: string;
|
|
41
|
+
upsellDiscountPercent: number;
|
|
40
42
|
createdAt: string;
|
|
41
43
|
updatedAt: string;
|
|
42
44
|
deletedAt: string;
|
|
@@ -56,6 +58,7 @@ export declare function useCreateBrand(options?: UseMutationOptions<Awaited<Retu
|
|
|
56
58
|
paystackPublicKey: string | null;
|
|
57
59
|
paystackSecretKey: string | null;
|
|
58
60
|
freeShippingThreshold: string;
|
|
61
|
+
upsellDiscountPercent: number;
|
|
59
62
|
createdAt: string;
|
|
60
63
|
updatedAt: string;
|
|
61
64
|
deletedAt: string;
|
|
@@ -80,6 +83,7 @@ export declare function useUpdateBrand(brandId: string, options?: UseMutationOpt
|
|
|
80
83
|
paystackPublicKey: string | null;
|
|
81
84
|
paystackSecretKey: string | null;
|
|
82
85
|
freeShippingThreshold: string;
|
|
86
|
+
upsellDiscountPercent: number;
|
|
83
87
|
createdAt: string;
|
|
84
88
|
updatedAt: string;
|
|
85
89
|
deletedAt: string;
|
|
@@ -19,14 +19,26 @@ export declare function useGetCustomerHistory(phone: string, options?: Omit<UseQ
|
|
|
19
19
|
};
|
|
20
20
|
orders: {
|
|
21
21
|
subtotal: number;
|
|
22
|
+
totalCost: number;
|
|
23
|
+
totalProfit: number;
|
|
24
|
+
profitMargin: number;
|
|
22
25
|
deliveryCharge: number;
|
|
23
26
|
totalPrice: number;
|
|
24
27
|
discountAmount: number;
|
|
28
|
+
amountPaid: number;
|
|
29
|
+
flutterwaveAccountBank: string;
|
|
30
|
+
flutterwaveAccountNumber: string;
|
|
31
|
+
flutterwaveAccountExpiry: string;
|
|
25
32
|
createdAt: string;
|
|
26
33
|
updatedAt: string;
|
|
27
34
|
deletedAt: string;
|
|
28
35
|
prospectSince: string;
|
|
29
36
|
lastRecoveryAttemptAt: string;
|
|
37
|
+
shippedAt: string;
|
|
38
|
+
deliveryConfirmationSentAt: string;
|
|
39
|
+
deliveryConfirmedAt: string;
|
|
40
|
+
deliveryConfirmationAttempts: number;
|
|
41
|
+
needsManualCall: boolean;
|
|
30
42
|
brand: {
|
|
31
43
|
id: string;
|
|
32
44
|
name: string;
|
|
@@ -38,6 +50,7 @@ export declare function useGetCustomerHistory(phone: string, options?: Omit<UseQ
|
|
|
38
50
|
tiktokPixelId: string;
|
|
39
51
|
paystackPublicKey: string;
|
|
40
52
|
freeShippingThreshold: number;
|
|
53
|
+
upsellDiscountPercent: number;
|
|
41
54
|
createdAt: string;
|
|
42
55
|
updatedAt: string;
|
|
43
56
|
deletedAt: string;
|
|
@@ -70,6 +83,8 @@ export declare function useGetCustomerHistory(phone: string, options?: Omit<UseQ
|
|
|
70
83
|
};
|
|
71
84
|
items: {
|
|
72
85
|
priceAtPurchase: number;
|
|
86
|
+
costAtPurchase: number;
|
|
87
|
+
itemProfit: number;
|
|
73
88
|
variant: {
|
|
74
89
|
price: number;
|
|
75
90
|
createdAt: string;
|
|
@@ -529,6 +544,7 @@ export declare function useGetCustomerHistory(phone: string, options?: Omit<UseQ
|
|
|
529
544
|
productId: string;
|
|
530
545
|
thumbnailUrl: string | null;
|
|
531
546
|
sku: string;
|
|
547
|
+
costPrice: string;
|
|
532
548
|
compareAtPrice: string;
|
|
533
549
|
trackInventory: boolean;
|
|
534
550
|
lowStockThreshold: number | null;
|
|
@@ -569,7 +585,18 @@ export declare function useGetCustomerHistory(phone: string, options?: Omit<UseQ
|
|
|
569
585
|
paystackReference: string | null;
|
|
570
586
|
status: import("@prisma/client").$Enums.OrderStatus;
|
|
571
587
|
cancellationReason: string | null;
|
|
588
|
+
shippingMethod: string | null;
|
|
589
|
+
dispatchRiderId: string | null;
|
|
590
|
+
fezTrackingNumber: string | null;
|
|
591
|
+
flutterwaveOrderRef: string | null;
|
|
592
|
+
flutterwaveCustomerId: string | null;
|
|
572
593
|
prospectReason: import("@prisma/client").$Enums.ProspectReason | null;
|
|
573
594
|
userActionToken: string;
|
|
595
|
+
labelPrintedAt: string;
|
|
596
|
+
dispatchRider?: {
|
|
597
|
+
id: string;
|
|
598
|
+
name: string;
|
|
599
|
+
phone: string;
|
|
600
|
+
};
|
|
574
601
|
}[];
|
|
575
602
|
}, Error>;
|
|
@@ -23,6 +23,7 @@ export declare function useListStates(options?: Omit<UseQueryOptions<Awaited<Ret
|
|
|
23
23
|
tiktokPixelId: string;
|
|
24
24
|
paystackPublicKey: string;
|
|
25
25
|
freeShippingThreshold: number;
|
|
26
|
+
upsellDiscountPercent: number;
|
|
26
27
|
createdAt: string;
|
|
27
28
|
updatedAt: string;
|
|
28
29
|
deletedAt: string;
|
|
@@ -135,6 +136,7 @@ export declare function useListDeliveryZones(params?: {
|
|
|
135
136
|
tiktokPixelId: string;
|
|
136
137
|
paystackPublicKey: string;
|
|
137
138
|
freeShippingThreshold: number;
|
|
139
|
+
upsellDiscountPercent: number;
|
|
138
140
|
createdAt: string;
|
|
139
141
|
updatedAt: string;
|
|
140
142
|
deletedAt: string;
|
|
@@ -181,6 +183,7 @@ export declare function useCreateDeliveryZone(options?: UseMutationOptions<Await
|
|
|
181
183
|
tiktokPixelId: string;
|
|
182
184
|
paystackPublicKey: string;
|
|
183
185
|
freeShippingThreshold: number;
|
|
186
|
+
upsellDiscountPercent: number;
|
|
184
187
|
createdAt: string;
|
|
185
188
|
updatedAt: string;
|
|
186
189
|
deletedAt: string;
|
|
@@ -242,6 +245,7 @@ export declare function useUpdateDeliveryZone(zoneId: string, options?: UseMutat
|
|
|
242
245
|
tiktokPixelId: string;
|
|
243
246
|
paystackPublicKey: string;
|
|
244
247
|
freeShippingThreshold: number;
|
|
248
|
+
upsellDiscountPercent: number;
|
|
245
249
|
createdAt: string;
|
|
246
250
|
updatedAt: string;
|
|
247
251
|
deletedAt: string;
|
|
@@ -32,6 +32,7 @@ export declare function useListDiscountCodes(params?: {
|
|
|
32
32
|
tiktokPixelId: string;
|
|
33
33
|
paystackPublicKey: string;
|
|
34
34
|
freeShippingThreshold: number;
|
|
35
|
+
upsellDiscountPercent: number;
|
|
35
36
|
createdAt: string;
|
|
36
37
|
updatedAt: string;
|
|
37
38
|
deletedAt: string;
|
|
@@ -85,6 +86,7 @@ export declare function useGetDiscountCode(codeId: string, options?: Omit<UseQue
|
|
|
85
86
|
tiktokPixelId: string;
|
|
86
87
|
paystackPublicKey: string;
|
|
87
88
|
freeShippingThreshold: number;
|
|
89
|
+
upsellDiscountPercent: number;
|
|
88
90
|
createdAt: string;
|
|
89
91
|
updatedAt: string;
|
|
90
92
|
deletedAt: string;
|
|
@@ -137,6 +139,7 @@ export declare function useCreateDiscountCode(options?: UseMutationOptions<Await
|
|
|
137
139
|
tiktokPixelId: string;
|
|
138
140
|
paystackPublicKey: string;
|
|
139
141
|
freeShippingThreshold: number;
|
|
142
|
+
upsellDiscountPercent: number;
|
|
140
143
|
createdAt: string;
|
|
141
144
|
updatedAt: string;
|
|
142
145
|
deletedAt: string;
|
|
@@ -184,6 +187,7 @@ export declare function useUpdateDiscountCode(codeId: string, options?: UseMutat
|
|
|
184
187
|
tiktokPixelId: string;
|
|
185
188
|
paystackPublicKey: string;
|
|
186
189
|
freeShippingThreshold: number;
|
|
190
|
+
upsellDiscountPercent: number;
|
|
187
191
|
createdAt: string;
|
|
188
192
|
updatedAt: string;
|
|
189
193
|
deletedAt: string;
|
|
@@ -266,6 +270,7 @@ export declare function useGetDiscountCodeAnalytics(codeId: string, options?: Om
|
|
|
266
270
|
tiktokPixelId: string;
|
|
267
271
|
paystackPublicKey: string;
|
|
268
272
|
freeShippingThreshold: number;
|
|
273
|
+
upsellDiscountPercent: number;
|
|
269
274
|
createdAt: string;
|
|
270
275
|
updatedAt: string;
|
|
271
276
|
deletedAt: string;
|
|
@@ -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
|
+
}
|