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.

703 B
Raw Blame
import { useMutation, useQueryClient } from "@tanstack/react-query";
import deleteAvatar from "@/fetchers/user/delete-avatar";
import { authClient } from "@/lib/auth-client";
import invalidateUserProfileQueries from "./invalidate-user-profile-queries";

function useRemoveUserAvatar() {
  const queryClient = useQueryClient();

  return useMutation({
    mutationFn: async () => {
      const { error } = await authClient.updateUser({ image: null });

      if (error) {
        throw new Error(error.message || "Failed to remove profile picture");
      }

      return deleteAvatar();
    },
    onSuccess: () => invalidateUserProfileQueries(queryClient),
  });
}

export default useRemoveUserAvatar;