"use client" import { Box, Typography } from "@mui/material" import { useRouter } from "next/navigation" import React, { useState } from "react" import { useTranslation } from "react-i18next" import { auth } from "@app/account/controller/AuthController" import Button from "@atoms/Button" import Input from "@atoms/Input" import Label from "@atoms/Label" const LoginForm: React.FC = () => { const [username, setUsername] = useState("") const [password, setPassword] = useState("") const [error, setError] = useState(null) const router = useRouter() const { t } = useTranslation() const handleLogin = async () => { const token = await auth(username, password) if (token) { router.push("/home") } else { setError( t("msj_Incorrect_credentials_try_again.")) } } return ( { e.preventDefault() handleLogin() }} sx={{ display: "flex", flexDirection: "column", gap: 3, width: "100%" }} > {error && {error}}