Files
crosscode-platform/apps/accounts/frontend/src/app/account/confirm-email/ConfirmEmail.tsx
T
joshuaandClaude Opus 5.5 f202a5a88e Accounts 1.0.0 frontend and @crosscode/ui
Sign-in steps (password, sign-up, email code, two-step sign-in and its
setup with recovery codes, privacy notice, news question), forgot and
reset password, the account page, admin (people, deletions, church
profile, linked products, settings, notice, licence, audit) and setup.
Strict CSP with a nonce per page; church colours from the profile.
@crosscode/ui gets its first components (shell, card, fields, buttons).
Plan: roles stay in each product (asked 2026-11-18).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 13:42:45 +02:00

31 lines
1.3 KiB
TypeScript

"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 (
<Shell branding={branding}>
<Card>
<Heading>Your email address</Heading>
{state ? <Notice tone={state.ok ? "success" : "error"}>{state.text}</Notice> : <p className="text-gray-600">Confirming…</p>}
<a href="/account" className="text-brand underline">Back to your account</a>
</Card>
</Shell>
);
}