import { useMutation } from "@tanstack/react-query";
import { notification } from "../../../service/notifications";
import { fetchClient, queryClient } from "../../api";
import { AutoAlbumQueryKeys } from "./useFetchAutoAlbumQuery";
import { AutoAlbumsQueryKeys } from "./useFetchAutoAlbumsQuery";

export const useDeleteAllAutoAlbumsMutation = () =>
  useMutation({
    mutationFn: async () => {
      await fetchClient.post("/albums/auto/delete_all/");
      notification.deleteAutogeneratedAlbums();
    },
    onSuccess: () => {
      queryClient.invalidateQueries({ queryKey: [...AutoAlbumsQueryKeys] });
      queryClient.invalidateQueries({ queryKey: [...AutoAlbumQueryKeys] });
    },
  });
