Merge master into family_banner_reload

This commit is contained in:
victorAnumudu
2024-11-29 05:09:23 +01:00
2 changed files with 23 additions and 22 deletions
+20 -8
View File
@@ -1,5 +1,5 @@
import React, { useEffect, useState } from "react"; import React, { useEffect, useState } from "react";
import { toast } from "react-toastify"; // import { toast } from "react-toastify";
import usersService from "../../services/UsersService"; import usersService from "../../services/UsersService";
import InputCom from "../Helpers/Inputs/InputCom"; import InputCom from "../Helpers/Inputs/InputCom";
import LoadingSpinner from "../Spinners/LoadingSpinner"; import LoadingSpinner from "../Spinners/LoadingSpinner";
@@ -84,11 +84,16 @@ function ReferralDisplay() {
loading: false, loading: false,
status: false, status: false,
}); });
return; setTimeout(()=>{
setError({ message: '', loading: false, status: false });
},3000)
} else { } else {
toast.success(res.data.status | "Message Sent!"); // toast.success(res.data.status | "Message Sent!");
setError({ message: "", loading: false, status: true }); setError({ message: res.data.status, loading: false, status: true });
setRefHistoryReload((prev) => !prev); setRefHistoryReload((prev) => !prev);
setTimeout(()=>{
setError({ message: '', loading: false, status: true });
},3000)
} }
}) })
.catch((error) => { .catch((error) => {
@@ -97,6 +102,9 @@ function ReferralDisplay() {
loading: false, loading: false,
status: false, status: false,
}); });
setTimeout(()=>{
setError({ message: '', loading: false, status: false });
},3000)
}); });
}; };
@@ -228,7 +236,7 @@ function ReferralDisplay() {
<hr /> <hr />
{error.message != "" && ( {error.message != "" && (
<p className="text-base text-red-500 py-2">{error.message}</p> <p className={`text-base py-2 ${error.status ? 'text-emerald-500' : 'text-red-500'}`}>{error.message}</p>
)} )}
<div className="referral-btn flex justify-end items-center py-4"> <div className="referral-btn flex justify-end items-center py-4">
{error.loading ? ( {error.loading ? (
@@ -237,6 +245,7 @@ function ReferralDisplay() {
<button <button
type="submit" type="submit"
className="px-2 h-11 flex justify-center items-center btn-gradient text-base rounded-full text-white" className="px-2 h-11 flex justify-center items-center btn-gradient text-base rounded-full text-white"
disabled={error.loading || error.status}
> >
Send Message Send Message
</button> </button>
@@ -251,9 +260,12 @@ function ReferralDisplay() {
{selectedTab == 'Referral List' && {selectedTab == 'Referral List' &&
<> <>
<div className="w-full p-4"> <div className="w-full p-4">
<h2 className="mb-2 text-slate-900 dark:text-white text-xl lg:text-2xl font-medium"> <div className='mb-2 flex flex-wrap gap-4 items-center'>
Referral List <h2 className="text-slate-900 dark:text-white text-xl lg:text-2xl font-medium">
</h2> Referral List
</h2>
<p className='text-slate-900 dark:text-white text-sm lg:text-base'>Uncompleted signup will be removed automatically after 7 days</p>
</div>
{referralList.loading ? ( {referralList.loading ? (
<LoadingSpinner size="22" color="sky-blue" /> <LoadingSpinner size="22" color="sky-blue" />
) : ( ) : (
+3 -14
View File
@@ -26,7 +26,6 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
const dispatch = useDispatch(); const dispatch = useDispatch();
const [lastActivityTime, setLastActivityTime] = useState(Date.now()); const [lastActivityTime, setLastActivityTime] = useState(Date.now());
const [isLogin, setIsLogin] = useState({ loading: true, status: false }); const [isLogin, setIsLogin] = useState({ loading: true, status: false });
const [loadProfileDetails, setLoadProfileDetails] = useState([]);
const navigate = useNavigate(); const navigate = useNavigate();
const { jobListTable, marketTableList, walletTable, familyBannersListTable, homeBanners } = useSelector( const { jobListTable, marketTableList, walletTable, familyBannersListTable, homeBanners } = useSelector(
@@ -48,19 +47,12 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
}; };
const checkInactivity = setInterval(() => { const checkInactivity = setInterval(() => {
let { account_type } = loadProfileDetails;
if (account_type === "FAMILY") { if (account_type === "FAMILY") {
if ( if (Date.now() - Number(lastActivityTime) > Number(process.env.REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY)) {
Date.now() - lastActivityTime >
process.env.REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY
) {
expireSession(); expireSession();
} }
} else { } else {
if ( if (Date.now() - Number(lastActivityTime) > Number(process.env.REACT_APP_SESSION_EXPIRE_MINUTES)) {
Date.now() - lastActivityTime >
process.env.REACT_APP_SESSION_EXPIRE_MINUTES
) {
expireSession(); expireSession();
} }
} }
@@ -70,7 +62,7 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
return () => { return () => {
clearInterval(checkInactivity); clearInterval(checkInactivity);
}; };
}, [lastActivityTime, navigate]); }, [lastActivityTime, navigate, isLogin.status]);
// Reset last activity time on user input // Reset last activity time on user input
const resetTime = useCallback(() => { const resetTime = useCallback(() => {
@@ -99,7 +91,6 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
setIsLogin({ loading: false, status: false }); setIsLogin({ loading: false, status: false });
return; return;
} }
setLoadProfileDetails(res.data);
dispatch(updateUserDetails({ ...res.data })); dispatch(updateUserDetails({ ...res.data }));
setIsLogin({ loading: false, status: true }); setIsLogin({ loading: false, status: true });
setNoCache(true) // Sets no cache to true, so as to trigger nocache whenever used in api call setNoCache(true) // Sets no cache to true, so as to trigger nocache whenever used in api call
@@ -145,8 +136,6 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
dispatch(updateNotifications({ loading: false, data: null })); dispatch(updateNotifications({ loading: false, data: null }));
return; return;
} }
setLoadProfileDetails(res.data);
const _raw = res.data?.result_list; const _raw = res.data?.result_list;
//Sort the notifications in ascending order based on the API time //Sort the notifications in ascending order based on the API time