@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.
@@ -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,17 @@ 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 item is added from upsell
139
+ if (variables.fromUpsell) {
140
+ queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId) });
141
+ }
138
142
  },
139
143
  ...options,
140
144
  });
@@ -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;