/home/techb158/balavpn.abdallabala.com/src/app/accept-invite
NameSizeModeActions
page.jsx34790644editdlrm
Edit: /home/techb158/balavpn.abdallabala.com/src/app/accept-invite/page.jsx (3479B)
"use client"; import { Suspense, useState, useEffect } from "react"; import { useRouter, useSearchParams } from "next/navigation"; function AcceptInviteForm() { const router = useRouter(); const searchParams = useSearchParams(); const token = searchParams.get("token"); const [displayName, setDisplayName] = useState(""); const [error, setError] = useState(""); const [loading, setLoading] = useState(false); const [done, setDone] = useState(false); useEffect(() => { if (!token) setError("No invitation token provided. Check your invite link."); }, [token]); async function handleSubmit(event) { event.preventDefault(); setError(""); setLoading(true); try { const res = await fetch("/api/auth/accept-invite", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ token, displayName: displayName || undefined }) }); if (!res.ok) { const data = await res.json(); throw new Error(data.error || "Failed to accept invitation"); } setDone(true); setTimeout(() => router.push("/login"), 2000); } catch (err) { setError(err.message); setLoading(false); } } if (done) { return (
🎉

Invitation accepted!

Redirecting to login...

); } return (
COSMIC AI-Risk SaaS

Accept invitation

You've been invited to join a team.

{error && (
{error}
)} {token ? (
setDisplayName(e.target.value)} placeholder="Jane Doe" style={{ width: "100%", padding: "10px 12px", borderRadius: 8, border: "1px solid var(--line)", fontSize: 16, boxSizing: "border-box" }} />
) : (

Create a new account instead

)}
); } export default function AcceptInvitePage() { return (
}>
); }