purple-welcome.tsx (982B)
1 import Head from "next/head"; 2 import { PurpleWelcome } from "../sections/PurpleWelcome"; 3 import { useIntl } from "react-intl"; 4 import { useEffect, useState } from "react"; 5 import { ErrorDialog } from "../ErrorDialog"; 6 import { usePurpleLoginSession } from "@/hooks/usePurpleLoginSession"; 7 8 9 export function PurpleWelcomePage() { 10 const intl = useIntl() 11 const [error, setError] = useState<string | null>(null) 12 const { accountInfo: existingAccountInfo, logout } = usePurpleLoginSession(setError) 13 14 useEffect(() => { 15 if (existingAccountInfo === null) { 16 // Redirect to the login page 17 window.location.href = "/purple/login?redirect=" + encodeURIComponent("/purple/welcome") 18 } 19 }, [existingAccountInfo]) 20 21 return (<> 22 <Head> 23 <title>Welcome to Damus Purple</title> 24 </Head> 25 <main style={{ scrollBehavior: "smooth" }}> 26 <ErrorDialog error={error} setError={setError} /> 27 {existingAccountInfo && <PurpleWelcome/>} 28 </main> 29 </>) 30 }