changed login type tab and made login route to home page without loading again once user logs in
This commit was merged in pull request #266.
This commit is contained in:
@@ -18,6 +18,8 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
|
||||
|
||||
const { jobListTable } = useSelector((state) => state.tableReload);
|
||||
|
||||
const { userDetails:{loggedIn} } = useSelector((state) => state?.userDetails); // CHECKS IF LOGGEDIN IS TRUE
|
||||
|
||||
useEffect(() => {
|
||||
//Removing Data stored at localStorage after session expires
|
||||
const expireSession = () => {
|
||||
@@ -68,7 +70,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
|
||||
}, [resetTime]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!isLogin.status) {
|
||||
if (!loggedIn) {
|
||||
const loadProfile = () => {
|
||||
// function to load user profile
|
||||
setIsLogin({ loading: true, status: false });
|
||||
@@ -80,7 +82,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
|
||||
return;
|
||||
}
|
||||
setLoadProfileDetails(res.data);
|
||||
dispatch(updateUserDetails(res.data));
|
||||
dispatch(updateUserDetails({...res.data, loggedIn:true}));
|
||||
setIsLogin({ loading: false, status: true });
|
||||
})
|
||||
.catch((error) => {
|
||||
@@ -134,13 +136,10 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
|
||||
});
|
||||
},[])
|
||||
|
||||
return isLogin.loading ? (
|
||||
return isLogin.loading && !loggedIn ? (
|
||||
<LoadingSpinner size="32" color="sky-blue" height="h-screen" />
|
||||
) : // Stills needs fixing
|
||||
// <div className="h-screen m-auto">
|
||||
// <img src={WrenchBoard} alt="wrenchboard" className="h-10" />
|
||||
// </div>
|
||||
!isLogin.status ? (
|
||||
) :
|
||||
!isLogin.status && !loggedIn ? (
|
||||
<Navigate to={redirectPath} replace />
|
||||
) : (
|
||||
children || <Outlet />
|
||||
|
||||
Reference in New Issue
Block a user