import type { Metadata } from "next"; import NextLink from "next/link"; import { Link } from "@unlocalhosted/metalui"; import { MailIcon } from "@/components/icons"; import { Alert, Box } from "@/components/ui"; import { getViewer } from "@/lib/auth"; import { confirmEmail } from "@/lib/emails"; export const metadata: Metadata = { title: "Confirm your email address" }; /** Where the link in a verification email (lib/emails.ts) leads. Opening it confirms the address. */ export default async function VerifyEmailPage({ searchParams }: PageProps<"/login/verify-email">) { const token = (await searchParams).token; const [user, viewer] = await Promise.all([typeof token === "string" ? confirmEmail(token) : null, getViewer()]); return (

Confirm your email address

{user ? ( {user.email} is confirmed as the address of @{user.username}. ) : ( This link has expired, or the account’s email address has changed since. Send a new one from your profile settings. )}

{viewer ? ( }>{user ? "Go to your dashboard" : "Open profile settings"} ) : ( }>Sign in )}

); }