Skip to content

armgit / kaneo

Public Imported from GitHub
0

⚡ Project management that doesn't become the project. Boards, Gantt charts, and GitHub integration. Self-host it or use Kaneo Cloud.

951 B
Raw Blame
import { useMutation, useQueryClient } from "@tanstack/react-query";
import { ImageMinusIcon } from "lucide-react";
import { useTranslation } from "react-i18next";
import { removeProjectBackground } from "@/fetchers/project/background";
import { toast } from "@/lib/toast";

function useRemoveProjectBackground() {
  const { t } = useTranslation();
  const queryClient = useQueryClient();

  return useMutation({
    mutationFn: removeProjectBackground,
    onSuccess: async (_data, projectId) => {
      await Promise.all([
        queryClient.invalidateQueries({ queryKey: ["tasks", projectId] }),
        queryClient.invalidateQueries({ queryKey: ["projects"] }),
      ]);
      toast.success(t("settings:projectGeneral.backgroundRemoveSuccess"), {
        icon: ImageMinusIcon,
      });
    },
    onError: () => {
      toast.error(t("settings:projectGeneral.backgroundRemoveError"));
    },
  });
}

export default useRemoveProjectBackground;