All files / src/mutations useDeleteSessionMutation.ts

55.55% Statements 5/9
100% Branches 0/0
33.33% Functions 1/3
55.55% Lines 5/9

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 24x 24x   24x                 24x        
import { useMutation } from "@tanstack/react-query";
import { deleteSession } from "@/api";
 
import useUserStore from "@/store/useUserStore";
import useMovieStore from "@/store/useMovieStore";
 
const useDeleteSessionMutation = () => {
  const { resetMovieStatus } = useMovieStore();
  const { resetState } = useUserStore();
 
  const { mutateAsync: deleteSessionMutation } = useMutation({
    mutationFn: (payload: string) => deleteSession(payload),
    onSuccess: () => {
      resetState();
      resetMovieStatus();
      localStorage.clear();
    },
  });
 
  return { deleteSessionMutation };
};
 
export default useDeleteSessionMutation;