1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00

refactor login dialog

This commit is contained in:
Fedor Katurov 2023-10-30 17:50:40 +06:00
parent 7e20975cb1
commit 7458fb2e55
5 changed files with 88 additions and 63 deletions

View file

@ -0,0 +1,58 @@
import { FC } from 'react';
import { Group } from '~/components/containers/Group';
import { Button } from '~/components/input/Button';
import { InputText } from '~/components/input/InputText';
import { useLoginForm } from '~/hooks/auth/useLoginForm';
import { IUser } from '~/types/auth';
import styles from './styles.module.scss';
interface LoginFormProps {
login: (username: string, password: string) => Promise<IUser>;
onSuccess: () => void;
onRestoreRequest: () => void;
}
const LoginForm: FC<LoginFormProps> = ({
login,
onSuccess,
onRestoreRequest,
}) => {
const { values, errors, handleSubmit, handleChange } = useLoginForm(
login,
onSuccess,
);
return (
<Group>
<form onSubmit={handleSubmit}>
<InputText
title="Логин"
handler={handleChange('username')}
value={values.username}
error={errors.username}
autoFocus
/>
<InputText
title="Пароль"
handler={handleChange('password')}
value={values.password}
error={errors.password}
type="password"
/>
<Button
color="link"
type="button"
onClick={onRestoreRequest}
className={styles.forgot_button}
>
Вспомнить пароль
</Button>
</form>
</Group>
);
};
export { LoginForm };

View file

@ -0,0 +1,3 @@
.forgot_button {
opacity: 0.5;
}