@instockng/api-client 1.0.40 → 1.0.41
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/hooks/public/carts.js +10 -9
- package/package.json +1 -1
|
@@ -128,17 +128,17 @@ export function useRemoveDiscount(cartId, options) {
|
|
|
128
128
|
export function useAddCartItem(cartId, options) {
|
|
129
129
|
const queryClient = useQueryClient();
|
|
130
130
|
return useMutation({
|
|
131
|
+
...options,
|
|
131
132
|
mutationFn: (data) => addCartItem(cartId, data.sku, data.quantity, data.fbc, data.fbp, data.ttp, data.ttclid, data.fromUpsell, data.upsellDiscountPercent),
|
|
132
|
-
onSuccess: (
|
|
133
|
+
onSuccess: (...args) => {
|
|
134
|
+
const [, variables] = args;
|
|
133
135
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
|
|
134
|
-
// Refresh recommendations only if cart is not visible (refreshRecommendations flag is true)
|
|
135
136
|
if (variables.refreshRecommendations) {
|
|
136
137
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.recommendations(cartId) });
|
|
137
138
|
}
|
|
138
|
-
// Refresh upsell addons when cart changes
|
|
139
139
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId) });
|
|
140
|
+
options?.onSuccess?.(...args);
|
|
140
141
|
},
|
|
141
|
-
...options,
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
144
|
/**
|
|
@@ -156,12 +156,13 @@ export function useAddCartItem(cartId, options) {
|
|
|
156
156
|
export function useUpdateCartItem(cartId, options) {
|
|
157
157
|
const queryClient = useQueryClient();
|
|
158
158
|
return useMutation({
|
|
159
|
+
...options,
|
|
159
160
|
mutationFn: ({ itemId, quantity }) => updateCartItem(cartId, itemId, quantity),
|
|
160
|
-
onSuccess: () => {
|
|
161
|
+
onSuccess: (...args) => {
|
|
161
162
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
|
|
162
163
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId) });
|
|
164
|
+
options?.onSuccess?.(...args);
|
|
163
165
|
},
|
|
164
|
-
...options,
|
|
165
166
|
});
|
|
166
167
|
}
|
|
167
168
|
/**
|
|
@@ -179,14 +180,14 @@ export function useUpdateCartItem(cartId, options) {
|
|
|
179
180
|
export function useRemoveCartItem(cartId, options) {
|
|
180
181
|
const queryClient = useQueryClient();
|
|
181
182
|
return useMutation({
|
|
183
|
+
...options,
|
|
182
184
|
mutationFn: (itemId) => removeCartItem(cartId, itemId),
|
|
183
|
-
onSuccess: () => {
|
|
185
|
+
onSuccess: (...args) => {
|
|
184
186
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
|
|
185
|
-
// Refresh recommendations when item is removed
|
|
186
187
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.recommendations(cartId) });
|
|
187
188
|
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId) });
|
|
189
|
+
options?.onSuccess?.(...args);
|
|
188
190
|
},
|
|
189
|
-
...options,
|
|
190
191
|
});
|
|
191
192
|
}
|
|
192
193
|
/**
|