moved user joblist into it's own slice, to avoid unneccessary side menu display recalculation

This commit was merged in pull request #121.
This commit is contained in:
victorAnumudu
2023-05-30 07:29:57 +01:00
parent 577212eb19
commit b2bfa6cd54
7 changed files with 89 additions and 46 deletions
+20
View File
@@ -5,6 +5,7 @@ import LoadingSpinner from "../components/Spinners/LoadingSpinner";
import { useDispatch, useSelector } from "react-redux";
import { updateUserDetails } from "../store/UserDetails";
import { updateJobs } from "../store/jobLists";
import { updateUserJobList } from "../store/userJobList";
const AuthRoute = ({ redirectPath = "/login", children }) => {
const apiCall = useMemo(() => new usersService(), []);
@@ -12,6 +13,8 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
const [lastActivityTime, setLastActivityTime] = useState(Date.now());
const [isLogin, setIsLogin] = useState({ loading: true, status: false });
const navigate = useNavigate();
const {jobListTable} = useSelector((state) => state.tableReload)
useEffect(() => {
//Removing Data stored at localStorage after session expires
@@ -73,6 +76,23 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
}
}, []);
useEffect(()=>{
const getMyJobList = async () => {
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}))
} catch (error) {
dispatch(updateUserJobList({loading: false, data:[]}))
// setMyJobList({loading: false, data:[]})
console.log("Error getting mode");
}
};
getMyJobList()
},[jobListTable])
useEffect(() => {
// Getting market data
const getMarketActiveJobList = async () => {