From 6f11a3e2c06f5f3a80f69347263f34880d36ab54 Mon Sep 17 00:00:00 2001 From: Ruidy Nemausat Date: Thu, 23 Apr 2020 21:15:28 +0200 Subject: [PATCH] adds TODO; signup page layout and base --- TODO.md | 7 ++ client/src/pages/SignUp/index.jsx | 107 +++++++++++++++++++++++++-- client/src/services/auth/firebase.js | 5 +- 3 files changed, 108 insertions(+), 11 deletions(-) create mode 100644 TODO.md diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000..dd58467 --- /dev/null +++ b/TODO.md @@ -0,0 +1,7 @@ +# TODO + +- [ ] Doc +- [ ] Tests +- [ ] PropTypes +- [ ] AuthSlice +- [ ] Redux thunk for validation diff --git a/client/src/pages/SignUp/index.jsx b/client/src/pages/SignUp/index.jsx index 1d25d72..d507f69 100644 --- a/client/src/pages/SignUp/index.jsx +++ b/client/src/pages/SignUp/index.jsx @@ -1,13 +1,106 @@ -import React from "react"; -import { Container } from "reactstrap"; -import ItemModal from "../../components/ItemModal"; -import List from "../../components/List"; +import React, { useState } from "react"; +import { Link } from "react-router-dom"; +import { Button, Form, FormGroup, Label, Input, Container } from "reactstrap"; +import * as ROUTES from "../../constants/routes"; +import { useFirebase } from "../../services/auth"; + +const useStyles = () => ({ + root: { + paddingTop: "1rem", + paddingBottom: "1rem", + }, + inputField: { + paddingBottom: "1rem", + }, + button: { + marginTop: "1rem", + marginBottom: "1rem", + }, +}); export default function SignUpPage() { + const styles = useStyles(); return ( - - - + +

Sign Up

+
); } + +export const SignUpForm = () => { + const [userName, setUserName] = useState(""); + const [email, setEmail] = useState(""); + const [password1, setPassword1] = useState(""); + const [password2, setPassword2] = useState(""); + const [error, setError] = useState(null); + + const auth = useFirebase(); + + const handleSubmit = (e) => { + e.preventDefault(); + auth.signInWithGoogle().then((res) => console.log(res.user)); + }; + + const isInvalid = + password1 !== password2 || + password1 === "" || + userName === "" || + email === ""; + + const styles = useStyles(); + + return ( +
+ + + + + + + {error &&

{error.message}

} +
+
+ ); +}; + +const InputField = ({ id, label, set, type = "text" }) => { + const handleChange = (e) => set(e.target.value); + + const styles = useStyles(); + return ( +
+ + +
+ ); +}; + +export const SignUpLink = () => ( +

+ Don't have an account yet? Sign Up +

+); diff --git a/client/src/services/auth/firebase.js b/client/src/services/auth/firebase.js index eb6be31..cc53f77 100644 --- a/client/src/services/auth/firebase.js +++ b/client/src/services/auth/firebase.js @@ -23,10 +23,7 @@ export default class Firebase { } provider = new app.auth.GoogleAuthProvider(); - signInWithGoogle = () => - this.auth - .signInWithPopup(this.provider) - .then((res) => console.log(res.user)); + signInWithGoogle = () => this.auth.signInWithPopup(this.provider); createUserWithEmailAndPassword = (email, password) => this.auth.createUserWithEmailAndPassword(email, password);