Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | 5x | import { useMutation, useQueryClient } from "@tanstack/react-query"; import { toast } from "react-toastify"; import { IWatchListPayload } from "@/interfaces"; import { setMovieInWatchList } from "@/api"; const useMovieWatchListMutation = () => { const queryClient = useQueryClient(); const { mutate: setMovieWatchListMutation, ...mutationState } = useMutation({ mutationFn: (payload: IWatchListPayload) => setMovieInWatchList(payload), onSuccess: (msg) => { toast(msg.status_message); queryClient.invalidateQueries({ queryKey: ["movieDetails"] }); }, }); return { setMovieWatchListMutation, ...mutationState, }; }; export default useMovieWatchListMutation; |