diff --git a/.env b/.env index 330d22f..245811c 100644 --- a/.env +++ b/.env @@ -18,6 +18,7 @@ REACT_APP_USERS_ENDPOINT="https://apigate.lotus.g1.wrenchboard.com/svs/user" #"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser" REACT_APP_SESSION_EXPIRE_MINUTES=300000 +REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY=600000 REACT_APP_SESSION_EXPIRE_CHECKER=60000 REACT_APP_LOGIN_ERROR_TIMEOUT=7000 diff --git a/.env.development b/.env.development index 288f294..95c0a38 100644 --- a/.env.development +++ b/.env.development @@ -18,6 +18,7 @@ REACT_APP_USERS_ENDPOINT="https://apigate.lotus.g1.wrenchboard.com/svs/user" #"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser" REACT_APP_SESSION_EXPIRE_MINUTES=300000 +REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY=600000 REACT_APP_SESSION_EXPIRE_CHECKER=60000 REACT_APP_LOGIN_ERROR_TIMEOUT=7000 diff --git a/.env.production b/.env.production index d5d045f..d30af61 100644 --- a/.env.production +++ b/.env.production @@ -18,6 +18,7 @@ REACT_APP_USERS_ENDPOINT="https://apigate.orion.g1.wrenchboard.com/svs/user" #"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser" REACT_APP_SESSION_EXPIRE_MINUTES=300000 +REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY=600000 REACT_APP_SESSION_EXPIRE_CHECKER=60000 REACT_APP_LOGIN_ERROR_TIMEOUT=7000 diff --git a/src/components/Partials/Header.jsx b/src/components/Partials/Header.jsx index 24b26c1..11a586b 100644 --- a/src/components/Partials/Header.jsx +++ b/src/components/Partials/Header.jsx @@ -100,7 +100,7 @@ export default function Header({ logoutModalHandler, sidebarHandler }) { // User Profile let { firstname, lastname, email, profile_pic } = userDetails; - let userEmail = email.split("@")[0]; + let userEmail = email?.split("@")[0]; return ( <> diff --git a/src/components/jobPopout/PendingJobsPopout.jsx b/src/components/jobPopout/PendingJobsPopout.jsx index 160437c..f42f444 100644 --- a/src/components/jobPopout/PendingJobsPopout.jsx +++ b/src/components/jobPopout/PendingJobsPopout.jsx @@ -229,4 +229,4 @@ function PendingJobsPopout({ details, onClose, situation }) { ); } -export default PendingJobsPopout; +export default PendingJobsPopout; \ No newline at end of file diff --git a/src/middleware/AuthRoute.jsx b/src/middleware/AuthRoute.jsx index 52bbb81..724f4c3 100644 --- a/src/middleware/AuthRoute.jsx +++ b/src/middleware/AuthRoute.jsx @@ -12,23 +12,37 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { const dispatch = useDispatch(); const [lastActivityTime, setLastActivityTime] = useState(Date.now()); const [isLogin, setIsLogin] = useState({ loading: true, status: false }); + const [loadProfileDetails, setLoadProfileDetails] = useState([]); const navigate = useNavigate(); - const {jobListTable} = useSelector((state) => state.tableReload) - + const { jobListTable } = useSelector((state) => state.tableReload); + useEffect(() => { //Removing Data stored at localStorage after session expires const expireSession = () => { - localStorage.clear(); + localStorage.removeItem("uid"); + localStorage.removeItem("member_id"); + localStorage.removeItem("session_token"); navigate("/login", { replace: true }); // redirects user to login page after session expires }; + console.log(loadProfileDetails); const checkInactivity = setInterval(() => { - if ( - Date.now() - lastActivityTime > - process.env.REACT_APP_SESSION_EXPIRE_MINUTES - ) { - expireSession(); + let { account_type } = loadProfileDetails; + if (account_type === "FAMILY") { + if ( + Date.now() - lastActivityTime > + process.env.REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY + ) { + expireSession(); + } + } else { + if ( + Date.now() - lastActivityTime > + process.env.REACT_APP_SESSION_EXPIRE_MINUTES + ) { + expireSession(); + } } }, process.env.REACT_APP_SESSION_EXPIRE_CHECKER); // Checks for inactivity every minute @@ -65,6 +79,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { setIsLogin({ loading: false, status: false }); return; } + setLoadProfileDetails(res.data); dispatch(updateUserDetails(res.data)); setIsLogin({ loading: false, status: true }); }) @@ -76,22 +91,22 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { } }, []); - useEffect(()=>{ + useEffect(() => { const getMyJobList = async () => { - dispatch(updateUserJobList({loading: true, data:[]})) + dispatch(updateUserJobList({ loading: true, data: [] })); try { const res = await apiCall.getMyJobList(); // setMyJobList({loading: false, data:res.data}) // setMyJobList(res.data); - dispatch(updateUserJobList({loading: false, data:res.data})) + dispatch(updateUserJobList({ loading: false, data: res.data })); } catch (error) { - dispatch(updateUserJobList({loading: false, data:[]})) + dispatch(updateUserJobList({ loading: false, data: [] })); // setMyJobList({loading: false, data:[]}) console.log("Error getting mode"); } }; - getMyJobList() - },[jobListTable]) + getMyJobList(); + }, [jobListTable]); useEffect(() => { // Getting market data