diff --git a/sports-matcher/client/src/pages/SIgnup.js b/sports-matcher/client/src/pages/SIgnup.js new file mode 100644 index 0000000..c603579 --- /dev/null +++ b/sports-matcher/client/src/pages/SIgnup.js @@ -0,0 +1,88 @@ +import React from "react"; +import { Button, Card, Form } from "react-bootstrap"; +import { apiClient } from "../utils/httpClients"; +import { guard } from "../utils/routing"; + +export default class Signup extends React.Component { + constructor(props) { + super(props); + this.state = { + user: null, + alertShow: false, + alertKey: null, + alertMsg: null + } + this.state.user = { + email: null, + firstName: null, + lastName: null, + phone: null, + password: null + } + } + + async registerUser() { + const res = await apiClient.post("/user", this.state); + if (res.status === 200) { + this.warnUser("You are successfully signed up!", "success") + } else if (res === 409) { + this.warnUser("This user already exists. Try logging in instead.", "danger") + } else if (res === 400) { + this.warnUser("Missing required fields.", "danger") + } else { + this.warnUser("Internal server error. Please try again later.", "danger") + } + } + + setUserState(event) { + newUser = this.state.user; + newUser[event.target.controlId] = event.target.value + this.setState({user: newUser}) + } + + warnUser(msg, key) { + this.setState({alertMsg: msg}) + this.setState({show: true}) + } + + render() { + return ( +
+ + {this.state.alertMsg} + + + + Login + Welcome to Sports Matcher! +
+ + First name + + + + Last name + + + + E-mail + + + + Phone number + + + + Password + + + +
+
+
+
+ ); + } +}