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 -24
View File
@@ -14,6 +14,7 @@ import usersService from "../../services/UsersService";
export default function Layout({ children }) {
const { drawer } = useSelector((state) => state.drawer);
const {userJobList} = useSelector((state) => state.userJobList)
const dispatch = useDispatch();
const [MobileSideBar, setMobileSidebar] = useToggle(false);
const [logoutModal, setLogoutModal] = useState(false);
@@ -35,29 +36,24 @@ export default function Layout({ children }) {
//---------------------------------------
/* LET U DEAL WITH JOB LIST - we need to centralize this list */
const {jobListTable} = useSelector((state) => state.tableReload)
const [myJobList, setMyJobList] = useState({loading: true, data:[]});
const api = new usersService();
// const {jobListTable} = useSelector((state) => state.tableReload)
// const [myJobList, setMyJobList] = useState({loading: true, data:[]});
// const api = new usersService();
const getMyJobList = async () => {
setMyJobList({loading: true, data:[]})
try {
const res = await api.getMyJobList();
setMyJobList({loading: false, data:res.data})
// setMyJobList(res.data);
} catch (error) {
setMyJobList({loading: false, data:[]})
console.log("Error getting mode");
}
};
useEffect(() => {
getMyJobList();
}, [jobListTable]);
// const getJobList = ()=>{
// let jobLists = useSelector((state) => state.jobLists);
// return jobLists;
// }
//---------------------------------------
// const getMyJobList = async () => {
// setMyJobList({loading: true, data:[]})
// try {
// const res = await api.getMyJobList();
// setMyJobList({loading: false, data:res.data})
// // setMyJobList(res.data);
// } catch (error) {
// setMyJobList({loading: false, data:[]})
// console.log("Error getting mode");
// }
// };
// useEffect(() => {
// getMyJobList();
// }, [jobListTable]);
return (
<>
@@ -75,7 +71,7 @@ export default function Layout({ children }) {
logoutModalHandler={logoutModalHandler}
sidebar={drawer}
action={() => dispatch(drawerToggle())}
myJobList={myJobList}
myJobList={userJobList}
/>
</div>
{MobileSideBar && (
@@ -93,7 +89,7 @@ export default function Layout({ children }) {
logoutModalHandler={logoutModalHandler}
sidebar={MobileSideBar}
action={() => setMobileSidebar.toggle()}
myJobList={myJobList}
myJobList={userJobList}
/>
</div>
{/* end sidebar */}