blob: 0ab10c9512e0a56dcf332faf864be2ced18ebe4f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
import { useState } from 'react';
import { useAuthState } from '../../context/auth';
import { useDocumentTitle } from '../../hooks/useDocumentTitle';
import useLayoutType from '../../hooks/useLayoutType';
import View from './View';
function Login() {
useDocumentTitle('Entrar');
const { login, isPending, isError, error } = useAuthState();
const layoutType = useLayoutType();
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const isSubmitable = email.length !== 0 && password.length !== 0;
const onTryLogin = () => {
isSubmitable && login(email, password);
};
return (
<View
email={email}
password={password}
onChangeEmail={setEmail}
onChangePassword={setPassword}
isSubmitable={isSubmitable}
onTryLogin={onTryLogin}
isPending={isPending}
isError={isError}
error={error}
layoutType={layoutType}
/>
);
}
export default Login;
|