'use client'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { useState } from 'react'; import { api, client, useMe } from '@/lib/api'; import { SupportLink } from './SupportLink'; export function Nav() { const { me, mutate } = useMe(); const router = useRouter(); const logout = async () => { await api('/auth/logout', { method: 'POST', body: {} }); await mutate(undefined, { revalidate: true }); router.push('/'); }; return ( <> {me && !me.emailVerified && } ); } /** Until they confirm, a forgotten password can't be reset; nudge them. */ function VerifyBanner({ email }: { email: string }) { const [sent, setSent] = useState(false); const resend = async () => { try { await client.resendVerification(); setSent(true); } catch (err) { alert((err as Error).message); } }; return (
Confirm your email: we sent a link to {email}.{' '} {sent ? Sent again. : }
); }