|
@@ -1,9 +1,10 @@
|
|
|
-import { Mutation, useMutation } from 'react-apollo'
|
|
|
+import { SyntheticEvent } from 'react'
|
|
|
+import { useMutation } from '@apollo/react-hooks'
|
|
|
import * as Yup from 'yup'
|
|
|
|
|
|
import { useFormHandler, TextInput } from '../form/forms'
|
|
|
import { USER_SIGNUP } from './graphql'
|
|
|
-import { SyntheticEvent } from 'react'
|
|
|
+import { userValidation } from './validation'
|
|
|
|
|
|
|
|
|
const initialValues = {
|
|
@@ -13,23 +14,10 @@ const initialValues = {
|
|
|
passwordAgain: '1234'
|
|
|
}
|
|
|
|
|
|
-const validationScheme = Yup.object({
|
|
|
- name: Yup.string()
|
|
|
- .required('Required')
|
|
|
- .max(40, 'Must be 40 characters or less'),
|
|
|
- email: Yup.string()
|
|
|
- .email('Invalid email address')
|
|
|
- .required('Required'),
|
|
|
- password: Yup.string()
|
|
|
- .min(4, 'Must have at least 8 characters'),
|
|
|
- passwordAgain: Yup.string()
|
|
|
- .oneOf([Yup.ref('password'), null], 'Passwords must match')
|
|
|
-})
|
|
|
-
|
|
|
|
|
|
const SignupForm = () => {
|
|
|
|
|
|
- const { inputProps, values } = useFormHandler(initialValues, validationScheme.isValid)
|
|
|
+ const { inputProps, values } = useFormHandler(initialValues, userValidation.validate)
|
|
|
const [userSignup, { loading, error }] = useMutation(USER_SIGNUP)
|
|
|
|
|
|
return (
|