import { createFileRoute, Link, redirect } from "@tanstack/react-router"; import { useState } from "react"; import SignInForm from "@/components/sign-in-form"; import SignUpForm from "@/components/sign-up-form"; import AuthLayout from "@/components/auth-layout"; import { Button } from "@/components/ui/button"; import { account } from "@/lib/auth-client"; export const Route = createFileRoute("/login")({ beforeLoad: async () => { let me = null; try { me = await account.get(); } catch { // ignore } console.log(me) if (me) { const isVerified = Boolean(me.emailVerification); if (isVerified) { throw redirect({ to: "/dashboard" }); } throw redirect({ to: "/verify-email" }); } }, component: RouteComponent, }); function RouteComponent() { const [showSignIn, setShowSignIn] = useState(false); const title = showSignIn ? "Welcome back" : "Create your account"; const subtitle = showSignIn ? "Sign in to access your dashboard and keep creating." : "Join Reflecto to capture ideas and collaborate seamlessly."; return (
{showSignIn ? ( ) : ( )}
} subtitle={subtitle} title={title} > {showSignIn ? ( setShowSignIn(false)} /> ) : ( setShowSignIn(true)} /> )}
); }