@instockng/api-client 1.0.37 → 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/fetchers/carts.d.ts +567 -1
- package/dist/fetchers/carts.js +18 -2
- package/dist/fetchers/orders.d.ts +19 -0
- 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 +8 -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/orders.d.ts +55 -0
- package/dist/hooks/admin/orders.js +23 -0
- package/dist/hooks/admin/products.d.ts +6 -0
- package/dist/hooks/admin/stats.d.ts +8 -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 +566 -1
- package/dist/hooks/public/carts.js +20 -2
- package/dist/hooks/public/orders.d.ts +19 -0
- package/dist/rpc-client.d.ts +795 -0
- package/dist/rpc-types.d.ts +9 -0
- package/dist/utils/query-keys.d.ts +2 -0
- package/dist/utils/query-keys.js +2 -0
- package/package.json +7 -8
package/dist/fetchers/carts.js
CHANGED
|
@@ -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
|
*
|
|
@@ -17,6 +17,9 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
|
|
|
17
17
|
canUpdateAddress: boolean;
|
|
18
18
|
confirmationMessage: string;
|
|
19
19
|
subtotal: number;
|
|
20
|
+
totalCost: number;
|
|
21
|
+
totalProfit: number;
|
|
22
|
+
profitMargin: number;
|
|
20
23
|
deliveryCharge: number;
|
|
21
24
|
totalPrice: number;
|
|
22
25
|
discountAmount: number;
|
|
@@ -33,6 +36,7 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
|
|
|
33
36
|
deliveryConfirmationSentAt: string;
|
|
34
37
|
deliveryConfirmedAt: string;
|
|
35
38
|
deliveryConfirmationAttempts: number;
|
|
39
|
+
needsManualCall: boolean;
|
|
36
40
|
brand: {
|
|
37
41
|
id: string;
|
|
38
42
|
name: string;
|
|
@@ -44,6 +48,7 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
|
|
|
44
48
|
tiktokPixelId: string;
|
|
45
49
|
paystackPublicKey: string;
|
|
46
50
|
freeShippingThreshold: number;
|
|
51
|
+
upsellDiscountPercent: number;
|
|
47
52
|
createdAt: string;
|
|
48
53
|
updatedAt: string;
|
|
49
54
|
deletedAt: string;
|
|
@@ -76,6 +81,8 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
|
|
|
76
81
|
};
|
|
77
82
|
items: {
|
|
78
83
|
priceAtPurchase: number;
|
|
84
|
+
costAtPurchase: number;
|
|
85
|
+
itemProfit: number;
|
|
79
86
|
variant: {
|
|
80
87
|
price: number;
|
|
81
88
|
createdAt: string;
|
|
@@ -535,6 +542,7 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
|
|
|
535
542
|
productId: string;
|
|
536
543
|
thumbnailUrl: string | null;
|
|
537
544
|
sku: string;
|
|
545
|
+
costPrice: string;
|
|
538
546
|
compareAtPrice: string;
|
|
539
547
|
trackInventory: boolean;
|
|
540
548
|
lowStockThreshold: number | null;
|
|
@@ -598,6 +606,9 @@ export declare function fetchOrder(orderId: string, token: string): Promise<{
|
|
|
598
606
|
*/
|
|
599
607
|
export declare function confirmOrder(orderId: string, token: string): Promise<{
|
|
600
608
|
subtotal: number;
|
|
609
|
+
totalCost: number;
|
|
610
|
+
totalProfit: number;
|
|
611
|
+
profitMargin: number;
|
|
601
612
|
deliveryCharge: number;
|
|
602
613
|
totalPrice: number;
|
|
603
614
|
discountAmount: number;
|
|
@@ -614,6 +625,7 @@ export declare function confirmOrder(orderId: string, token: string): Promise<{
|
|
|
614
625
|
deliveryConfirmationSentAt: string;
|
|
615
626
|
deliveryConfirmedAt: string;
|
|
616
627
|
deliveryConfirmationAttempts: number;
|
|
628
|
+
needsManualCall: boolean;
|
|
617
629
|
brand: {
|
|
618
630
|
id: string;
|
|
619
631
|
name: string;
|
|
@@ -625,6 +637,7 @@ export declare function confirmOrder(orderId: string, token: string): Promise<{
|
|
|
625
637
|
tiktokPixelId: string;
|
|
626
638
|
paystackPublicKey: string;
|
|
627
639
|
freeShippingThreshold: number;
|
|
640
|
+
upsellDiscountPercent: number;
|
|
628
641
|
createdAt: string;
|
|
629
642
|
updatedAt: string;
|
|
630
643
|
deletedAt: string;
|
|
@@ -657,6 +670,8 @@ export declare function confirmOrder(orderId: string, token: string): Promise<{
|
|
|
657
670
|
};
|
|
658
671
|
items: {
|
|
659
672
|
priceAtPurchase: number;
|
|
673
|
+
costAtPurchase: number;
|
|
674
|
+
itemProfit: number;
|
|
660
675
|
variant: {
|
|
661
676
|
price: number;
|
|
662
677
|
createdAt: string;
|
|
@@ -1116,6 +1131,7 @@ export declare function confirmOrder(orderId: string, token: string): Promise<{
|
|
|
1116
1131
|
productId: string;
|
|
1117
1132
|
thumbnailUrl: string | null;
|
|
1118
1133
|
sku: string;
|
|
1134
|
+
costPrice: string;
|
|
1119
1135
|
compareAtPrice: string;
|
|
1120
1136
|
trackInventory: boolean;
|
|
1121
1137
|
lowStockThreshold: number | null;
|
|
@@ -1367,6 +1383,7 @@ export declare function fetchOrderRecommendations(orderId: string, token: string
|
|
|
1367
1383
|
tiktokPixelId: string;
|
|
1368
1384
|
paystackPublicKey: string;
|
|
1369
1385
|
freeShippingThreshold: number;
|
|
1386
|
+
upsellDiscountPercent: number;
|
|
1370
1387
|
createdAt: string;
|
|
1371
1388
|
updatedAt: string;
|
|
1372
1389
|
deletedAt: string;
|
|
@@ -1375,9 +1392,11 @@ export declare function fetchOrderRecommendations(orderId: string, token: string
|
|
|
1375
1392
|
createdAt: string;
|
|
1376
1393
|
updatedAt: string;
|
|
1377
1394
|
price: number;
|
|
1395
|
+
costPrice: number;
|
|
1378
1396
|
compareAtPrice: number;
|
|
1379
1397
|
deletedAt: string;
|
|
1380
1398
|
thumbnailUrl: string;
|
|
1399
|
+
rawThumbnailUrl: string;
|
|
1381
1400
|
originalPrice: number;
|
|
1382
1401
|
id: string;
|
|
1383
1402
|
name: string | null;
|
|
@@ -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,6 +19,9 @@ 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;
|
|
@@ -35,6 +38,7 @@ export declare function useGetCustomerHistory(phone: string, options?: Omit<UseQ
|
|
|
35
38
|
deliveryConfirmationSentAt: string;
|
|
36
39
|
deliveryConfirmedAt: string;
|
|
37
40
|
deliveryConfirmationAttempts: number;
|
|
41
|
+
needsManualCall: boolean;
|
|
38
42
|
brand: {
|
|
39
43
|
id: string;
|
|
40
44
|
name: string;
|
|
@@ -46,6 +50,7 @@ export declare function useGetCustomerHistory(phone: string, options?: Omit<UseQ
|
|
|
46
50
|
tiktokPixelId: string;
|
|
47
51
|
paystackPublicKey: string;
|
|
48
52
|
freeShippingThreshold: number;
|
|
53
|
+
upsellDiscountPercent: number;
|
|
49
54
|
createdAt: string;
|
|
50
55
|
updatedAt: string;
|
|
51
56
|
deletedAt: string;
|
|
@@ -78,6 +83,8 @@ export declare function useGetCustomerHistory(phone: string, options?: Omit<UseQ
|
|
|
78
83
|
};
|
|
79
84
|
items: {
|
|
80
85
|
priceAtPurchase: number;
|
|
86
|
+
costAtPurchase: number;
|
|
87
|
+
itemProfit: number;
|
|
81
88
|
variant: {
|
|
82
89
|
price: number;
|
|
83
90
|
createdAt: string;
|
|
@@ -537,6 +544,7 @@ export declare function useGetCustomerHistory(phone: string, options?: Omit<UseQ
|
|
|
537
544
|
productId: string;
|
|
538
545
|
thumbnailUrl: string | null;
|
|
539
546
|
sku: string;
|
|
547
|
+
costPrice: string;
|
|
540
548
|
compareAtPrice: string;
|
|
541
549
|
trackInventory: boolean;
|
|
542
550
|
lowStockThreshold: number | null;
|
|
@@ -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;
|
|
@@ -29,6 +29,9 @@ export declare function useListOrders(filters?: {
|
|
|
29
29
|
}, options?: Omit<UseQueryOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['orders']['index']['$get']>>['json']>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
|
|
30
30
|
data: {
|
|
31
31
|
subtotal: number;
|
|
32
|
+
totalCost: number;
|
|
33
|
+
totalProfit: number;
|
|
34
|
+
profitMargin: number;
|
|
32
35
|
deliveryCharge: number;
|
|
33
36
|
totalPrice: number;
|
|
34
37
|
discountAmount: number;
|
|
@@ -45,6 +48,7 @@ export declare function useListOrders(filters?: {
|
|
|
45
48
|
deliveryConfirmationSentAt: string;
|
|
46
49
|
deliveryConfirmedAt: string;
|
|
47
50
|
deliveryConfirmationAttempts: number;
|
|
51
|
+
needsManualCall: boolean;
|
|
48
52
|
brand: {
|
|
49
53
|
id: string;
|
|
50
54
|
name: string;
|
|
@@ -56,6 +60,7 @@ export declare function useListOrders(filters?: {
|
|
|
56
60
|
tiktokPixelId: string;
|
|
57
61
|
paystackPublicKey: string;
|
|
58
62
|
freeShippingThreshold: number;
|
|
63
|
+
upsellDiscountPercent: number;
|
|
59
64
|
createdAt: string;
|
|
60
65
|
updatedAt: string;
|
|
61
66
|
deletedAt: string;
|
|
@@ -88,6 +93,8 @@ export declare function useListOrders(filters?: {
|
|
|
88
93
|
};
|
|
89
94
|
items: {
|
|
90
95
|
priceAtPurchase: number;
|
|
96
|
+
costAtPurchase: number;
|
|
97
|
+
itemProfit: number;
|
|
91
98
|
variant: {
|
|
92
99
|
price: number;
|
|
93
100
|
createdAt: string;
|
|
@@ -547,6 +554,7 @@ export declare function useListOrders(filters?: {
|
|
|
547
554
|
productId: string;
|
|
548
555
|
thumbnailUrl: string | null;
|
|
549
556
|
sku: string;
|
|
557
|
+
costPrice: string;
|
|
550
558
|
compareAtPrice: string;
|
|
551
559
|
trackInventory: boolean;
|
|
552
560
|
lowStockThreshold: number | null;
|
|
@@ -621,6 +629,9 @@ export declare function useListOrders(filters?: {
|
|
|
621
629
|
*/
|
|
622
630
|
export declare function useGetOrder(orderId: string, options?: Omit<UseQueryOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['orders'][':id']['$get']>>['json']>>, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<{
|
|
623
631
|
subtotal: number;
|
|
632
|
+
totalCost: number;
|
|
633
|
+
totalProfit: number;
|
|
634
|
+
profitMargin: number;
|
|
624
635
|
deliveryCharge: number;
|
|
625
636
|
totalPrice: number;
|
|
626
637
|
discountAmount: number;
|
|
@@ -637,6 +648,7 @@ export declare function useGetOrder(orderId: string, options?: Omit<UseQueryOpti
|
|
|
637
648
|
deliveryConfirmationSentAt: string;
|
|
638
649
|
deliveryConfirmedAt: string;
|
|
639
650
|
deliveryConfirmationAttempts: number;
|
|
651
|
+
needsManualCall: boolean;
|
|
640
652
|
brand: {
|
|
641
653
|
id: string;
|
|
642
654
|
name: string;
|
|
@@ -648,6 +660,7 @@ export declare function useGetOrder(orderId: string, options?: Omit<UseQueryOpti
|
|
|
648
660
|
tiktokPixelId: string;
|
|
649
661
|
paystackPublicKey: string;
|
|
650
662
|
freeShippingThreshold: number;
|
|
663
|
+
upsellDiscountPercent: number;
|
|
651
664
|
createdAt: string;
|
|
652
665
|
updatedAt: string;
|
|
653
666
|
deletedAt: string;
|
|
@@ -680,6 +693,8 @@ export declare function useGetOrder(orderId: string, options?: Omit<UseQueryOpti
|
|
|
680
693
|
};
|
|
681
694
|
items: {
|
|
682
695
|
priceAtPurchase: number;
|
|
696
|
+
costAtPurchase: number;
|
|
697
|
+
itemProfit: number;
|
|
683
698
|
variant: {
|
|
684
699
|
price: number;
|
|
685
700
|
createdAt: string;
|
|
@@ -1139,6 +1154,7 @@ export declare function useGetOrder(orderId: string, options?: Omit<UseQueryOpti
|
|
|
1139
1154
|
productId: string;
|
|
1140
1155
|
thumbnailUrl: string | null;
|
|
1141
1156
|
sku: string;
|
|
1157
|
+
costPrice: string;
|
|
1142
1158
|
compareAtPrice: string;
|
|
1143
1159
|
trackInventory: boolean;
|
|
1144
1160
|
lowStockThreshold: number | null;
|
|
@@ -1210,6 +1226,9 @@ export declare function useGetOrder(orderId: string, options?: Omit<UseQueryOpti
|
|
|
1210
1226
|
*/
|
|
1211
1227
|
export declare function useCreateOrder(options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['orders']['index']['$post']>>['json']>>, Error, any>): import("@tanstack/react-query").UseMutationResult<{
|
|
1212
1228
|
subtotal: number;
|
|
1229
|
+
totalCost: number;
|
|
1230
|
+
totalProfit: number;
|
|
1231
|
+
profitMargin: number;
|
|
1213
1232
|
deliveryCharge: number;
|
|
1214
1233
|
totalPrice: number;
|
|
1215
1234
|
discountAmount: number;
|
|
@@ -1226,6 +1245,7 @@ export declare function useCreateOrder(options?: UseMutationOptions<Awaited<Retu
|
|
|
1226
1245
|
deliveryConfirmationSentAt: string;
|
|
1227
1246
|
deliveryConfirmedAt: string;
|
|
1228
1247
|
deliveryConfirmationAttempts: number;
|
|
1248
|
+
needsManualCall: boolean;
|
|
1229
1249
|
brand: {
|
|
1230
1250
|
id: string;
|
|
1231
1251
|
name: string;
|
|
@@ -1237,6 +1257,7 @@ export declare function useCreateOrder(options?: UseMutationOptions<Awaited<Retu
|
|
|
1237
1257
|
tiktokPixelId: string;
|
|
1238
1258
|
paystackPublicKey: string;
|
|
1239
1259
|
freeShippingThreshold: number;
|
|
1260
|
+
upsellDiscountPercent: number;
|
|
1240
1261
|
createdAt: string;
|
|
1241
1262
|
updatedAt: string;
|
|
1242
1263
|
deletedAt: string;
|
|
@@ -1269,6 +1290,8 @@ export declare function useCreateOrder(options?: UseMutationOptions<Awaited<Retu
|
|
|
1269
1290
|
};
|
|
1270
1291
|
items: {
|
|
1271
1292
|
priceAtPurchase: number;
|
|
1293
|
+
costAtPurchase: number;
|
|
1294
|
+
itemProfit: number;
|
|
1272
1295
|
variant: {
|
|
1273
1296
|
price: number;
|
|
1274
1297
|
createdAt: string;
|
|
@@ -1728,6 +1751,7 @@ export declare function useCreateOrder(options?: UseMutationOptions<Awaited<Retu
|
|
|
1728
1751
|
productId: string;
|
|
1729
1752
|
thumbnailUrl: string | null;
|
|
1730
1753
|
sku: string;
|
|
1754
|
+
costPrice: string;
|
|
1731
1755
|
compareAtPrice: string;
|
|
1732
1756
|
trackInventory: boolean;
|
|
1733
1757
|
lowStockThreshold: number | null;
|
|
@@ -1800,6 +1824,9 @@ export declare function useCreateOrder(options?: UseMutationOptions<Awaited<Retu
|
|
|
1800
1824
|
*/
|
|
1801
1825
|
export declare function useUpdateOrder(orderId: string, options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['orders'][':id']['$patch']>>['json']>>, Error, any>): import("@tanstack/react-query").UseMutationResult<{
|
|
1802
1826
|
subtotal: number;
|
|
1827
|
+
totalCost: number;
|
|
1828
|
+
totalProfit: number;
|
|
1829
|
+
profitMargin: number;
|
|
1803
1830
|
deliveryCharge: number;
|
|
1804
1831
|
totalPrice: number;
|
|
1805
1832
|
discountAmount: number;
|
|
@@ -1816,6 +1843,7 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
1816
1843
|
deliveryConfirmationSentAt: string;
|
|
1817
1844
|
deliveryConfirmedAt: string;
|
|
1818
1845
|
deliveryConfirmationAttempts: number;
|
|
1846
|
+
needsManualCall: boolean;
|
|
1819
1847
|
brand: {
|
|
1820
1848
|
id: string;
|
|
1821
1849
|
name: string;
|
|
@@ -1827,6 +1855,7 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
1827
1855
|
tiktokPixelId: string;
|
|
1828
1856
|
paystackPublicKey: string;
|
|
1829
1857
|
freeShippingThreshold: number;
|
|
1858
|
+
upsellDiscountPercent: number;
|
|
1830
1859
|
createdAt: string;
|
|
1831
1860
|
updatedAt: string;
|
|
1832
1861
|
deletedAt: string;
|
|
@@ -1859,6 +1888,8 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
1859
1888
|
};
|
|
1860
1889
|
items: {
|
|
1861
1890
|
priceAtPurchase: number;
|
|
1891
|
+
costAtPurchase: number;
|
|
1892
|
+
itemProfit: number;
|
|
1862
1893
|
variant: {
|
|
1863
1894
|
price: number;
|
|
1864
1895
|
createdAt: string;
|
|
@@ -2318,6 +2349,7 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
2318
2349
|
productId: string;
|
|
2319
2350
|
thumbnailUrl: string | null;
|
|
2320
2351
|
sku: string;
|
|
2352
|
+
costPrice: string;
|
|
2321
2353
|
compareAtPrice: string;
|
|
2322
2354
|
trackInventory: boolean;
|
|
2323
2355
|
lowStockThreshold: number | null;
|
|
@@ -2389,6 +2421,7 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
2389
2421
|
paystackPublicKey: string | null;
|
|
2390
2422
|
paystackSecretKey: string | null;
|
|
2391
2423
|
freeShippingThreshold: string;
|
|
2424
|
+
upsellDiscountPercent: number;
|
|
2392
2425
|
createdAt: string;
|
|
2393
2426
|
updatedAt: string;
|
|
2394
2427
|
deletedAt: string;
|
|
@@ -2898,6 +2931,7 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
2898
2931
|
thumbnailUrl: string | null;
|
|
2899
2932
|
sku: string;
|
|
2900
2933
|
price: string;
|
|
2934
|
+
costPrice: string;
|
|
2901
2935
|
compareAtPrice: string;
|
|
2902
2936
|
trackInventory: boolean;
|
|
2903
2937
|
lowStockThreshold: number | null;
|
|
@@ -2908,6 +2942,7 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
2908
2942
|
orderId: string;
|
|
2909
2943
|
warehouseId: string | null;
|
|
2910
2944
|
priceAtPurchase: string;
|
|
2945
|
+
costAtPurchase: string;
|
|
2911
2946
|
}[];
|
|
2912
2947
|
notes: {
|
|
2913
2948
|
User: {
|
|
@@ -3128,6 +3163,9 @@ export declare function useUpdateOrder(orderId: string, options?: UseMutationOpt
|
|
|
3128
3163
|
*/
|
|
3129
3164
|
export declare function useUpdateOrderStatus(orderId: string, options?: UseMutationOptions<Awaited<ReturnType<Awaited<ReturnType<ReturnType<typeof createAdminRpcClients>['orders'][':id']['status']['$patch']>>['json']>>, Error, any>): import("@tanstack/react-query").UseMutationResult<{
|
|
3130
3165
|
subtotal: number;
|
|
3166
|
+
totalCost: number;
|
|
3167
|
+
totalProfit: number;
|
|
3168
|
+
profitMargin: number;
|
|
3131
3169
|
deliveryCharge: number;
|
|
3132
3170
|
totalPrice: number;
|
|
3133
3171
|
discountAmount: number;
|
|
@@ -3144,6 +3182,7 @@ export declare function useUpdateOrderStatus(orderId: string, options?: UseMutat
|
|
|
3144
3182
|
deliveryConfirmationSentAt: string;
|
|
3145
3183
|
deliveryConfirmedAt: string;
|
|
3146
3184
|
deliveryConfirmationAttempts: number;
|
|
3185
|
+
needsManualCall: boolean;
|
|
3147
3186
|
brand: {
|
|
3148
3187
|
id: string;
|
|
3149
3188
|
name: string;
|
|
@@ -3155,6 +3194,7 @@ export declare function useUpdateOrderStatus(orderId: string, options?: UseMutat
|
|
|
3155
3194
|
tiktokPixelId: string;
|
|
3156
3195
|
paystackPublicKey: string;
|
|
3157
3196
|
freeShippingThreshold: number;
|
|
3197
|
+
upsellDiscountPercent: number;
|
|
3158
3198
|
createdAt: string;
|
|
3159
3199
|
updatedAt: string;
|
|
3160
3200
|
deletedAt: string;
|
|
@@ -3187,6 +3227,8 @@ export declare function useUpdateOrderStatus(orderId: string, options?: UseMutat
|
|
|
3187
3227
|
};
|
|
3188
3228
|
items: {
|
|
3189
3229
|
priceAtPurchase: number;
|
|
3230
|
+
costAtPurchase: number;
|
|
3231
|
+
itemProfit: number;
|
|
3190
3232
|
variant: {
|
|
3191
3233
|
price: number;
|
|
3192
3234
|
createdAt: string;
|
|
@@ -3646,6 +3688,7 @@ export declare function useUpdateOrderStatus(orderId: string, options?: UseMutat
|
|
|
3646
3688
|
productId: string;
|
|
3647
3689
|
thumbnailUrl: string | null;
|
|
3648
3690
|
sku: string;
|
|
3691
|
+
costPrice: string;
|
|
3649
3692
|
compareAtPrice: string;
|
|
3650
3693
|
trackInventory: boolean;
|
|
3651
3694
|
lowStockThreshold: number | null;
|
|
@@ -3741,6 +3784,18 @@ export declare function useBatchDeliveryConfirmation(options?: UseMutationOption
|
|
|
3741
3784
|
}>): import("@tanstack/react-query").UseMutationResult<any, Error, {
|
|
3742
3785
|
orderIds: string[];
|
|
3743
3786
|
}, unknown>;
|
|
3787
|
+
/**
|
|
3788
|
+
* Hook to fetch aggregate order stats (revenue, cost, profit, margin)
|
|
3789
|
+
*
|
|
3790
|
+
* @param filters - Query parameters for filtering orders
|
|
3791
|
+
* @param options - React Query options
|
|
3792
|
+
*/
|
|
3793
|
+
export declare function useOrderStats(filters?: {
|
|
3794
|
+
status?: string;
|
|
3795
|
+
brandId?: string;
|
|
3796
|
+
startDate?: string;
|
|
3797
|
+
endDate?: string;
|
|
3798
|
+
}, options?: Omit<UseQueryOptions<any, Error>, 'queryKey' | 'queryFn'>): import("@tanstack/react-query").UseQueryResult<any, Error>;
|
|
3744
3799
|
/**
|
|
3745
3800
|
* Hook to add a note to an order using admin RPC
|
|
3746
3801
|
*
|
|
@@ -246,6 +246,29 @@ export function useBatchDeliveryConfirmation(options) {
|
|
|
246
246
|
...options,
|
|
247
247
|
});
|
|
248
248
|
}
|
|
249
|
+
/**
|
|
250
|
+
* Hook to fetch aggregate order stats (revenue, cost, profit, margin)
|
|
251
|
+
*
|
|
252
|
+
* @param filters - Query parameters for filtering orders
|
|
253
|
+
* @param options - React Query options
|
|
254
|
+
*/
|
|
255
|
+
export function useOrderStats(filters, options) {
|
|
256
|
+
const { baseURL, getAuthToken } = useApiConfig();
|
|
257
|
+
return useQueryUnwrapped({
|
|
258
|
+
queryKey: queryKeys.admin.orders.stats(filters),
|
|
259
|
+
queryFn: async () => {
|
|
260
|
+
const token = await getAuthToken();
|
|
261
|
+
const clients = createAdminRpcClients(baseURL);
|
|
262
|
+
const cleanFilters = filters ? Object.fromEntries(Object.entries(filters).filter(([_, v]) => v !== undefined)) : undefined;
|
|
263
|
+
const res = await clients.orders.stats.$get({ query: cleanFilters }, authHeaders(token));
|
|
264
|
+
if (!res.ok) {
|
|
265
|
+
throw new Error(`Failed to fetch order stats: ${res.statusText}`);
|
|
266
|
+
}
|
|
267
|
+
return res.json();
|
|
268
|
+
},
|
|
269
|
+
...options,
|
|
270
|
+
});
|
|
271
|
+
}
|
|
249
272
|
/**
|
|
250
273
|
* Hook to add a note to an order using admin RPC
|
|
251
274
|
*
|
|
@@ -169,6 +169,7 @@ export declare function useListProducts(brandId?: string, options?: Omit<UseQuer
|
|
|
169
169
|
tiktokPixelId: string;
|
|
170
170
|
paystackPublicKey: string;
|
|
171
171
|
freeShippingThreshold: number;
|
|
172
|
+
upsellDiscountPercent: number;
|
|
172
173
|
createdAt: string;
|
|
173
174
|
updatedAt: string;
|
|
174
175
|
deletedAt: string;
|
|
@@ -177,9 +178,11 @@ export declare function useListProducts(brandId?: string, options?: Omit<UseQuer
|
|
|
177
178
|
createdAt: string;
|
|
178
179
|
updatedAt: string;
|
|
179
180
|
price: number;
|
|
181
|
+
costPrice: number;
|
|
180
182
|
compareAtPrice: number;
|
|
181
183
|
deletedAt: string;
|
|
182
184
|
thumbnailUrl: string;
|
|
185
|
+
rawThumbnailUrl: string;
|
|
183
186
|
originalPrice: number;
|
|
184
187
|
id: string;
|
|
185
188
|
name: string | null;
|
|
@@ -671,6 +674,7 @@ export declare function useGetProduct(productId: string, options?: Omit<UseQuery
|
|
|
671
674
|
tiktokPixelId: string;
|
|
672
675
|
paystackPublicKey: string;
|
|
673
676
|
freeShippingThreshold: number;
|
|
677
|
+
upsellDiscountPercent: number;
|
|
674
678
|
createdAt: string;
|
|
675
679
|
updatedAt: string;
|
|
676
680
|
deletedAt: string;
|
|
@@ -679,9 +683,11 @@ export declare function useGetProduct(productId: string, options?: Omit<UseQuery
|
|
|
679
683
|
createdAt: string;
|
|
680
684
|
updatedAt: string;
|
|
681
685
|
price: number;
|
|
686
|
+
costPrice: number;
|
|
682
687
|
compareAtPrice: number;
|
|
683
688
|
deletedAt: string;
|
|
684
689
|
thumbnailUrl: string;
|
|
690
|
+
rawThumbnailUrl: string;
|
|
685
691
|
originalPrice: number;
|
|
686
692
|
id: string;
|
|
687
693
|
name: string | null;
|