import useConfirmUser from '@/hooks/auth/useConfirmUser'; import createErrorToast from '@/util/createErrorToast'; import Head from 'next/head'; import { FC, useState } from 'react'; import { toast } from 'react-hot-toast'; const ConfirmUserPage: FC = () => { const { needsToLogin, tokenInvalid } = useConfirmUser(); const [confirmationResent, setConfirmationResent] = useState(false); const onClick = async () => { const resentConfirmationLoadingToast = toast.loading( 'Resending your confirmation email.', ); try { const response = await fetch('/api/users/resend-confirmation', { method: 'POST', }); if (!response.ok) { throw new Error('Something went wrong.'); } toast.remove(resentConfirmationLoadingToast); toast.success('Sent a new confirmation email.'); setConfirmationResent(true); } catch (err) { createErrorToast(err); } }; return ( <> Confirm User | The Biergarten App
{needsToLogin && (

Please login to confirm your account.

)} {!needsToLogin && tokenInvalid && !confirmationResent && ( <>

Your confirmation token is invalid or is expired.

)} {!needsToLogin && tokenInvalid && confirmationResent && ( <>

Resent your confirmation link.

Please check your email.

)}
); }; export default ConfirmUserPage;