import { useEffect, useRef } from "react"; import { Center, Flex, Box, FormControl, FormErrorMessage, FormLabel, Input, Stack, useColorModeValue, useToast, } from "@chakra-ui/react"; import { Formik, Form, Field } from "formik"; import { LocalePicker, PrettyButton, ThemeSwitcher } from "src/components"; import { useAuthState } from "src/context"; import { intl } from "src/locale"; import { validateEmail, validateString } from "src/modules/Validations"; // import logo from "../../img/logo-256.png"; function Login() { const toast = useToast(); const emailRef = useRef(null); const { login } = useAuthState(); const onSubmit = async (values: any, { setSubmitting }: any) => { const showErr = (msg: string) => { toast({ description: intl.formatMessage({ id: `error.${msg}`, }), status: "error", position: "top", duration: 3000, isClosable: true, }); }; try { await login(values.email, values.password); } catch (err) { if (err instanceof Error) { showErr(err.message); } } setSubmitting(false); }; useEffect(() => { // @ts-expect-error ts-migrate(2531) FIXME: Object is possibly 'null'. emailRef.current.focus(); }, []); return (
Logo
{({ isSubmitting }) => (
{({ field, form }: any) => ( {intl.formatMessage({ id: "user.email" })} {form.errors.email} )} {({ field, form }: any) => ( {intl.formatMessage({ id: "user.password", })} {form.errors.password} )} {/* {intl.formatMessage({ id: "login.forgot", })} */} {intl.formatMessage({ id: "login.login", })}
)}
); } export default Login;