import React from 'react' import Link from 'next/link' import isEmail from 'validator/lib/isEmail' import axios from 'axios' import {FormController, Input, Button} from '~/components/form' import useErrorReducer from '../hooks/errorReducer' export default function Register(){ const [errors, dispatch] = useErrorReducer() const submit = async (values)=>{ try { const {data} = await axios.post(`/api/users`, values) console.log(data) } catch (err) { if(!err.response || err.response.status !== 422) throw err; dispatch({ type: 'set_errors', errors: err.response.data.errors }) } } return (

Register

isEmail(value)} hint="Enter a valid email address" /> (value.length >= 8)} hint="Password must be at least 8 characters long" /> (value === fields.password.value)} hint="Passwords must match" />

Already have an account? Login here.

) }