auth validation

This commit is contained in:
Виталий Лавшонок
2025-11-23 13:53:48 +03:00
parent dae4584840
commit ee0e44082a
5 changed files with 147 additions and 17 deletions

View File

@@ -27,7 +27,6 @@ const Login = () => {
// После успешного логина
useEffect(() => {
dispatch(setMenuActivePage('account'));
submitClicked;
}, []);
useEffect(() => {
@@ -47,6 +46,21 @@ const Login = () => {
dispatch(loginUser({ username, password }));
};
const getErrorLoginMessage = (): string => {
if (!submitClicked) return '';
if (username == '') return 'Поле не может быть пустым';
if (password == '') return '';
if (status === 'failed')
return 'Неверное имя пользователя и/или пароль';
return '';
};
const getErrorPasswordMessage = (): string => {
if (!submitClicked) return '';
if (password == '') return 'Поле не может быть пустым';
return '';
};
return (
<div className="h-svh w-svw fixed pointer-events-none top-0 left-0 flex items-center justify-center">
<div className="grid gap-[80px] grid-cols-[400px,384px] box-border relative ">
@@ -73,6 +87,7 @@ const Login = () => {
setUsername(v);
}}
placeholder="login"
error={getErrorLoginMessage()}
/>
<Input
name="password"
@@ -84,6 +99,7 @@ const Login = () => {
setPassword(v);
}}
placeholder="abCD1234"
error={getErrorPasswordMessage()}
/>
<div className="flex justify-end mt-[10px]">