Commit fb58b221 authored by Daniel Puchala's avatar Daniel Puchala
Browse files

feat: invalid credential error added

parent 79842b1d
......@@ -7,19 +7,27 @@ export const Login = () => {
const navigate = useNavigate();
const [ name, setName ] = useState<string>('');
const [ password, setPassword ] = useState<string>('');
const [ isError, setIsError ] = useState<boolean>(false);
async function handleSubmit(event: any) {
event.preventDefault();
const response: any = await login(name, password);
response.status === 200 ? navigate('/pa165/', { replace: true }) : alert('Invalid credentials');
if (response.status === 200) {
setIsError(false);
navigate('/pa165/', { replace: true });
} else {
setIsError(true);
alert('Invalid credentials');
}
}
return (
<div className="h-[100vh]">
<Header/>
<div className="grid place-items-center h-[90%]">
{isError && <div className="text-2xl text-center font-bold mt-auto text-red-900">Invalid credentials</div>}
<form onSubmit={handleSubmit}
className="flex flex-col w-1/4 gap-3 border-2 border-black rounded-lg bg-slate-300 p-4">
className={`flex flex-col w-1/4 gap-3 border-2 border-black rounded-lg bg-slate-300 p-4 mb-auto ${isError || 'mt-auto'}`}>
<p className="text-2xl text-center font-bold">Login</p>
<label className="flex justify-between">
Username:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment