@instockng/api-client 1.0.37 → 1.0.40
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 +2 -2
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
import { useMutation, useQueryClient } from '@tanstack/react-query';
|
|
8
8
|
import { useQueryUnwrapped } from '../use-query-unwrapped';
|
|
9
9
|
import { queryKeys } from '../../utils/query-keys';
|
|
10
|
-
import { fetchCart, updateCart, createCart, addCartItem, updateCartItem, removeCartItem, applyDiscount, removeDiscount, checkoutCart, initiateCheckout, fetchCartRecommendations, } from '../../fetchers/carts';
|
|
10
|
+
import { fetchCart, updateCart, createCart, addCartItem, updateCartItem, removeCartItem, applyDiscount, removeDiscount, checkoutCart, initiateCheckout, fetchCartRecommendations, fetchCartUpsellAddons, } from '../../fetchers/carts';
|
|
11
11
|
/**
|
|
12
12
|
* Hook to get cart by ID using RPC
|
|
13
13
|
*
|
|
@@ -128,13 +128,15 @@ export function useRemoveDiscount(cartId, options) {
|
|
|
128
128
|
export function useAddCartItem(cartId, options) {
|
|
129
129
|
const queryClient = useQueryClient();
|
|
130
130
|
return useMutation({
|
|
131
|
-
mutationFn: (data) => addCartItem(cartId, data.sku, data.quantity, data.fbc, data.fbp, data.ttp, data.ttclid),
|
|
131
|
+
mutationFn: (data) => addCartItem(cartId, data.sku, data.quantity, data.fbc, data.fbp, data.ttp, data.ttclid, data.fromUpsell, data.upsellDiscountPercent),
|
|
132
132
|
onSuccess: (_, variables) => {
|
|
133
133
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
|
|
134
134
|
// Refresh recommendations only if cart is not visible (refreshRecommendations flag is true)
|
|
135
135
|
if (variables.refreshRecommendations) {
|
|
136
136
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.recommendations(cartId) });
|
|
137
137
|
}
|
|
138
|
+
// Refresh upsell addons when cart changes
|
|
139
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId) });
|
|
138
140
|
},
|
|
139
141
|
...options,
|
|
140
142
|
});
|
|
@@ -157,6 +159,7 @@ export function useUpdateCartItem(cartId, options) {
|
|
|
157
159
|
mutationFn: ({ itemId, quantity }) => updateCartItem(cartId, itemId, quantity),
|
|
158
160
|
onSuccess: () => {
|
|
159
161
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
|
|
162
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId) });
|
|
160
163
|
},
|
|
161
164
|
...options,
|
|
162
165
|
});
|
|
@@ -181,6 +184,7 @@ export function useRemoveCartItem(cartId, options) {
|
|
|
181
184
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
|
|
182
185
|
// Refresh recommendations when item is removed
|
|
183
186
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.recommendations(cartId) });
|
|
187
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId) });
|
|
184
188
|
},
|
|
185
189
|
...options,
|
|
186
190
|
});
|
|
@@ -256,3 +260,17 @@ export function useGetCartRecommendations(cartId, limit, options) {
|
|
|
256
260
|
...options,
|
|
257
261
|
});
|
|
258
262
|
}
|
|
263
|
+
/**
|
|
264
|
+
* Hook to get discounted upsell add-ons for a cart
|
|
265
|
+
*
|
|
266
|
+
* @param cartId - Cart UUID
|
|
267
|
+
* @param options - React Query options
|
|
268
|
+
*/
|
|
269
|
+
export function useGetCartUpsellAddons(cartId, options) {
|
|
270
|
+
return useQueryUnwrapped({
|
|
271
|
+
queryKey: cartId ? queryKeys.public.carts.upsellAddons(cartId) : ['public', 'carts', 'upsell-addons'],
|
|
272
|
+
queryFn: () => fetchCartUpsellAddons(cartId),
|
|
273
|
+
enabled: !!cartId,
|
|
274
|
+
...options,
|
|
275
|
+
});
|
|
276
|
+
}
|
|
@@ -25,6 +25,9 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
|
|
|
25
25
|
canUpdateAddress: boolean;
|
|
26
26
|
confirmationMessage: string;
|
|
27
27
|
subtotal: number;
|
|
28
|
+
totalCost: number;
|
|
29
|
+
totalProfit: number;
|
|
30
|
+
profitMargin: number;
|
|
28
31
|
deliveryCharge: number;
|
|
29
32
|
totalPrice: number;
|
|
30
33
|
discountAmount: number;
|
|
@@ -41,6 +44,7 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
|
|
|
41
44
|
deliveryConfirmationSentAt: string;
|
|
42
45
|
deliveryConfirmedAt: string;
|
|
43
46
|
deliveryConfirmationAttempts: number;
|
|
47
|
+
needsManualCall: boolean;
|
|
44
48
|
brand: {
|
|
45
49
|
id: string;
|
|
46
50
|
name: string;
|
|
@@ -52,6 +56,7 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
|
|
|
52
56
|
tiktokPixelId: string;
|
|
53
57
|
paystackPublicKey: string;
|
|
54
58
|
freeShippingThreshold: number;
|
|
59
|
+
upsellDiscountPercent: number;
|
|
55
60
|
createdAt: string;
|
|
56
61
|
updatedAt: string;
|
|
57
62
|
deletedAt: string;
|
|
@@ -84,6 +89,8 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
|
|
|
84
89
|
};
|
|
85
90
|
items: {
|
|
86
91
|
priceAtPurchase: number;
|
|
92
|
+
costAtPurchase: number;
|
|
93
|
+
itemProfit: number;
|
|
87
94
|
variant: {
|
|
88
95
|
price: number;
|
|
89
96
|
createdAt: string;
|
|
@@ -543,6 +550,7 @@ export declare function useGetOrder(orderId: string, token: string, options?: Om
|
|
|
543
550
|
productId: string;
|
|
544
551
|
thumbnailUrl: string | null;
|
|
545
552
|
sku: string;
|
|
553
|
+
costPrice: string;
|
|
546
554
|
compareAtPrice: string;
|
|
547
555
|
trackInventory: boolean;
|
|
548
556
|
lowStockThreshold: number | null;
|
|
@@ -616,6 +624,9 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
|
|
|
616
624
|
token: string;
|
|
617
625
|
}>): import("@tanstack/react-query").UseMutationResult<{
|
|
618
626
|
subtotal: number;
|
|
627
|
+
totalCost: number;
|
|
628
|
+
totalProfit: number;
|
|
629
|
+
profitMargin: number;
|
|
619
630
|
deliveryCharge: number;
|
|
620
631
|
totalPrice: number;
|
|
621
632
|
discountAmount: number;
|
|
@@ -632,6 +643,7 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
|
|
|
632
643
|
deliveryConfirmationSentAt: string;
|
|
633
644
|
deliveryConfirmedAt: string;
|
|
634
645
|
deliveryConfirmationAttempts: number;
|
|
646
|
+
needsManualCall: boolean;
|
|
635
647
|
brand: {
|
|
636
648
|
id: string;
|
|
637
649
|
name: string;
|
|
@@ -643,6 +655,7 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
|
|
|
643
655
|
tiktokPixelId: string;
|
|
644
656
|
paystackPublicKey: string;
|
|
645
657
|
freeShippingThreshold: number;
|
|
658
|
+
upsellDiscountPercent: number;
|
|
646
659
|
createdAt: string;
|
|
647
660
|
updatedAt: string;
|
|
648
661
|
deletedAt: string;
|
|
@@ -675,6 +688,8 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
|
|
|
675
688
|
};
|
|
676
689
|
items: {
|
|
677
690
|
priceAtPurchase: number;
|
|
691
|
+
costAtPurchase: number;
|
|
692
|
+
itemProfit: number;
|
|
678
693
|
variant: {
|
|
679
694
|
price: number;
|
|
680
695
|
createdAt: string;
|
|
@@ -1134,6 +1149,7 @@ export declare function useConfirmOrder(options?: UseMutationOptions<Awaited<Ret
|
|
|
1134
1149
|
productId: string;
|
|
1135
1150
|
thumbnailUrl: string | null;
|
|
1136
1151
|
sku: string;
|
|
1152
|
+
costPrice: string;
|
|
1137
1153
|
compareAtPrice: string;
|
|
1138
1154
|
trackInventory: boolean;
|
|
1139
1155
|
lowStockThreshold: number | null;
|
|
@@ -1397,6 +1413,7 @@ export declare function useGetOrderRecommendations(orderId: string | null | unde
|
|
|
1397
1413
|
tiktokPixelId: string;
|
|
1398
1414
|
paystackPublicKey: string;
|
|
1399
1415
|
freeShippingThreshold: number;
|
|
1416
|
+
upsellDiscountPercent: number;
|
|
1400
1417
|
createdAt: string;
|
|
1401
1418
|
updatedAt: string;
|
|
1402
1419
|
deletedAt: string;
|
|
@@ -1405,9 +1422,11 @@ export declare function useGetOrderRecommendations(orderId: string | null | unde
|
|
|
1405
1422
|
createdAt: string;
|
|
1406
1423
|
updatedAt: string;
|
|
1407
1424
|
price: number;
|
|
1425
|
+
costPrice: number;
|
|
1408
1426
|
compareAtPrice: number;
|
|
1409
1427
|
deletedAt: string;
|
|
1410
1428
|
thumbnailUrl: string;
|
|
1429
|
+
rawThumbnailUrl: string;
|
|
1411
1430
|
originalPrice: number;
|
|
1412
1431
|
id: string;
|
|
1413
1432
|
name: string | null;
|