import React from 'react' import Link from 'next/link' import Head from 'next/head' import Router from 'next/router' import isEmail from 'validator/lib/isEmail' import axios from 'axios' import {useSetUser} from '~/hooks/useUser' import {useSetCart} from '~/hooks/useCart' import {FormController, Input, Button} from '~/components/form' import useAccountRedirect from '~/hooks/useAccountRedirect' export default function Login(){ useAccountRedirect() const setUser = useSetUser() const setCart = useSetCart() const redirectAfterLogin = user => { setUser(user) axios.get(`/api/cart`).then(({data: cart}) => setCart(cart)); if (user.is_admin) Router.push('/admin') else Router.push('/account') } return ( <> Login | Society of Socks

Login

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

Forgot your password? Reset your password.

Need an account? Register here.

) }