diff --git a/src/App.jsx b/src/App.jsx
index fdbfcc049..dd6f91030 100644
--- a/src/App.jsx
+++ b/src/App.jsx
@@ -16,7 +16,7 @@ import Loader from "./components/Loader";
import { FaArrowCircleUp } from "react-icons/fa";
import { useSnackbar } from "notistack";
import logo from "./assets/logo.png";
-import {Switch, Route, Link, useHistory, Redirect} from "react-router-dom";
+import {Switch, Route, useHistory} from "react-router-dom";
import LoginScreen from './pages/Login';
import SignupScreen from './pages/Signup';
import AnimatedButton from "./components/AnimatedButton";
@@ -94,8 +94,10 @@ function App() {
const unsubscribe = auth.onAuthStateChanged((authUser) => {
if (authUser) {
setUser(authUser);
+ history.push('/dummygram/');
} else {
setUser(null);
+ history.push('/dummygram/login');
}
});
@@ -356,7 +358,7 @@ function App() {
)}
:
-
+ <>>
}
diff --git a/src/pages/Login.jsx b/src/pages/Login.jsx
index 438b96bd3..b80fd4056 100644
--- a/src/pages/Login.jsx
+++ b/src/pages/Login.jsx
@@ -2,8 +2,9 @@ import React, {useState, useEffect} from 'react';
import { getModalStyle, useStyles } from '../App';
import { Input } from "@mui/material";
import AnimatedButton from "../components/AnimatedButton";
-import { auth } from "../lib/firebase";
+import { auth, googleProvider, facebookProvider } from "../lib/firebase";
import { useSnackbar } from "notistack";
+import { useHistory } from 'react-router-dom';
@@ -15,8 +16,6 @@ const LoginScreen = () => {
const [password, setPassword] = useState("");
const [user, setUser] = useState(null);
- // const [loggingIn, setLoggingIn] = useState(false);
-
const buttonStyle = {
background: "linear-gradient(40deg, #e107c1, #59afc7)",
borderRadius: "20px",
@@ -26,34 +25,17 @@ const LoginScreen = () => {
};
const { enqueueSnackbar } = useSnackbar();
-
-
- // useEffect(() => {
- // const unsubscribe = auth.onAuthStateChanged((authUser) => {
- // if (authUser) {
- // // user has logged in
- // setUser(authUser);
- // } else {
- // // user has logged out
- // setUser(null);
- // }
- // });
- // return () => {
- // // perform some cleanup actions
- // unsubscribe();
- // };
- // }, [user, username]);
+ const history = useHistory();
const signIn = (e) => {
e.preventDefault();
- // setLoggingIn(true);
auth
.signInWithEmailAndPassword(email, password)
.then(() => {
enqueueSnackbar("Login successful!", {
variant: "success",
});
- window.location.href = '/';
+ // history.push('/dummygram/');
})
.catch((error) =>
enqueueSnackbar(error.message, {
@@ -61,14 +43,12 @@ const LoginScreen = () => {
})
)
.finally(() => {
- // setLoggingIn(false);
});
};
const signInWithGoogle = (e) => {
e.preventDefault();
- setLoggingIn(true);
auth
.signInWithPopup(googleProvider)
.then(() => {
@@ -82,20 +62,17 @@ const LoginScreen = () => {
})
)
.finally(() => {
- setLoggingIn(false);
});
};
const signInWithFacebook = (e) => {
e.preventDefault();
- setLoggingIn(true);
auth
.signInWithPopup(facebookProvider)
.then(() => {
enqueueSnackbar("Login successful!", {
variant: "success",
});
- setOpenSignIn(false);
})
.catch((error) =>
enqueueSnackbar(error.message, {
@@ -103,12 +80,12 @@ const LoginScreen = () => {
})
)
.finally(() => {
- setLoggingIn(false);
});
};
return (
-
{
@@ -26,6 +28,9 @@ const SignupScreen = () => {
},
};
+ const { enqueueSnackbar } = useSnackbar();
+
+
const handleChange = (e) => {
if (e.target.files[0]) {
setImage(e.target.files[0]);