diff --git a/src/App.jsx b/src/App.jsx index 5effdbaec..8ccfd1076 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,21 +1,14 @@ -import { - Box, - Button, - ClickAwayListener, - Divider, - Modal, - Typography, -} from "@mui/material"; -import { FaArrowCircleUp, FaUserCircle } from "react-icons/fa"; import React, { useEffect, useState } from "react"; import { Route, Routes, useNavigate } from "react-router-dom"; import { auth, db } from "./lib/firebase"; -import { AiOutlineInsertRowAbove } from "react-icons/ai"; import AnimatedButton from "./components/AnimatedButton"; +import { FaArrowCircleUp } from "react-icons/fa"; import Favorite from "./components/Favorite"; import Loader from "./components/Loader"; import LoginScreen from "./pages/Login"; +import Modal from "@mui/material/Modal"; +import Navbar from "./components/Navbar"; import NotFoundPage from "./components/NotFound"; import Post from "./components/Post"; import PostView from "./pages/PostView"; @@ -23,7 +16,6 @@ import Profile from "./pages/Profile"; import ShareModal from "./components/ShareModal"; import SideBar from "./components/SideBar"; import SignupScreen from "./pages/Signup"; -import logo from "./assets/logo.png"; import { makeStyles } from "@mui/styles"; import { useSnackbar } from "notistack"; @@ -194,142 +186,15 @@ function App() { return (
-
- dummygram { - if ( - location.pathname !== "/dummygram/login" && - location.pathname !== "/dummygram/signup" - ) { - navigate("/dummygram/"); - } - window.scrollTo({ top: 0, left: 0, behavior: "smooth" }); - }} - style={{ - cursor: "pointer", - }} - /> - - {user ? ( - <> -
-
{ - setRowMode(!rowMode); - }} - > - -
- setOpen(false)}> - - -
- - ) : ( -
- - - -
- )} -
+ { + const unsubscribe = auth.onAuthStateChanged((authUser) => { + if (authUser) { + setUser(authUser); + navigate("/dummygram/"); + } else { + setUser(null); + navigate("/dummygram/login"); + } + }); + + return () => { + unsubscribe(); + }; + }, [user]); + + return ( +
+ dummygram { + if ( + location.pathname !== "/dummygram/login" && + location.pathname !== "/dummygram/signup" + ) { + navigate("/dummygram/"); + } + window.scrollTo({ top: 0, left: 0, behavior: "smooth" }); + }} + style={{ + cursor: "pointer", + }} + /> + + {user && ( + <> +
+
{ + setRow(!row); + }} + > + +
+ setOpen(false)}> + + +
+ + )} +
+ ); +} + +export default Navbar; diff --git a/src/components/ShareModal.jsx b/src/components/ShareModal.jsx index 42157d139..c0e5b6ae1 100644 --- a/src/components/ShareModal.jsx +++ b/src/components/ShareModal.jsx @@ -1,6 +1,6 @@ import { Dialog, IconButton, Input } from "@mui/material"; -import React, { useState } from "react"; +import React from "react"; import logo from "../assets/logo.png"; import { useSnackbar } from "notistack"; diff --git a/src/pages/Login/index.jsx b/src/pages/Login/index.jsx index fdbd72ab9..9e7749f77 100644 --- a/src/pages/Login/index.jsx +++ b/src/pages/Login/index.jsx @@ -55,7 +55,7 @@ const LoginScreen = () => { variant: "error", }); } else { - enqueueSnackbar("Error Occured!", { + enqueueSnackbar(error.message, { variant: "error", }); } @@ -81,7 +81,7 @@ const LoginScreen = () => { variant: "error", }); } else { - enqueueSnackbar("An error occcured!", { + enqueueSnackbar(error.message, { variant: "error", }); } @@ -104,7 +104,7 @@ const LoginScreen = () => { variant: "error", }); } else { - enqueueSnackbar("An error occcured!", { + enqueueSnackbar(error.message, { variant: "error", }); } @@ -153,7 +153,6 @@ const LoginScreen = () => { backgroundColor: "white", boxShadow: "0 0 20px rgba(104, 85, 224, 0.2)", borderRadius: "4px", - // padding: "10px", }} > {