From 441b21ec35578cb644a384ad9f1ea6481d2af459 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Fri, 22 Nov 2024 08:28:57 +0100 Subject: [PATCH 1/3] resources bug fix --- src/views/OffersInterestPage.jsx | 8 ++++---- src/views/ResourcePage.jsx | 24 ++++++++++++------------ 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/views/OffersInterestPage.jsx b/src/views/OffersInterestPage.jsx index f3ecdcd..93b4274 100644 --- a/src/views/OffersInterestPage.jsx +++ b/src/views/OffersInterestPage.jsx @@ -1,4 +1,4 @@ -import React, { useContext, useState, useEffect } from "react"; +import React, { useState, useEffect } from "react"; // import BlogItem from "../components/Blogs"; import { useSelector } from "react-redux"; import OffersInterest from "../components/OffersInterest"; @@ -15,7 +15,7 @@ export default function OffersInterestPage() { let {joinRoom} = SocketValues() // function to join room for socket - const apiCall = new usersService() + const apiCall = useMemo(()=>{new usersService()},[]) let {commonHeadBanner} = useSelector(state => state.commonHeadBanner) @@ -28,11 +28,11 @@ export default function OffersInterestPage() { setOfferInterestList({loading: false, data: [], imgServer:''}) console.log('Error: ', err) }) - },[offerInterestListReload]) + },[apiCall, offerInterestListReload]) useEffect(()=>{ joinRoom(`INTEREST-${userDetails?.uid}`) - },[]) + },[joinRoom, userDetails]) return ( <> diff --git a/src/views/ResourcePage.jsx b/src/views/ResourcePage.jsx index 801f2a1..6be0f33 100644 --- a/src/views/ResourcePage.jsx +++ b/src/views/ResourcePage.jsx @@ -1,22 +1,22 @@ -import React, { useState, useEffect } from "react"; +import React, { useCallback, useMemo, useState, useEffect } from "react"; import Resources from "../components/Resources"; import usersService from "../services/UsersService"; import { useLocation } from "react-router-dom"; export default function ResourcePage() { - const {state, pathname} = useLocation() // CHECKS IF THERE IS AN ACTIVE TAB WITH LINK BACK TO RESOURCES + const {state} = useLocation() // CHECKS IF THERE IS AN ACTIVE TAB WITH LINK BACK TO RESOURCES const [MyResourceData, setMyResourceData] = useState([]); - const api = new usersService(); - const getMyResourceData = async () => { - try { - const res = await api.getResourceList(); - setMyResourceData(res.data); - } catch (error) { - throw new Error("Error getting mode"); - } - }; + const api = useMemo(()=>{new usersService()},[]); + const getMyResourceData = useCallback( async () => { + try { + const res = await api.getResourceList(); + setMyResourceData(res.data); + } catch (error) { + throw new Error("Error getting mode"); + } + },[api]) useEffect(() => { getMyResourceData(); - }, []); + }, [getMyResourceData]); return ; } \ No newline at end of file From bf28e501a9c7ee9b5181474b411529a7e5b9a66d Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Fri, 22 Nov 2024 08:35:36 +0100 Subject: [PATCH 2/3] resources bug fix --- src/views/OffersInterestPage.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/views/OffersInterestPage.jsx b/src/views/OffersInterestPage.jsx index 93b4274..f070188 100644 --- a/src/views/OffersInterestPage.jsx +++ b/src/views/OffersInterestPage.jsx @@ -1,4 +1,4 @@ -import React, { useState, useEffect } from "react"; +import React, { useMemo, useState, useEffect } from "react"; // import BlogItem from "../components/Blogs"; import { useSelector } from "react-redux"; import OffersInterest from "../components/OffersInterest"; From cee984e5740b5eb4ca376063966d3635981dc5ae Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Fri, 22 Nov 2024 11:17:24 +0100 Subject: [PATCH 3/3] removal of unused var --- src/components/AddJob/AddJob.jsx | 10 +- src/components/AuthPages/AuthLayout2.jsx | 4 +- .../AuthPages/AuthProfile/index.jsx | 100 +++++++++--------- .../AuthPages/AuthRedirect/AppleRedirect.jsx | 22 ++-- .../AuthPages/AuthRedirect/FbookRedirect.jsx | 8 +- .../AuthPages/AuthRedirect/Redirect.jsx | 8 +- .../AuthPages/ForgotPassword/index.jsx | 2 +- .../AuthPages/ForgotPassword/index2.jsx | 6 +- 8 files changed, 80 insertions(+), 80 deletions(-) diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx index 23e4339..5b07500 100644 --- a/src/components/AddJob/AddJob.jsx +++ b/src/components/AddJob/AddJob.jsx @@ -3,7 +3,7 @@ import { useDispatch, useSelector, usersService, - initialValues as IV, + // initialValues as IV, initialReqState, useState, tableReload, @@ -75,7 +75,7 @@ function AddJob({ popUpHandler, categories }) { // For form initial values const initialValues = { // initial values for formik - country: walletDetails.data.length == 1 ? walletDetails.data[0].country : '', + country: walletDetails.data.length === 1 ? walletDetails.data[0].country : '', price: "", title: "", description: "", @@ -117,7 +117,7 @@ function AddJob({ popUpHandler, categories }) { className={`input-field p-2 mt-3 rounded-full placeholder:text-base text-dark-gray w-full h-[42px] bg-slate-100 focus:ring-0 focus:outline-none border`} onChange={props.handleChange} onBlur={props.handleBlur} - disabled={walletDetails.data.length == 1} + disabled={walletDetails.data.length === 1} > {walletDetails?.loading ? ( ))} - ) : walletDetails.data.length == 1 ? + ) : walletDetails.data.length === 1 ? <> {walletDetails.data?.map((item, index) => (