import { createFileRoute, useNavigate, Link } from "@tanstack/react-router"; import { useEffect, useState } from "react"; import { useAuth } from "@/lib/auth"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "@/components/ui/card"; import { Scale, Loader2, ShieldCheck } from "lucide-react"; import { toast } from "sonner"; export const Route = createFileRoute("/login")({ component: LoginPage, }); function LoginPage() { const { signIn, session, loading } = useAuth(); const navigate = useNavigate(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [submitting, setSubmitting] = useState(false); useEffect(() => { if (!loading && session) navigate({ to: "/" }); }, [loading, session, navigate]); const onSubmit = async (e: React.FormEvent) => { e.preventDefault(); setSubmitting(true); const { error } = await signIn(email.trim(), password); setSubmitting(false); if (error) { toast.error("Sign-in failed", { description: error }); } else { navigate({ to: "/" }); } }; return (
Cases, clients, documents, time, and billing — secured behind authenticated access and row-level data protection. Designed for HOA-focused firms and beyond.