@instockng/api-client 1.0.40 → 1.0.42
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 +18 -17
- 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
|
-
|
|
134
|
-
|
|
133
|
+
onSuccess: (...args) => {
|
|
134
|
+
const [, variables] = args;
|
|
135
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId), exact: true });
|
|
135
136
|
if (variables.refreshRecommendations) {
|
|
136
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.recommendations(cartId) });
|
|
137
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.recommendations(cartId), exact: true });
|
|
137
138
|
}
|
|
138
|
-
|
|
139
|
-
|
|
139
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId), exact: true });
|
|
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
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
|
|
162
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId) });
|
|
161
|
+
onSuccess: (...args) => {
|
|
162
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId), exact: true });
|
|
163
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId), exact: true });
|
|
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: () => {
|
|
184
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId) });
|
|
185
|
-
|
|
186
|
-
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.
|
|
187
|
-
|
|
185
|
+
onSuccess: (...args) => {
|
|
186
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.detail(cartId), exact: true });
|
|
187
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.recommendations(cartId), exact: true });
|
|
188
|
+
queryClient.invalidateQueries({ queryKey: queryKeys.public.carts.upsellAddons(cartId), exact: true });
|
|
189
|
+
options?.onSuccess?.(...args);
|
|
188
190
|
},
|
|
189
|
-
...options,
|
|
190
191
|
});
|
|
191
192
|
}
|
|
192
193
|
/**
|