diff --git a/src/App.jsx b/src/App.jsx index dd6f91030..c64bd7300 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -1,28 +1,18 @@ import React, { useState, useEffect } from "react"; import Post from "./components/Post"; -import { - db, - auth, -} from "./lib/firebase"; -import { - Button, - Dialog, - Modal, - DialogContent, -} from "@mui/material"; +import { db, auth } from "./lib/firebase"; +import { Button, Dialog, Modal, DialogContent } from "@mui/material"; import { makeStyles } from "@mui/styles"; import ImgUpload from "./components/ImgUpload"; import Loader from "./components/Loader"; import { FaArrowCircleUp } from "react-icons/fa"; import { useSnackbar } from "notistack"; import logo from "./assets/logo.png"; -import {Switch, Route, useHistory} from "react-router-dom"; -import LoginScreen from './pages/Login'; -import SignupScreen from './pages/Signup'; +import { Switch, Route, useHistory } from "react-router-dom"; +import LoginScreen from "./pages/Login"; +import SignupScreen from "./pages/Signup"; import AnimatedButton from "./components/AnimatedButton"; - - export function getModalStyle() { const top = 50; const left = 50; @@ -64,7 +54,7 @@ function App() { const [loadMorePosts, setLoadMorePosts] = useState(false); const [openNewUpload, setOpenNewUpload] = useState(false); const [logout, setLogout] = useState(false); - + const buttonStyle = { background: "linear-gradient(40deg, #e107c1, #59afc7)", borderRadius: "20px", @@ -92,14 +82,13 @@ function App() { useEffect(() => { const unsubscribe = auth.onAuthStateChanged((authUser) => { - if (authUser) { + if (authUser) { setUser(authUser); - history.push('/dummygram/'); + history.push("/dummygram/"); } else { setUser(null); - history.push('/dummygram/login'); + history.push("/dummygram/login"); } - }); return () => { @@ -107,7 +96,7 @@ function App() { }; }, [user]); - useEffect(() => { + useEffect(() => { if (document.body.classList.contains("darkmode--activated")) { window.document.body.style.setProperty("--bg-color", "black"); window.document.body.style.setProperty("--color", "white"); @@ -167,7 +156,6 @@ function App() { setLoadMorePosts(false); }, [loadMorePosts]); - const signOut = () => { auth.signOut().finally(); enqueueSnackbar("Logged out Successfully !", { @@ -177,7 +165,6 @@ function App() { return (
-
- setOpenNewUpload(false)} - > -
- instagram -

- New Post -

+ setOpenNewUpload(false)} + > +
+ instagram +

+ New Post +

+ + + {!loadingPosts && + (user ? ( + setOpenNewUpload(false)} + /> + ) : ( +

Sorry you need to login to upload posts

+ ))} +
+
+
+ setLogout(false)}> +
+
+ dummygram + +

+ Are you sure you want to Logout? +

- + Logout + + +
+
+ + + + {user ? ( +
+
- {!loadingPosts && - (user ? ( - setOpenNewUpload(false)} - /> - ) : ( -

Sorry you need to login to upload posts

- ))} - -
-
- setLogout(false)}> -
-
- dummygram - -

- Are you sure you want to Logout? -

- - - Logout - -
-
-
- - - - - {user ?
-
- {loadingPosts ? ( - - ) : ( -
- {posts.map(({ id, post }) => ( - - ))} -
- )} -
-
: - <> - } -
- - - - - - - - - - -

Page not found: 404

-
- -
- + {loadingPosts ? ( + + ) : ( +
+ {posts.map(({ id, post }) => ( + + ))} +
+ )} +
+ + ) : ( + <> + )} + + + + + + + + + + + +

+ Page not found: 404 +

+
+ - ); } diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx index b80fd4056..5cecacb18 100644 --- a/src/pages/Login.jsx +++ b/src/pages/Login.jsx @@ -1,12 +1,10 @@ -import React, {useState, useEffect} from 'react'; -import { getModalStyle, useStyles } from '../App'; +import React, { useState, useEffect } from "react"; +import { getModalStyle, useStyles } from "../App"; import { Input } from "@mui/material"; import AnimatedButton from "../components/AnimatedButton"; import { auth, googleProvider, facebookProvider } from "../lib/firebase"; import { useSnackbar } from "notistack"; -import { useHistory } from 'react-router-dom'; - - +import { useHistory } from "react-router-dom"; const LoginScreen = () => { const classes = useStyles(); @@ -15,7 +13,7 @@ const LoginScreen = () => { const [username, setUsername] = useState(""); const [password, setPassword] = useState(""); const [user, setUser] = useState(null); - + const buttonStyle = { background: "linear-gradient(40deg, #e107c1, #59afc7)", borderRadius: "20px", @@ -42,11 +40,9 @@ const LoginScreen = () => { variant: "error", }) ) - .finally(() => { - }); + .finally(() => {}); }; - const signInWithGoogle = (e) => { e.preventDefault(); auth @@ -61,8 +57,7 @@ const LoginScreen = () => { variant: "error", }) ) - .finally(() => { - }); + .finally(() => {}); }; const signInWithFacebook = (e) => { @@ -79,75 +74,74 @@ const LoginScreen = () => { variant: "error", }) ) - .finally(() => { - }); + .finally(() => {}); }; - return ( -
-
-
- dummygram - setEmail(e.target.value)} - /> - setPassword(e.target.value)} - /> - - Sign In - - - Sign In With Google - - - Sign In With Facebook - -
-
-
- ); -} + return ( +
+
+
+ dummygram + setEmail(e.target.value)} + /> + setPassword(e.target.value)} + /> + + Sign In + + + Sign In With Google + + + Sign In With Facebook + +
+
+
+ ); +}; -export default LoginScreen; \ No newline at end of file +export default LoginScreen; diff --git a/src/pages/Signup.jsx b/src/pages/Signup.jsx index 91924fdcc..b897d4322 100644 --- a/src/pages/Signup.jsx +++ b/src/pages/Signup.jsx @@ -1,12 +1,15 @@ -import React, {useState, useEffect} from 'react'; -import { getModalStyle, useStyles } from '../App'; +import React, { useState, useEffect } from "react"; +import { getModalStyle, useStyles } from "../App"; import { Input } from "@mui/material"; import AnimatedButton from "../components/AnimatedButton"; -import {auth, storage, googleProvider, facebookProvider } from "../lib/firebase"; +import { + auth, + storage, + googleProvider, + facebookProvider, +} from "../lib/firebase"; import { useSnackbar } from "notistack"; - - const SignupScreen = () => { const classes = useStyles(); @@ -16,27 +19,25 @@ const SignupScreen = () => { const [password, setPassword] = useState(""); const [signingUp, setSigningUp] = useState(false); - const [image, setImage] = useState(null); const [address, setAddress] = useState(null); - - const buttonStyle = { - background: "linear-gradient(40deg, #e107c1, #59afc7)", - borderRadius: "20px", - ":hover": { - background: "linear-gradient(-40deg, #59afc7, #e107c1)", - }, - }; - const { enqueueSnackbar } = useSnackbar(); + const buttonStyle = { + background: "linear-gradient(40deg, #e107c1, #59afc7)", + borderRadius: "20px", + ":hover": { + background: "linear-gradient(-40deg, #59afc7, #e107c1)", + }, + }; + const { enqueueSnackbar } = useSnackbar(); - const handleChange = (e) => { - if (e.target.files[0]) { - setImage(e.target.files[0]); - setAddress(e.target.value); - } - }; + const handleChange = (e) => { + if (e.target.files[0]) { + setImage(e.target.files[0]); + setAddress(e.target.value); + } + }; const signUp = (e) => { e.preventDefault(); @@ -75,7 +76,7 @@ const SignupScreen = () => { }); } ); - window.location.href = '/dummygram/'; + window.location.href = "/dummygram/"; }) // .then(() => { @@ -90,96 +91,97 @@ const SignupScreen = () => { }); }; - return ( -
+
+
+ instagram +
+ {address ? ( + profile pic -
- - instagram -
- {address ? ( - profile pic - ) : ( -
PROFILE PICTURE
- )} -
- setUsername(e.target.value)} - /> - setEmail(e.target.value)} - /> - setPassword(e.target.value)} - /> -
- - -
- - Sign Up - - -
-
- ); -} + /> + ) : ( +
PROFILE PICTURE
+ )} +
+ setUsername(e.target.value)} + /> + setEmail(e.target.value)} + /> + setPassword(e.target.value)} + /> +
+ + +
+ + Sign Up + + +
+ + ); +}; -export default SignupScreen; \ No newline at end of file +export default SignupScreen;