From 77cb7a7fa1c17632bf0eeef01df4f46993cdf8a2 Mon Sep 17 00:00:00 2001 From: Cain Watson <23223956+cainwatson@users.noreply.github.com> Date: Thu, 20 Apr 2023 19:07:01 -0500 Subject: [PATCH] Break out sign up into dedicated component --- src/App.jsx | 4 + .../SplashpageLayout/SplashpageLayout.jsx | 97 +---------------- .../Organizations/OrganizationNew.jsx | 1 + src/Components/SignUp/SignUp.css | 8 -- src/Components/SignUp/SignUp.jsx | 43 -------- src/Components/SignUp/SignUpForm.jsx | 102 ------------------ .../NavbarSplashpage/NavbarSplashpage.jsx | 24 ++--- .../SignUp/SignUpForm}/SignUpForm.css | 0 src/pages/SignUp/SignUpForm/SignUpForm.jsx | 89 +++++++++++++++ src/pages/SignUp/SignUpPage.css | 27 +++++ src/pages/SignUp/SignUpPage.jsx | 47 ++++++++ 11 files changed, 182 insertions(+), 260 deletions(-) delete mode 100644 src/Components/SignUp/SignUp.css delete mode 100644 src/Components/SignUp/SignUp.jsx delete mode 100644 src/Components/SignUp/SignUpForm.jsx rename src/{Components/SignUp => pages/SignUp/SignUpForm}/SignUpForm.css (100%) create mode 100644 src/pages/SignUp/SignUpForm/SignUpForm.jsx create mode 100644 src/pages/SignUp/SignUpPage.css create mode 100644 src/pages/SignUp/SignUpPage.jsx diff --git a/src/App.jsx b/src/App.jsx index abbd17fd..6de0fead 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -14,6 +14,7 @@ import TeamPage from "./pages/Team/TeamPage"; import TeamMemberPage from "./pages/TeamMember/TeamMemberPage"; import ContactPage from "./pages/Contact/ContactPage"; import FeaturesPage from "./pages/Features/FeaturesPage"; +import SignUpPage from "./pages/SignUp/SignUpPage"; export default function App() { return ( @@ -29,6 +30,9 @@ export default function App() { + + {/* */} + {/* */} ); - const [panelView, setPanelView] = useState(""); - const [scrollbarWidth, setScrollbarWidth] = useState(15); - - useEffect(() => { - const currentWidth = calculateScrollbarWidth(); - if (!panelView && currentWidth > 0) { - setScrollbarWidth(calculateScrollbarWidth()); - } - }, [panelView]); - - const calculateScrollbarWidth = () => - window.innerWidth - document.documentElement.offsetWidth; - - const handleCloseSplashPageModal = () => setShowSplashPageModal(false); - const handleSwitchSplashPageModal = (modalLabelInput) => { - setModalLabel(modalLabelInput); - if (modalLabelInput === "Sign Up") { - setModalContents( -
-
- -
-
- ); - setShowSplashPageModal(true); - } else if (modalLabelInput === "Log In") { - setModalContents( -
-
- -
-
- ); - } else if (modalLabelInput === "Forgot Password") { - setModalContents( -
-
- -
-
- ); - } - setShowSplashPageModal(true); - }; - return (
-
- +
+
-
+
Splashpage graphics - - {modalContents} -
diff --git a/src/Components/Organizations/OrganizationNew.jsx b/src/Components/Organizations/OrganizationNew.jsx index 90d4857b..b3d3324a 100644 --- a/src/Components/Organizations/OrganizationNew.jsx +++ b/src/Components/Organizations/OrganizationNew.jsx @@ -16,6 +16,7 @@ function OrganizationNew() { return (

Create Organization

+ {/* TODO: Add paragraph here! */}
); diff --git a/src/Components/SignUp/SignUp.css b/src/Components/SignUp/SignUp.css deleted file mode 100644 index f119ef60..00000000 --- a/src/Components/SignUp/SignUp.css +++ /dev/null @@ -1,8 +0,0 @@ -.signup { - display: flex; - width: 100%; -} - -.signup__header { - margin: 3rem 0; -} diff --git a/src/Components/SignUp/SignUp.jsx b/src/Components/SignUp/SignUp.jsx deleted file mode 100644 index 0a2e76cd..00000000 --- a/src/Components/SignUp/SignUp.jsx +++ /dev/null @@ -1,43 +0,0 @@ -import React from "react"; -import { useHistory } from "react-router-dom"; -import Container from "../design/Container/Container"; -import { createUser } from "../../Services/Auth/SignupService"; -import SignUpForm from "./SignUpForm"; -import "./SignUp.css"; - -export default function SignUp(props) { - const history = useHistory(); - - const handleCancel = (event) => { - event.preventDefault(); - props.onCancel(); - history.push(`/splashpage`); - }; - - const handleSubmit = (newUserFields) => { - createUser(newUserFields) - .then((createdUser) => { - alert("user created!"); - console.log(createdUser); - props.toggleModalContents("Log In"); - }) - .catch((error) => { - alert( - error.response.data.errors[0] || - "Something went wrong while creating this user. Please try again later." - ); - }); - }; - - return ( -
- - - -
- ); -} diff --git a/src/Components/SignUp/SignUpForm.jsx b/src/Components/SignUp/SignUpForm.jsx deleted file mode 100644 index 16121038..00000000 --- a/src/Components/SignUp/SignUpForm.jsx +++ /dev/null @@ -1,102 +0,0 @@ -import React, { useState } from "react"; -import Button from "../design/Button/Button"; -import TextBox from "../design/TextBox/TextBox"; -import "./SignUpForm.css"; - -export default function SignUpForm(props) { - const [newUserFields, setNewUserFields] = useState({}); - - const handleSubmit = (event) => { - event.preventDefault(); - setNewUserFields({ ...newUserFields, active: true }); - props.onSubmit(newUserFields); - }; - - return ( - <> -
- - setNewUserFields({ - ...newUserFields, - first_name: event.target.value, - }) - } - required - /> - - setNewUserFields({ - ...newUserFields, - last_name: event.target.value, - }) - } - required - /> - - setNewUserFields({ - ...newUserFields, - email: event.target.value, - }) - } - required - /> - - setNewUserFields({ ...newUserFields, password: event.target.value }) - } - required - /> - - setNewUserFields({ - ...newUserFields, - password_confirmation: event.target.value, - }) - } - required - /> -
-

- Already have an account? - -

- -
- - - ); -} diff --git a/src/Components/design/Navbar/NavbarSplashpage/NavbarSplashpage.jsx b/src/Components/design/Navbar/NavbarSplashpage/NavbarSplashpage.jsx index 56df3eeb..c2080107 100644 --- a/src/Components/design/Navbar/NavbarSplashpage/NavbarSplashpage.jsx +++ b/src/Components/design/Navbar/NavbarSplashpage/NavbarSplashpage.jsx @@ -59,13 +59,11 @@ export default function NavbarSplashpage(props) { alt="Custom button" className="navbar__image" /> - + + + Log In + +
Custom button - + +
diff --git a/src/Components/SignUp/SignUpForm.css b/src/pages/SignUp/SignUpForm/SignUpForm.css similarity index 100% rename from src/Components/SignUp/SignUpForm.css rename to src/pages/SignUp/SignUpForm/SignUpForm.css diff --git a/src/pages/SignUp/SignUpForm/SignUpForm.jsx b/src/pages/SignUp/SignUpForm/SignUpForm.jsx new file mode 100644 index 00000000..f8aa52a2 --- /dev/null +++ b/src/pages/SignUp/SignUpForm/SignUpForm.jsx @@ -0,0 +1,89 @@ +import React, { useState } from "react"; +import Button from "../../../Components/design/Button/Button"; +import TextBox from "../../../Components/design/TextBox/TextBox"; +import "./SignUpForm.css"; + +export default function SignUpForm(props) { + const [newUserFields, setNewUserFields] = useState({}); + + const handleSubmit = (event) => { + event.preventDefault(); + props.onSubmit(newUserFields); + }; + + return ( +
+ + setNewUserFields({ + ...newUserFields, + first_name: event.target.value, + }) + } + required + /> + + setNewUserFields({ + ...newUserFields, + last_name: event.target.value, + }) + } + required + /> + + setNewUserFields({ + ...newUserFields, + email: event.target.value, + }) + } + required + /> + + setNewUserFields({ ...newUserFields, password: event.target.value }) + } + required + /> + + setNewUserFields({ + ...newUserFields, + password_confirmation: event.target.value, + }) + } + required + /> +
+ +
+ + ); +} diff --git a/src/pages/SignUp/SignUpPage.css b/src/pages/SignUp/SignUpPage.css new file mode 100644 index 00000000..b9304d8d --- /dev/null +++ b/src/pages/SignUp/SignUpPage.css @@ -0,0 +1,27 @@ +.sign-up-page { + display: flex; + flex-direction: column; + min-height: 100vh; +} + +.sign-up-page__content { + flex: 1; + padding: 4rem; +} + +.sign-up-page__header { + margin-bottom: 2rem; + color: inherit; +} + +.sign-up-page__text { + margin-bottom: 2rem; +} + +.sign-up__login { + text-align: center; +} +.sign-up__login > a { + color: var(--body-text); + font-weight: var(--font-weight-bold); +} diff --git a/src/pages/SignUp/SignUpPage.jsx b/src/pages/SignUp/SignUpPage.jsx new file mode 100644 index 00000000..604f61a1 --- /dev/null +++ b/src/pages/SignUp/SignUpPage.jsx @@ -0,0 +1,47 @@ +import React, { useContext } from "react"; +import { useHistory, Link } from "react-router-dom"; +import Footer from "../../Components/design/Footer/Footer"; +import NavbarSplashpage from "../../Components/design/Navbar/NavbarSplashpage/NavbarSplashpage"; +import SignUpForm from "./SignUpForm/SignUpForm"; +import { createUser } from "../../Services/Auth/SignupService"; +import "./SignUpPage.css"; +import { useCurrentUser } from "../../Contexts/currentUserContext"; + +export default function SignUpPage() { + const history = useHistory(); + const { login } = useCurrentUser(); + + // TODO: maybe use react-query here + const handleSubmit = (newUserFields) => { + createUser(newUserFields) + .then(() => login(newUserFields.email, newUserFields.password)) + .then(() => history.push(`/organizations`)) + .catch((error) => { + alert( + error.response.data.errors[0] || + "Something went wrong while creating this user. Please try again later." + ); + }); + }; + + return ( +
+ +
+
+

Sign Up

+

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do + eiusmod tempor incididunt ut labore et dolore magna aliqua. Arcu + odio ut sem nulla pharetra diam sit amet. +

+
+ +

+ Already have an account? Log In +

+
+
+ ); +}