"use client"; import { useState } from "react"; import { signOut } from "next-auth/react"; import { useTranslations } from "next-intl"; import { Button } from "@/components/Button"; import InfoMessage from "@/components/InfoMessage"; import { deleteAccount } from "@/server/deleteAccount"; import { useRouter } from "@/utils/routing"; export default function Contact() { const t = useTranslations("DeleteAccount"); const at = useTranslations("App"); const router = useRouter(); const [deleting, setDeleting] = useState(false); const [deleted, setDeleted] = useState(false); const [error, setError] = useState(false); const onDeleteAccount = async () => { try { setDeleting(true); const result = await deleteAccount(); if (result?.validationErrors) { throw new Error("ERR_VALIDATION"); } else if (result?.serverError) { throw new Error(result.serverError); } signOut({ redirect: false }); setDeleted(true); } catch { setDeleting(false); setError(true); } }; return (

{t("title")}

{deleted ? ( ) : ( <>

{t("info")}

{error && }
)}
); }