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:
parent
7e20975cb1
commit
7458fb2e55
5 changed files with 88 additions and 63 deletions
58
src/components/auth/login/LoginForm/index.tsx
Normal file
58
src/components/auth/login/LoginForm/index.tsx
Normal 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 };
|
3
src/components/auth/login/LoginForm/styles.module.scss
Normal file
3
src/components/auth/login/LoginForm/styles.module.scss
Normal file
|
@ -0,0 +1,3 @@
|
|||
.forgot_button {
|
||||
opacity: 0.5;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue