From 6ef31e5dbe0e59b2e08d67e5c72cfbf0148bcccf Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Thu, 31 Oct 2024 02:47:49 +0100 Subject: [PATCH] reloads market job list when the api call fails --- src/components/MarketPlace/index.jsx | 13 ++++++++++++- src/middleware/AuthRoute.jsx | 2 ++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/components/MarketPlace/index.jsx b/src/components/MarketPlace/index.jsx index c017cf6..42255fe 100644 --- a/src/components/MarketPlace/index.jsx +++ b/src/components/MarketPlace/index.jsx @@ -1,16 +1,27 @@ -import { useSelector } from "react-redux"; +import {useEffect} from 'react' +import { useSelector, useDispatch} from "react-redux"; import Layout from "../Partials/Layout"; import CommonHead from "../UserHeader/CommonHead"; import MainSection from "./MainSection"; import CustomBreadcrumb from "../Breadcrumb/CustomBreadcrumb"; import LoadingSpinner from "../Spinners/LoadingSpinner"; +import { tableReload } from '../../store/TableReloads'; export default function MarketPlace({ commonHeadData }) { + + const dispatch = useDispatch() + let { jobLists } = useSelector((state) => state.jobLists); const marketData = jobLists?.result_list; const categories = jobLists?.categories; const image_server = jobLists?.session_image_server; + useEffect(()=>{ + if(marketData?.length < 1 && !jobLists.loading){ + dispatch(tableReload({ type: "MARKETTABLELIST" })); // reloads market page + } + },[]) + return ( <> diff --git a/src/middleware/AuthRoute.jsx b/src/middleware/AuthRoute.jsx index fa9778f..2553ff2 100644 --- a/src/middleware/AuthRoute.jsx +++ b/src/middleware/AuthRoute.jsx @@ -231,6 +231,8 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { getMyWalletList(); }, [walletTable, isLogin.status]); + + // FUNCTION TO GET MARKET JOB LIST useEffect(() => { if((!loggedIn && !isLogin.status) || account_type == 'FAMILY'){ // DO NOT CALL THIS, IF USER ACCOUNT TYPE IS FAMILY return