added socket event to listen to job market post

This commit is contained in:
victorAnumudu
2024-03-13 19:56:13 +01:00
parent 7f5eccb3b7
commit 70d82d89b3
4 changed files with 40 additions and 9 deletions
+11 -2
View File
@@ -14,8 +14,12 @@ import { updateWalletDetails } from "../store/walletDetails";
import { familyBannersList } from "../store/FamilyBannerList";
import { familyResources } from "../store/FamilyResources";
import {familyWalletRedeemOptList} from '../store/FamilyWalletRedeemOpt'
import { SocketValues } from "../components/Contexts/SocketIOContext";
const AuthRoute = ({ redirectPath = "/login", children }) => {
let {joinRoom} = SocketValues() // destructures 'SEND MESSAGE' and 'JOIN ROOM' FUNCTIONS FROM SOCKET
const apiCall = useMemo(() => new usersService(), []);
const dispatch = useDispatch();
const [lastActivityTime, setLastActivityTime] = useState(Date.now());
@@ -23,7 +27,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
const [loadProfileDetails, setLoadProfileDetails] = useState([]);
const navigate = useNavigate();
const { jobListTable, walletTable, familyBannersListTable } = useSelector(
const { jobListTable, marketTableList, walletTable, familyBannersListTable } = useSelector(
(state) => state.tableReload
);
@@ -219,7 +223,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
}
};
getMarketActiveJobList();
}, [apiCall, dispatch, jobListTable, isLogin.status]);
}, [apiCall, dispatch, marketTableList, isLogin.status]);
//FUNCTION TO GET COMMON HEAD DATA
useEffect(() => {
@@ -309,6 +313,11 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
familyWalletRedeemOptions()
}, [isLogin.status]);
useEffect(()=>{ // sends an event to the socket to enable user join a room to be able to receive update when jobs enters the market
joinRoom('full-markets-jobs')
console.log('joined oooooooooooooooooooooooooooooooooooooooooooooooooooooooo')
},[isLogin.status])
// RENDER PAGE
return isLogin.loading && !loggedIn ? (