-
- CookBook Pro
-
-
);
};
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 (
-
-
Sign Up
-
-
-
- );
-};
-
-export default SignUp;
+import React, {useState, useEffect} from 'react';
+import {getAuth, createUserWithEmailAndPassword, updateProfile} from 'firebase/auth';
+import {getFirestore} from "firebase/firestore";
+import {collection, doc, getDoc, setDoc} from "firebase/firestore";
+import {firebaseApp} from '../firebase/firebaseConfig.js';
+import '../index.js'
+import './LoginSignUp.css';
+import './home.js'
+
+var SignUp=()=>{
+ const[userName, isUserName] = useState("");
+ const[userEmail, isUserEmail] = useState("");
+ const[userPassword, isUserPassword] = useState("");
+ const auth = getAuth();
+ const firebaseDB = getFirestore(firebaseApp);
+ useEffect(()=>{
+ document.title = 'CookBook-Pro: SignUp';
+ document.body.style.backgroundColor="#CFDEF3"
+ }, []);
+ const inputCredentials=async(e)=>{
+ e.preventDefault();
+ await createUserWithEmailAndPassword(auth, userEmail, userPassword)
+ .then (async (userCredential)=>{
+ const user = userCredential.user;
+ const isUID = user.uid;
+ const docSnap = await getDoc(doc(firebaseDB, "Users", isUID));
+ if(!docSnap.exists()){
+ await setDoc(doc(firebaseDB, "Users", isUID), {recipeID:[""]});
+ }
+ })
+ .catch((error)=>{
+ const errorCode = error.code;
+ const errorMessage = error.message;
+ console.log(errorCode, errorMessage);
+ });
+ await updateProfile(auth.currentUser, {displayName: document.getElementById("isName").value})
+ .then(()=>{
+ console.log(auth.currentUser);
+ document.location.href = "/";
+ })
+ .catch((error)=>{
+ const errorCode = error.code;
+ const errorMessage = error.message;
+ console.log(errorCode, errorMessage);
+ });
+ }
+
+ return(
+
+
Sign Up
+
+
+ )
+}
+
+export default SignUp;
\ No newline at end of file
diff --git a/src/pages/home.js b/src/pages/home.js
index d64e33f..6c18fb6 100644
--- a/src/pages/home.js
+++ b/src/pages/home.js
@@ -1,35 +1,19 @@
+import React, {useState, useEffect} from 'react';
+import {Offcanvas, OffcanvasHeader, OffcanvasBody, Button, Card, ListGroup, ListGroupItem, ListGroupItemHeading, ListGroupItemText, ListInlineItem } from 'reactstrap';
-import React, { useState } from 'react';
-
-import { Offcanvas, OffcanvasHeader, OffcanvasBody, Button, Card, ListGroup, ListGroupItem, ListGroupItemHeading, ListGroupItemText, ListInlineItem } from 'reactstrap';
-
-const Home = () => {
-
+const Home=()=>{
const [toggle, setToggle] = useState(false);
-
- function buttonPushed() {
+ function buttonPushed(){
setToggle(toggle => !toggle);
}
return (
Welcome to CookBook Pro
-
-
+
- buttonPushed()}>
- Offcanvas
-
-
-
- This is the Offcanvas body.
-
-
+ buttonPushed()}>Offcanvas
+ This is the Offcanvas body.
);