import { CheckCircleIcon, XCircleIcon } from "@phosphor-icons/react"; import { useEffect, useRef, useState } from "react"; import { useNavigate, useParams } from "react-router-dom"; import { publicApi } from "../api/apiClient"; import Logo from "../components/Logo"; import { endpoints, replacePathParams } from "../config/endpoints"; import { ROUTES } from "../config/routes"; export default function Activate() { const { uidb64, token } = useParams(); const [status, setStatus] = useState<"loading" | "success" | "error">( "loading", ); const hasCalled = useRef(false); const navigate = useNavigate(); useEffect(() => { if (!(uidb64 && token) || hasCalled.current) return; // prevent double api calls hasCalled.current = true; const activateAccount = async () => { try { const url = replacePathParams(endpoints.ACTIVATE, { uidb64, token, }); await publicApi.get(url); setStatus("success"); } catch (_err) { setStatus("error"); } }; activateAccount(); }, [uidb64, token]); return (
Activating your account...
Welcome to
Your identity is now verified and ready for timeless letters.
The link might be expired or already used. Please try registering again.