You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
734 B
JavaScript

import React from 'react'
import isEmail from 'validator/lib/isEmail'
import axios from 'axios'
import {FormController, Input, Button} from '~/components/form'
export default function Login(){
const submit = async (values)=>{
const {data} = await axios.post(`/api/auth`, values)
console.log(data)
}
return (
<FormController onSubmit={submit}>
<h1>Login</h1>
<Input label="Email" type="text" name="email" validate={value=>isEmail(value)} hint="Enter a valid email address" />
<Input label="Password" type="password" name="password" validate={value=>(value.length >= 8)} hint="Password must be at least 8 characters long" />
<Button type="submit">Submit</Button>
</FormController>
)
}