diff --git a/src/pages/Auth/Signup/index.tsx b/src/pages/Auth/Signup/index.tsx index 4deb5d2..cf6bd22 100644 --- a/src/pages/Auth/Signup/index.tsx +++ b/src/pages/Auth/Signup/index.tsx @@ -1,9 +1,41 @@ +import * as Yup from 'yup'; +import { useFormik } from 'formik'; +import { useState } from 'react'; +import { useHistory } from 'react-router-dom'; import { Google, Signup as SignupIllustration, Logo } from '../../../assets'; -import { Box, Button, Input, Link, Text } from '../../../components'; +import { Box, Button, Input, Link, Text, Alert } from '../../../components'; import { theme } from '../../../themes'; import { Wrapper } from './styles'; const Signup = () => { + const history = useHistory(); + const [error, setError] = useState(''); + + const form = useFormik({ + initialValues: { + email: '', + password: '', + }, + validationSchema: Yup.object().shape({ + email: Yup.string() + .required('Email is required') + .email('Email is invalid'), + password: Yup.string() + .required('Password is required') + .min(6, 'Password is 6 characters minimum'), + }), + onSubmit: ({ email, password }, { resetForm }) => { + try { + history.push(`/additional-info?email=${email}&password=${password}`); + } catch (err) { + setError(err.message); + setTimeout(() => setError(''), 3000); + } finally { + resetForm(); + } + }, + }); + return ( { - - astrobuild - - - Signup - - {}} /> - {}} - /> + + Signup + + {error && } + +
-