import { useEffect, useState, type FormEvent } from "react"; import { useNavigate } from "react-router-dom"; import { useTranslation } from "react-i18next"; import { useLogin } from "../api/queries"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Label } from "@/components/ui/label"; export function LoginPage() { const { t } = useTranslation(); const navigate = useNavigate(); const login = useLogin(); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); useEffect(() => { document.title = t("app.name"); }, [t]); const onSubmit = (event: FormEvent) => { event.preventDefault(); login.mutate( { email, password }, { onSuccess: () => navigate("/objects", { replace: true }) }, ); }; const errorKey = login.error ? login.error.message === "invalid" ? "auth.invalid" : "auth.networkError" : null; return (

{t("app.name")}

setEmail(event.target.value)} autoComplete="username" />
setPassword(event.target.value)} autoComplete="current-password" />
{errorKey && (

{t(errorKey)}

)}
); }