import React, { useState } from 'react' import { useHistory } from 'react-router-dom' import login from '@wasp/auth/login' import signup from '@wasp/auth/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.message || submitError }
) }