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.

567 B
Raw Blame
import { useMutation } from "@tanstack/react-query";
import { authClient } from "@/lib/auth-client";

export const SESSION_TOO_OLD = "SESSION_TOO_OLD";

function useDeleteAccount() {
  return useMutation({
    mutationFn: async () => {
      const { data, error } = await authClient.deleteUser();

      if (error) {
        if (error.code === "SESSION_EXPIRED") {
          throw new Error(SESSION_TOO_OLD);
        }

        throw new Error(error.message || "Failed to delete account");
      }

      return data;
    },
  });
}

export default useDeleteAccount;