import React from "react"; import TextField from "@material-ui/core/TextField"; import { styled } from "@material-ui/core/styles"; import { useInput } from "../../utils/forms"; import { Auth } from "aws-amplify"; import Button from "@material-ui/core/Button"; import CircularProgress from "@material-ui/core/CircularProgress"; import { Link, useHistory } from "react-router-dom"; const Field = styled(TextField)({ margin: "10px 0", }); const DLink = styled(Link)({ margin: "15px 0", textAlign: "right", }); const Signup: React.FC = () => { const [loading, setLoading] = React.useState(false); const history = useHistory(); const { value: name, bind: bindName } = useInput(""); const { value: email, bind: bindEmail } = useInput(""); const { value: password, bind: bindPassword } = useInput(""); const { value: confirmPassword, bind: bindConfirmPassword } = useInput(""); const handleSignUp = async (e: React.SyntheticEvent) => { e.preventDefault(); setLoading(true); if (password !== confirmPassword) { alert("Error: Password and Confirm Password fields should match"); return; } try { await Auth.signUp({ username: name, password: confirmPassword, attributes: { email, name }, }). then( () => { history.push("/confirmation"); }); } catch (error) { alert(error.message); console.log(error.message); } setLoading(false); }; return (

{" "} Register a New Account

Back to login → ); }; export default Signup;