cache banner API using redux

This commit was merged in pull request #580.
This commit is contained in:
victorAnumudu
2024-02-26 18:07:58 +01:00
parent bddbe6ceb4
commit 06186b3c0f
5 changed files with 88 additions and 21 deletions
+20 -1
View File
@@ -11,6 +11,7 @@ import { updateJobs } from "../store/jobLists";
import { updateNotifications } from "../store/notifications";
import { updateUserJobList } from "../store/userJobList";
import { updateWalletDetails } from "../store/walletDetails";
import { familyBannersList } from "../store/FamilyBannerList";
const AuthRoute = ({ redirectPath = "/login", children }) => {
const apiCall = useMemo(() => new usersService(), []);
@@ -20,7 +21,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
const [loadProfileDetails, setLoadProfileDetails] = useState([]);
const navigate = useNavigate();
const { jobListTable, walletTable } = useSelector(
const { jobListTable, walletTable, familyBannersListTable } = useSelector(
(state) => state.tableReload
);
@@ -252,6 +253,24 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
});
}, []);
//FUNCTION TO GET FAMILY BANNERS
useEffect(() => {
if((!loggedIn && !isLogin.status) || account_type == 'FULL'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FULL
return
}
const getFamilyBanners = async () => { // FUNCTION TO GET FAMILY BANNERS
// setFamilyBannersList({loading:true, result:[]});
try {
const res = await apiCall.getFamilyBannersList();
dispatch(familyBannersList(res.data))
} catch (error) {
console.log("Error getting tasks");
}
};
getFamilyBanners()
}, [isLogin.status, familyBannersListTable]);
// useEffect(() => {
// apiCall
// .getHeroJBanners()