From 19fb5256cf0044cb4970d836cbe9101fcf847ca1 Mon Sep 17 00:00:00 2001 From: QkoSad Date: Wed, 30 Nov 2022 16:58:41 +0200 Subject: [PATCH] added toastify to signin and signup --- package-lock.json | 34 ++++++++++++++++++++++++++++++++++ package.json | 1 + src/App.js | 37 ++++++++++++++++++++----------------- src/pages/Profile.jsx | 18 +++++++++++------- src/pages/Signin.jsx | 5 +++-- src/pages/Signup.jsx | 4 +++- 6 files changed, 72 insertions(+), 27 deletions(-) diff --git a/package-lock.json b/package-lock.json index cfe3138..fb3ac7f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,6 +16,7 @@ "react-dom": "^18.2.0", "react-router-dom": "^6.4.3", "react-scripts": "5.0.1", + "react-toastify": "^9.1.1", "web-vitals": "^2.1.4" } }, @@ -6299,6 +6300,14 @@ "wrap-ansi": "^7.0.0" } }, + "node_modules/clsx": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", + "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==", + "engines": { + "node": ">=6" + } + }, "node_modules/co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -15081,6 +15090,18 @@ } } }, + "node_modules/react-toastify": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.1.1.tgz", + "integrity": "sha512-pkFCla1z3ve045qvjEmn2xOJOy4ZciwRXm1oMPULVkELi5aJdHCN/FHnuqXq8IwGDLB7PPk2/J6uP9D8ejuiRw==", + "dependencies": { + "clsx": "^1.1.1" + }, + "peerDependencies": { + "react": ">=16", + "react-dom": ">=16" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", @@ -22425,6 +22446,11 @@ "wrap-ansi": "^7.0.0" } }, + "clsx": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/clsx/-/clsx-1.2.1.tgz", + "integrity": "sha512-EcR6r5a8bj6pu3ycsa/E/cKVGuTgZJZdsyUYHOksG/UHIiKfjxzRxYJpyVBwYaQeOvghal9fcc4PidlgzugAQg==" + }, "co": { "version": "4.6.0", "resolved": "https://registry.npmjs.org/co/-/co-4.6.0.tgz", @@ -28627,6 +28653,14 @@ "workbox-webpack-plugin": "^6.4.1" } }, + "react-toastify": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/react-toastify/-/react-toastify-9.1.1.tgz", + "integrity": "sha512-pkFCla1z3ve045qvjEmn2xOJOy4ZciwRXm1oMPULVkELi5aJdHCN/FHnuqXq8IwGDLB7PPk2/J6uP9D8ejuiRw==", + "requires": { + "clsx": "^1.1.1" + } + }, "read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", diff --git a/package.json b/package.json index d767d7d..8007acc 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "react-dom": "^18.2.0", "react-router-dom": "^6.4.3", "react-scripts": "5.0.1", + "react-toastify": "^9.1.1", "web-vitals": "^2.1.4" }, "scripts": { diff --git a/src/App.js b/src/App.js index c0a70aa..17f63ee 100644 --- a/src/App.js +++ b/src/App.js @@ -1,26 +1,29 @@ -import Navbar from './components/Navbar' -import {BrowserRouter as Router,Routes, Route} from 'react-router-dom' -import Explore from './pages/Explore' -import Profile from './pages/Profile' -import ForgotPassword from './pages/ForgotPassword' -import Offers from './pages/Offers' -import Signin from './pages/Signin' -import Signup from './pages/Signup' +import { BrowserRouter as Router, Routes, Route } from "react-router-dom"; +import { ToastContainer } from "react-toastify"; +import "react-toastify/dist/ReactToastify.css"; +import Navbar from "./components/Navbar"; +import Explore from "./pages/Explore"; +import Profile from "./pages/Profile"; +import ForgotPassword from "./pages/ForgotPassword"; +import Offers from "./pages/Offers"; +import Signin from "./pages/Signin"; +import Signup from "./pages/Signup"; function App() { return ( <> - }/> - }/> - }/> - }/> - }/> - }/> - - - + } /> + } /> + } /> + } /> + } /> + } /> + + + + ); } diff --git a/src/pages/Profile.jsx b/src/pages/Profile.jsx index 0216ce9..79c559c 100644 --- a/src/pages/Profile.jsx +++ b/src/pages/Profile.jsx @@ -1,9 +1,13 @@ +import { useEffect, useState } from "react"; +import { getAuth } from "firebase/auth"; -function Profile (){ - return ( - <> -

My app

- - ); +function Profile() { + const [user, setUser] = useState(); + const auth = getAuth(); + useEffect(() => { + setUser(auth.currentUser); + }, []); + + return user ?

{user.displayName}

: "Not Logged In"; } -export default Profile +export default Profile; diff --git a/src/pages/Signin.jsx b/src/pages/Signin.jsx index 5f2cb34..cb0398c 100644 --- a/src/pages/Signin.jsx +++ b/src/pages/Signin.jsx @@ -1,8 +1,9 @@ import { useState } from "react"; import { Link, useNavigate } from "react-router-dom"; +import { toast } from "react-toastify"; +import { getAuth, signInWithEmailAndPassword } from "firebase/auth"; import { ReactComponent as ArrowRightIcon } from "../assets/svg/keyboardArrowRightIcon.svg"; import visibilityIcon from "../assets/svg/visibilityIcon.svg"; -import { getAuth, signInWithEmailAndPassword } from "firebase/auth"; function Signin() { const [showPassword, setShowPassword] = useState(false); @@ -29,7 +30,7 @@ function Signin() { navigate("/"); } } catch (error) { - console.log(error); + toast.error("Bad user credentials") } }; return ( diff --git a/src/pages/Signup.jsx b/src/pages/Signup.jsx index 9ba5c2f..fa9993c 100644 --- a/src/pages/Signup.jsx +++ b/src/pages/Signup.jsx @@ -1,3 +1,5 @@ + import 'react-toastify/dist/ReactToastify.css'; +import { toast } from 'react-toastify'; import { useState } from "react"; import { Link, useNavigate } from "react-router-dom"; import { ReactComponent as ArrowRightIcon } from "../assets/svg/keyboardArrowRightIcon.svg"; @@ -47,7 +49,7 @@ function Signup() { navigate("/"); } catch (error) { - console.log(error); + toast.error("something went wron with the registration") } }; return (