diff --git a/.env b/.env index 5e1b33c..426eb40 100644 --- a/.env +++ b/.env @@ -17,7 +17,8 @@ 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=5 +REACT_APP_SESSION_EXPIRE_MINUTES=300000 +REACT_APP_SESSION_EXPIRE_CHECKER=60000 REACT_APP_LOGIN_ERROR_TIMEOUT=7000 diff --git a/src/components/AuthPages/SignUp/index.jsx b/src/components/AuthPages/SignUp/index.jsx index f902d38..3cd6a12 100644 --- a/src/components/AuthPages/SignUp/index.jsx +++ b/src/components/AuthPages/SignUp/index.jsx @@ -113,7 +113,7 @@ export default function SignUp() { return ( <>
-
+
@@ -122,7 +122,7 @@ export default function SignUp() { wrenchboard
-
+

-
- {datas.isActive && ( - - Active - - )} -
+ + {/*
*/} + {/* {datas.isActive && (*/} + {/* */} + {/* Active*/} + {/**/} + {/* )}*/} + {/*
*/} -
- -
+ {/*
*/} + {/* */} + {/* */} + {/* */} + {/*
*/}
diff --git a/src/components/Cards/AvailableJobsCard.jsx b/src/components/Cards/AvailableJobsCard.jsx new file mode 100644 index 0000000..0eb70d9 --- /dev/null +++ b/src/components/Cards/AvailableJobsCard.jsx @@ -0,0 +1,127 @@ +import React, { useState } from "react"; +import { Link } from "react-router-dom"; +import { toast } from "react-toastify"; +import localImgLoad from "../../lib/localImgLoad"; +import Icons from "../Helpers/Icons"; + +export default function AvailableJobsCard({ + className, + datas, + hidden = false, + }) { + //debugger; + const [addFavorite, setValue] = useState(datas.whishlisted); + const [options, setOption] = useState(false); + const favoriteHandler = () => { + if (!addFavorite) { + setValue(true); + toast.success("Added to Favorite List"); + } else { + setValue(false); + toast.warn("Remove to Favorite List"); + } + }; + return ( +
+
+ +

+ {datas.title} +

+ + +
+
+
+

Added

+

+ {datas.offer_added} +

+
+
+
+
+
+

+ Expires +

+

+ {datas.expire} +

+
+
+
+
+
+
+ {datas.description} +
+ + + + + +
+ +
+
+
+ + {/*
*/} + {/* {datas.isActive && (*/} + {/* */} + {/* Active*/} + {/**/} + {/* )}*/} + {/*
*/} + + + {/*
*/} + {/* */} + {/* */} + {/* */} + {/*
*/} +
+ +
+
+
+

+ {datas.price*0.01}{datas.currency} | {datas.timeline_days} day(s) +

+

+ ( {datas.offer_code}) +

+
+
+
+ +
+
+
+
+
+ ); +} diff --git a/src/components/MarketPlace/MainSection.jsx b/src/components/MarketPlace/MainSection.jsx index 063695a..fec95a8 100644 --- a/src/components/MarketPlace/MainSection.jsx +++ b/src/components/MarketPlace/MainSection.jsx @@ -1,8 +1,9 @@ import React, { useEffect, useState } from "react"; //import ProductCardStyleTwo from "../Cards/ProductCardStyleTwo"; import DataIteration from "../Helpers/DataIteration"; -import SearchCom from "../Helpers/SearchCom"; -import ActiveJobsCard from "../Cards/ActiveJobsCard"; +// import SearchCom from "../Helpers/SearchCom"; +// import ActiveJobsCard from "../Cards/ActiveJobsCard"; +import AvailableJobsCard from "../Cards/AvailableJobsCard"; export default function MainSection({ className, marketPlaceProduct }) { const [tab, setTab] = useState("explore"); @@ -98,7 +99,7 @@ export default function MainSection({ className, marketPlaceProduct }) { endLength={products?.length} > {({ datas }) => ( - + )}
diff --git a/src/middleware/AuthRoute.jsx b/src/middleware/AuthRoute.jsx index 9f557fc..f7b4b9c 100644 --- a/src/middleware/AuthRoute.jsx +++ b/src/middleware/AuthRoute.jsx @@ -1,7 +1,55 @@ -import { Navigate, Outlet } from "react-router-dom"; +import { useEffect, useState } from "react"; +import { Navigate, Outlet, useLocation, useNavigate } from "react-router-dom"; const AuthRoute = ({ redirectPath = "/login", children }) => { + const [lastActivityTime, setLastActivityTime] = useState(Date.now()); const isLogin = localStorage.getItem("email"); + + const navigate = useNavigate(); + const { pathname } = useLocation(); + + + //Removing Data stored at localStorage after session expires + const expireSession = () => { + localStorage.removeItem("email"); + localStorage.removeItem('session_token'); + localStorage.removeItem('firstname'); + localStorage.removeItem('member_id'); + localStorage.removeItem('lastname'); + localStorage.removeItem('state'); + localStorage.removeItem('last_login'); + localStorage.removeItem('uid'); + localStorage.removeItem('session'); + localStorage.removeItem('city'); + localStorage.removeItem('country'); + localStorage.removeItem('loglevel'); + localStorage.removeItem('zip_code'); + localStorage.removeItem('added'); + navigate("/login", { replace: true }); // redirects user to login page after session expires + }; + + const checkInactivity = setInterval(() => { + if (Date.now() - lastActivityTime > process.env.REACT_APP_SESSION_EXPIRE_MINUTES) { + expireSession() + } + }, process.env.REACT_APP_SESSION_EXPIRE_CHECKER) // Checks for inactivity every minute + + // Reset last activity time on user input + const resetTime = () => { + setLastActivityTime(Date.now()); + } + window.addEventListener('mousemove', resetTime) + window.addEventListener('keydown', resetTime) + + useEffect(() => { + // cleaning up listeners + return () => { + clearInterval(checkInactivity) + window.removeEventListener('mousemove', resetTime) + window.removeEventListener('keydown', resetTime) + } + }, [pathname, lastActivityTime]) + if (!isLogin) { return ; }