1
0
Fork 0
mirror of https://github.com/muerwre/vault-frontend.git synced 2025-04-24 20:36:40 +07:00
vault-frontend/src/components/auth/login/LoginForm/index.tsx
2023-10-30 17:50:40 +06:00

58 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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 };