import { useMutation } from "@tanstack/react-query"; import { AlertDialog, XStack, YStack } from "tamagui"; import { deleteUser } from "@movie-web/api"; import { useAuth } from "~/hooks/useAuth"; import { useAuthStore } from "~/stores/settings"; import { MWButton } from "../ui/Button"; export function DeleteAccountAlert() { const account = useAuthStore((state) => state.account); const backendUrl = useAuthStore((state) => state.backendUrl); const { logout } = useAuth(); const logoutMutation = useMutation({ mutationKey: ["logout"], mutationFn: logout, }); const deleteAccountMutation = useMutation({ mutationKey: ["deleteAccount"], mutationFn: () => deleteUser(backendUrl, account!), onSuccess: () => { logoutMutation.mutate(); }, }); return ( Delete account Are you sure? This action is irreversible. All data will be deleted and nothing can be recovered. Cancel deleteAccountMutation.mutate()} > I am sure ); }