From acf53d23a61bac525cc989b4b84240fe7fb5f7c6 Mon Sep 17 00:00:00 2001 From: defining-art <118932320+defining-art@users.noreply.github.com> Date: Tue, 21 Nov 2023 13:25:40 -0500 Subject: [PATCH 1/2] Store UID --- src/pages/Login.js | 126 ++++++++++++-------------------- src/pages/LoginSignUp.css | 112 ++++++++++++++-------------- src/pages/SignUp.js | 149 ++++++++++++++++---------------------- src/pages/home.js | 30 ++------ 4 files changed, 170 insertions(+), 247 deletions(-) diff --git a/src/pages/Login.js b/src/pages/Login.js index fc251e7..d70a796 100644 --- a/src/pages/Login.js +++ b/src/pages/Login.js @@ -1,80 +1,46 @@ -import React, { useState, useEffect } from "react"; -import { useNavigate } from "react-router-dom"; -import { getAuth, signInWithEmailAndPassword } from "firebase/auth"; -import "../index.js"; -import "./LoginSignUp.css"; -import "../firebase/firebaseConfig.js"; -import "./home.js"; -import "./SignUp.js"; - -var Login = () => { - const [userEmail, isUserEmail] = useState(""); - const [userPassword, isUserPassword] = useState(""); - const auth = getAuth(); - const navigate = useNavigate(); - useEffect(() => { - document.title = "CookBook-Pro: Login"; - document.body.style.backgroundColor = "#E0EAFC"; - }, []); - const checkInput = (e) => { - e.preventDefault(); - signInWithEmailAndPassword(auth, userEmail, userPassword) - .then((userCredential) => { - const user = userCredential.user; - document.location.href = "/"; - }) - .catch((error) => { - const errorCode = error.code; - const errorMessage = error.message; - console.log(errorCode, errorMessage); - }); - }; - - return ( -
- ); -}; -export default Login; +import React, {useState, useEffect} from 'react' +import {getAuth, signInWithEmailAndPassword} from 'firebase/auth'; +import '../index.js' +import './LoginSignUp.css'; +import '../firebase/firebaseConfig.js'; +import './home.js' +import './SignUp.js' + +var Login=()=>{ + const[userEmail, isUserEmail] = useState(""); + const[userPassword, isUserPassword] = useState(""); + const auth = getAuth(); + useEffect(()=>{ + document.title = 'CookBook-Pro: Login'; + document.body.style.backgroundColor="#E0EAFC"; + }, []); + const checkInput=async(e)=>{ + e.preventDefault(); + await signInWithEmailAndPassword(auth, userEmail, userPassword) + .then((userCredential)=>{ + const user = userCredential.user; + document.location.href = "/"; + }) + .catch((error)=>{ + const errorCode = error.code; + const errorMessage = error.message; + console.log(errorCode,errorMessage); + }); + } + + return( + + ) +} +export default Login; \ No newline at end of file diff --git a/src/pages/LoginSignUp.css b/src/pages/LoginSignUp.css index e863b8d..d3abcd5 100644 --- a/src/pages/LoginSignUp.css +++ b/src/pages/LoginSignUp.css @@ -1,59 +1,53 @@ -.LogIn, -.SignUp { - width: 350px; - height: 350px; - border: 2px lightgrey; - border-style: solid; - border-radius: 15px; - margin: auto; - margin-top: 150px; - overflow-wrap: anywhere; - background: white; -} - -.Title { - text-align: center; -} - -.FullName, -.Email, -.Password { - padding-left: 12px; -} - -.getFullName, -.getEmail, -.getPassword { - margin-left: 14px; - height: 25px; - width: 300px; - border-radius: 15px; - padding-left: 8px; -} - -.InvalidInput { - margin-left: 14px; - color: blue; -} - -.InvalidInput:hover { - cursor: pointer; -} - -.isSubmission, -.isValidate { - height: 35px; - width: 300px; - margin-left: 20px; - font-size: 14pt; - color: white; - background-color: darkgray; - border-radius: 12px; - border-style: none; -} - -.isValidate:hover { - background-color: lightgray; - box-shadow: 2px 5px 4px rgba(0, 0, 0, 0.5); - cursor: pointer; -} +.LogIn, .SignUp{ + width: 350px; + height: 350px; + border: 2px lightgrey; + border-style:solid; + border-radius: 15px; + margin:auto; + margin-top: 150px; + overflow-wrap: anywhere; + background: white; +} + +.Title{ + text-align: center; +} + +.FullName, .Email, .Password{ + padding-left: 12px; +} + +.getFullName, .getEmail, .getPassword{ + margin-left: 14px; + height: 25px; + width: 300px; + border-radius: 15px; + padding-left: 8px; +} + +.InvalidInput{ + margin-left: 14px; + color: blue; +} + +.InvalidInput:hover{ + cursor:pointer; +} + +.isSubmission, .isValidate{ + height: 35px; + width: 300px; + margin-left: 20px; + font-size: 14pt; + color: white; + background-color: darkgray; + border-radius: 12px; + border-style: none; +} + +.isValidate:hover{ + background-color: lightgray; + box-shadow: 2px 5px 4px rgba(0, 0, 0, 0.5); + cursor: pointer; +} \ No newline at end of file diff --git a/src/pages/SignUp.js b/src/pages/SignUp.js index 8c98af5..db1dc64 100644 --- a/src/pages/SignUp.js +++ b/src/pages/SignUp.js @@ -1,85 +1,64 @@ -import React, { useState, useEffect } from "react"; -import { getAuth, createUserWithEmailAndPassword } from "firebase/auth"; -import "../index.js"; -import "./LoginSignUp.css"; -import "../firebase/firebaseConfig.js"; -import "./home.js"; - -var SignUp = () => { - const [userName, isUserName] = useState(""); - const [userEmail, isUserEmail] = useState(""); - const [userPassword, isUserPassword] = useState(""); - const auth = getAuth(); - useEffect(() => { - document.title = "CookBook-Pro: SignUp"; - document.body.style.backgroundColor = "#CFDEF3"; - }, []); - const inputCredentials = async (e) => { - e.preventDefault(); - await createUserWithEmailAndPassword(auth, userEmail, userPassword) - .then((userCredential) => { - const user = userCredential.user; - document.location.href = "/"; - }) - .catch((error) => { - const errorCode = error.code; - const errorMessage = error.message; - console.log(errorCode, errorMessage); - }); - }; - - return ( -