import { useState, useEffect } from "react"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { CheckCircle2, XCircle, Loader2, Mail } from "lucide-react"; export default function VerifyPage() { const [status, setStatus] = useState<"loading" | "success" | "error">("loading"); const [message, setMessage] = useState(""); useEffect(() => { const params = new URLSearchParams(window.location.search); const token = params.get("token"); if (!token) { setStatus("error"); setMessage("No verification token provided."); return; } fetch(`/api/auth/verify/${token}`) .then(async (res) => { const data = await res.json(); if (!res.ok) { throw new Error(data.error || "Verification failed"); } return data; }) .then(() => { setStatus("success"); setMessage("Email verified successfully!"); // Auto-login set by server via session cookie. // Redirect to dashboard using full page navigation (not wouter hash routing) // so the auth context picks up the new session cookie. setTimeout(() => { window.location.href = "/#/"; }, 2000); }) .catch((err) => { setStatus("error"); setMessage(err.message || "Verification failed."); }); }, []); return (
G

GammaDesk

{status === "loading" && ( <>
Verifying... Please wait while we verify your email )} {status === "success" && ( <>
Account Verified! {message} )} {status === "error" && ( <>
Verification Failed {message} )}
{status === "success" && (
Redirecting to dashboard...
)} {status === "error" && ( )}
); }