diff --git a/src/Routers.jsx b/src/Routers.jsx index d282677..d196183 100644 --- a/src/Routers.jsx +++ b/src/Routers.jsx @@ -94,7 +94,7 @@ export default function Routers() { } /> } /> } /> - } /> + } /> } /> ) : ( diff --git a/src/components/Contexts/SocketIOContext.js b/src/components/Contexts/SocketIOContext.js index 6c9ab8e..b494ad8 100644 --- a/src/components/Contexts/SocketIOContext.js +++ b/src/components/Contexts/SocketIOContext.js @@ -67,6 +67,7 @@ export default function SocketIOContextProvider({children}) { let {message} = data if(message.action == "REFRESH_OFFER" && message.family_uid == user_uid && message.audience == "MEMBER"){ // for refreshing child account when parent assigns a job dispatch(tableReload({type:'FAMILYOFFERLIST'})) // dispatches to update family pending/offer list on family side + dispatch(tableReload({ type: "FAMILYBANNERSLIST" })) // dispatches to update family banner list on family side } if(message.action == "REFRESH_TASK" && message.audience == "PARENT"){ // for refreshing parent account when child accepts or rejects a job dispatch(tableReload({type:'PARENTFAMILYTASKLIST'})) // dispatches to update parent family task list on parent side diff --git a/src/components/Referral/ReferralDisplay.jsx b/src/components/Referral/ReferralDisplay.jsx index 7d87316..1f71989 100644 --- a/src/components/Referral/ReferralDisplay.jsx +++ b/src/components/Referral/ReferralDisplay.jsx @@ -74,7 +74,7 @@ function ReferralDisplay() { }; //FUNCTION TO SEND REFERRAL MESSAGE - const sendReferralMsg = (postData) => { + const sendReferralMsg = (postData, helpers) => { apiCall .sendReferralMsg(postData) .then((res) => { @@ -90,6 +90,7 @@ function ReferralDisplay() { } else { // toast.success(res.data.status | "Message Sent!"); setError({ message: res.data.status, loading: false, status: true }); + helpers.resetForm() // resets the form data setRefHistoryReload((prev) => !prev); setTimeout(()=>{ setError({ message: '', loading: false, status: true }); @@ -111,7 +112,7 @@ function ReferralDisplay() { //FUNCTION TO HANDLE SUBMIT const handleSubmit = (values, helpers) => { setError({ message: "", loading: true, status: false }); - sendReferralMsg({...values}); // FUNCTION TO SEND REFERRAL MESSAGE + sendReferralMsg({...values}, helpers); // FUNCTION TO SEND REFERRAL MESSAGE }; const [selectedTab, setSelectedTab] = useState("Send Referral"); diff --git a/src/middleware/AuthRoute.jsx b/src/middleware/AuthRoute.jsx index 0bdc379..8176f2a 100644 --- a/src/middleware/AuthRoute.jsx +++ b/src/middleware/AuthRoute.jsx @@ -20,6 +20,8 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { let {joinRoom} = SocketValues() // destructures 'SEND MESSAGE' and 'JOIN ROOM' FUNCTIONS FROM SOCKET + const [nocache, setNoCache] = useState(false) // holds cache/nocache value + const apiCall = useMemo(() => new usersService(), []); const dispatch = useDispatch(); const [lastActivityTime, setLastActivityTime] = useState(Date.now()); @@ -91,6 +93,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { } dispatch(updateUserDetails({ ...res.data })); setIsLogin({ loading: false, status: true }); + setNoCache(true) // Sets no cache to true, so as to trigger nocache whenever used in api call }) .catch((error) => { setIsLogin({ loading: false, status: false }); @@ -99,6 +102,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { loadProfile(); }else{ setIsLogin({ loading: false, status: true }); + setNoCache(true) // Sets no cache to true, so as to trigger nocache whenever used in api call } }, []); @@ -269,8 +273,11 @@ const AuthRoute = ({ redirectPath = "/login", children }) => { } const getFamilyBanners = async () => { // FUNCTION TO GET FAMILY BANNERS // setFamilyBannersList({loading:true, result:[]}); + dispatch(familyBannersList({loading:true})) + const noCache = (isLogin.status && nocache )? 1 : 0 + const reqData = {nocache: noCache} try { - const res = await apiCall.getFamilyBannersList(); + const res = await apiCall.getFamilyBannersList(reqData); dispatch(familyBannersList({...res?.data, loading:false})) } catch (error) { dispatch(familyBannersList({loading:false})) diff --git a/src/services/UsersService.js b/src/services/UsersService.js index 371dde2..0cdf4ca 100644 --- a/src/services/UsersService.js +++ b/src/services/UsersService.js @@ -1396,7 +1396,7 @@ class usersService { } // API FUNCTION TO FAMILY BANNERS - getFamilyBannersList() { + getFamilyBannersList(reqData) { var postData = { uid: localStorage.getItem("uid"), member_id: localStorage.getItem("member_id"), @@ -1404,6 +1404,7 @@ class usersService { action: apiConst.WRENCHBOARD_ACCOUNT_FAMILY_BANNERS, limit: 20, offset: 1, + ...reqData }; return this.postAuxEnd("/familybanners", postData); }