import { useEffect, useState } from "react"; import { useSearchParams, useNavigate } from "react-router-dom"; import { CheckCircle, XCircle, Loader2, Mail } from "lucide-react"; import { Button } from "@/components/ui/button"; import { Card, CardContent } from "@/components/ui/card"; import { SecuirdLogo } from "@/components/branding/SecuirdLogo"; import { api, ApiError } from "@/lib/api"; type Status = "loading" | "success" | "error" | "missing"; export default function ActivatePage() { const [searchParams] = useSearchParams(); const navigate = useNavigate(); const [status, setStatus] = useState("loading"); const [message, setMessage] = useState(""); useEffect(() => { const code = searchParams.get("code") || searchParams.get("activation_key") || searchParams.get("key"); if (!code) { setStatus("missing"); return; } api.auth .activate(code) .then(() => { setStatus("success"); setMessage("Your account has been activated. You can now sign in."); }) .catch((err) => { const msg = err instanceof ApiError ? err.message : "Activation failed. The link may have expired or already been used."; setMessage(msg); setStatus("error"); }); }, [searchParams]); return (
{/* Logo */}
{status === "loading" && ( <>

Activating your account…

)} {status === "success" && ( <>

Account Activated

{message}

)} {status === "error" && ( <>

Activation Failed

{message}

)} {status === "missing" && ( <>

Invalid Activation Link

No activation code was found in this link. Please check your email and use the link provided.

)}
); }