"use client"; import { useState } from "react"; import { Card, Heading, Notice, Shell } from "@crosscode/ui"; import { useBranding } from "@/components/BrandingProvider"; import { call, selfSignIn } from "@/lib/api"; import { useExternalEffect } from "@/lib/hooks"; export function ConfirmEmail({ token }: { token: string }) { const branding = useBranding(); const [state, setState] = useState<{ ok: boolean; text: string } | null>(null); useExternalEffect(() => { let alive = true; call("POST", "/me/email/confirm", { token }).then((r) => { if (!alive) return; if (r.status === 401) return window.location.assign(selfSignIn(`/account/confirm-email?token=${encodeURIComponent(token)}`)); setState(r.ok ? { ok: true, text: "Your new email address is confirmed. Sign in with it from now on." } : { ok: false, text: r.error.message }); }); return () => { alive = false; }; }, [token]); return ( Your email address {state ? {state.text} :

Confirming…

} Back to your account
); }