import React, { useState } from 'react' import { useHistory } from 'react-router-dom' import login from '@wasp/auth/login.js' import signup from '@wasp/actions/signup' export default () => { const history = useHistory() const [username, setUsername] = useState() const [email, setEmail] = useState() const [password, setPassword] = useState() const [submitError, setSubmitError] = useState() // TODO: Do validation in form and show validation errors. const handleSubmit = async (event) => { event.preventDefault() setSubmitError(null) try { await signup({ username, email, password }) await login(email, password) history.push('/') } catch (err) { setSubmitError(err) } } // TODO: I should look into using bootstrap v4, it might make all this simpler. return (
{ submitError && (

{ submitError.message || submitError }

) }

Username

setUsername(e.target.value)} />

Email

setEmail(e.target.value)} />

Password

setPassword(e.target.value)} />
) }