Skip to content

Commit de2d2c9

Browse files
committed
feat: update mutations to tanstack-query v5 syntax
1 parent 372c4f9 commit de2d2c9

File tree

1 file changed

+15
-16
lines changed

1 file changed

+15
-16
lines changed

src/hooks/Mutations/shop/useMakeOrder.jsx

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@ const useMakeOrder = () => {
77
const { auth, logout } = useAuth();
88
const queryClient = useQueryClient();
99

10-
return useMutation(
11-
async (customerInfo) => {
10+
return useMutation({
11+
mutationFn: async (customerInfo) => {
1212
const response = await privateAxios.post("/orders/", customerInfo, {
1313
headers: {
1414
"Content-Type": "application/json",
@@ -17,20 +17,19 @@ const useMakeOrder = () => {
1717
});
1818
return response.data;
1919
},
20-
{
21-
onSuccess: (data) => {
22-
console.log("Added to cart: ", data);
23-
queryClient.invalidateQueries(["productsInCart"]);
24-
},
25-
onError: (error) => {
26-
// eslint-disable-next-line no-console
27-
console.error("Unable to add availability");
28-
if (error.response.status === 401) {
29-
logout();
30-
}
31-
},
32-
}
33-
);
20+
21+
onSuccess: (data) => {
22+
console.log("Added to cart: ", data);
23+
queryClient.invalidateQueries({ queryKey: ["productsInCart"] });
24+
},
25+
onError: (error) => {
26+
// eslint-disable-next-line no-console
27+
console.error("Unable to add availability");
28+
if (error.response.status === 401) {
29+
logout();
30+
}
31+
},
32+
});
3433
};
3534

3635
export default useMakeOrder;

0 commit comments

Comments
 (0)