Compare commits

...

9 Commits

7 changed files with 131 additions and 49 deletions
+1
View File
@@ -18,6 +18,7 @@ REACT_APP_USERS_ENDPOINT="https://apigate.lotus.g1.wrenchboard.com/svs/user"
#"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser" #"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser"
REACT_APP_SESSION_EXPIRE_MINUTES=300000 REACT_APP_SESSION_EXPIRE_MINUTES=300000
REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY=600000
REACT_APP_SESSION_EXPIRE_CHECKER=60000 REACT_APP_SESSION_EXPIRE_CHECKER=60000
REACT_APP_LOGIN_ERROR_TIMEOUT=7000 REACT_APP_LOGIN_ERROR_TIMEOUT=7000
+1
View File
@@ -18,6 +18,7 @@ REACT_APP_USERS_ENDPOINT="https://apigate.lotus.g1.wrenchboard.com/svs/user"
#"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser" #"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser"
REACT_APP_SESSION_EXPIRE_MINUTES=300000 REACT_APP_SESSION_EXPIRE_MINUTES=300000
REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY=600000
REACT_APP_SESSION_EXPIRE_CHECKER=60000 REACT_APP_SESSION_EXPIRE_CHECKER=60000
REACT_APP_LOGIN_ERROR_TIMEOUT=7000 REACT_APP_LOGIN_ERROR_TIMEOUT=7000
+1
View File
@@ -18,6 +18,7 @@ REACT_APP_USERS_ENDPOINT="https://apigate.orion.g1.wrenchboard.com/svs/user"
#"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser" #"https://devapi.mermsemr.com/en/desktop/api/v2/myfituser"
REACT_APP_SESSION_EXPIRE_MINUTES=300000 REACT_APP_SESSION_EXPIRE_MINUTES=300000
REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY=600000
REACT_APP_SESSION_EXPIRE_CHECKER=60000 REACT_APP_SESSION_EXPIRE_CHECKER=60000
REACT_APP_LOGIN_ERROR_TIMEOUT=7000 REACT_APP_LOGIN_ERROR_TIMEOUT=7000
+37 -2
View File
@@ -95,7 +95,7 @@ function ActiveJobs(props) {
} }
// FUNCTION TO SEND FILES // FUNCTION TO SEND FILES
const sendFile = () => { const sendFile = async () => {
setRequestStatus({loading: true, status: false, message: ''}) setRequestStatus({loading: true, status: false, message: ''})
if(!filesToSend.length){ // checks if file to send is empty if(!filesToSend.length){ // checks if file to send is empty
@@ -109,12 +109,28 @@ function ActiveJobs(props) {
// for(let files of filesToSend){ // for(let files of filesToSend){
// reqData.append(files.name, files) // reqData.append(files.name, files)
// } // }
let reqData={file_size: filesToSend[0].size, file_type: 'image/png', file_data: filesToSend[0], msg_type: 'FILE', contract:props.details.contract} // let reqData={file_size: filesToSend[0].size, file_type: 'image/png', file_data: filesToSend[0], msg_type: 'FILE', contract:props.details.contract}
// for(let files of filesToSend){ // for(let files of filesToSend){
// reqData[files.name] = files // reqData[files.name] = files
// } // }
const fileToBase64 = async () =>{
try {
const base64String = await convertFileToBase64(filesToSend[0]);
return base64String;
} catch (error) {
return false;
}
}
if(await !fileToBase64()){
return
}
let reqData={file_name: filesToSend[0].name, file_size: filesToSend[0].size, file_type: 'image/png', file_data: await fileToBase64(), msg_type: 'FILE', contract:props.details.contract}
console.log(reqData)
ApiCall.sendFiles(reqData).then((res)=>{ ApiCall.sendFiles(reqData).then((res)=>{
if(res.status != 200 || res.data.internal_return < 0){ if(res.status != 200 || res.data.internal_return < 0){
setRequestStatus({loading: false, status: false, message: 'Files(s) could not be sent, try again later'}) setRequestStatus({loading: false, status: false, message: 'Files(s) could not be sent, try again later'})
@@ -367,3 +383,22 @@ function ActiveJobs(props) {
} }
export default ActiveJobs; export default ActiveJobs;
function convertFileToBase64(file) {
return new Promise((resolve, reject) => {
const reader = new FileReader();
reader.onload = () => {
const base64String = reader.result.split(',')[1];
resolve(base64String);
};
reader.onerror = error => {
reject(error);
};
reader.readAsDataURL(file);
});
}
+1 -1
View File
@@ -100,7 +100,7 @@ export default function Header({ logoutModalHandler, sidebarHandler }) {
// User Profile // User Profile
let { firstname, lastname, email, profile_pic } = userDetails; let { firstname, lastname, email, profile_pic } = userDetails;
let userEmail = email.split("@")[0]; let userEmail = email?.split("@")[0];
return ( return (
<> <>
+58 -29
View File
@@ -1,46 +1,63 @@
import React, { useMemo, useState } from "react"; import React, { useCallback, useMemo, useState } from "react";
import Detail from "./popoutcomponent/Detail"; import Detail from "./popoutcomponent/Detail";
import ModalCom from "../Helpers/ModalCom"; import ModalCom from "../Helpers/ModalCom";
import usersService from "../../services/UsersService"; import usersService from "../../services/UsersService";
import { toast } from "react-toastify";
import LoadingSpinner from "../Spinners/LoadingSpinner";
const showSuccessToast = (message) => {
toast.success(message, {
autoClose: 3000,
hideProgressBar: true,
});
};
function PendingJobsPopout({ details, onClose, situation }) { function PendingJobsPopout({ details, onClose, situation }) {
const [pendingJobLoader, setPendingJobLoader] = useState(false) const [pendingJobLoader, setPendingJobLoader] = useState({
extend: false,
offer: false,
});
const apiCall = useMemo(() => new usersService(), []); const apiCall = useMemo(() => new usersService(), []);
const handlePendingJobsBtn = async ({ target: { name } }) => { const handlePendingJobsBtn = useCallback(
setPendingJobLoader(true) async ({ target: { name } }) => {
let { job_uid, offer_code } = details; let { job_uid, offer_code } = details;
let reqData; let reqData;
let pendingData = { job_uid, offer_code }; let pendingData = { job_uid, offer_code };
if (name === "extend") {
try { try {
reqData = { ...pendingData }; if (name === "extend") {
let { data } = await apiCall.pendingJobExtend(reqData); setPendingJobLoader({ extend: true });
console.log("This is for extend", data); reqData = { ...pendingData };
setPendingJobLoader(false) // let { data } =
await apiCall.pendingJobExtend(reqData);
// console.log("This is for extend", data);
showSuccessToast("Job has been extended by a week!");
} else if (name === "offer") {
setPendingJobLoader({ offer: true });
reqData = { ...pendingData };
// let { data } =
await apiCall.pendingJobSendTome(reqData);
// console.log("This is for offer", data);
showSuccessToast("Offer sent, check your email");
} else return;
setTimeout(() => {
setPendingJobLoader({ extend: false, offer: false });
onClose();
}, 2700);
} catch (error) { } catch (error) {
setPendingJobLoader(false) setPendingJobLoader({ extend: false, offer: false });
throw new Error(error); throw new Error(error);
} }
} else if (name === "offer") { },
try { [onClose, apiCall, details]
reqData = { ...pendingData }; );
let { data } = await apiCall.pendingJobSendTome(reqData);
console.log("This is for offer", data);
setPendingJobLoader(false)
} catch (error) {
setPendingJobLoader(false)
throw new Error(error);
}
} else return;
onClose();
};
return ( return (
<ModalCom action={onClose} situation={situation}> <ModalCom action={onClose} situation={situation} className="edit-popup">
<div className="logout-modal-wrapper lw-[90%] md:w-[768px] h-full lg:h-auto bg-white dark:bg-dark-white lg:rounded-2xl overflow-y-auto"> <div className="logout-modal-wrapper lw-[90%] md:w-[768px] h-full lg:h-auto bg-white dark:bg-dark-white lg:rounded-2xl overflow-y-auto">
<div className="logout-modal-header w-full flex items-center justify-between lg:p-6 px-[30px] py-[23px] border-b dark:border-[#5356fb29] border-light-purple"> <div className="logout-modal-header w-full flex items-center justify-between lg:p-6 px-[30px] py-[23px] border-b dark:border-[#5356fb29] border-light-purple">
<h1 className="text-26 font-bold text-dark-gray dark:text-white tracking-wide"> <h1 className="text-26 font-bold text-dark-gray dark:text-white tracking-wide">
@@ -159,7 +176,13 @@ function PendingJobsPopout({ details, onClose, situation }) {
onClick={handlePendingJobsBtn} onClick={handlePendingJobsBtn}
name="extend" name="extend"
> >
Extend by a week {pendingJobLoader.extend ? (
<div className="w-[136px] flex justify-center items-center h-full">
<LoadingSpinner size={5} color="sky-blue" />
</div>
) : (
"Extend by a week"
)}
</button> </button>
</div> </div>
@@ -169,7 +192,13 @@ function PendingJobsPopout({ details, onClose, situation }) {
onClick={handlePendingJobsBtn} onClick={handlePendingJobsBtn}
name="offer" name="offer"
> >
Send to me {pendingJobLoader.offer ? (
<div className="w-[96px] flex justify-center items-center h-full">
<LoadingSpinner size={5} color="sky-blue" />
</div>
) : (
"Send to me"
)}
</button> </button>
</div> </div>
+28 -13
View File
@@ -12,23 +12,37 @@ 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} = useSelector((state) => state.tableReload) const { jobListTable } = useSelector((state) => state.tableReload);
useEffect(() => { useEffect(() => {
//Removing Data stored at localStorage after session expires //Removing Data stored at localStorage after session expires
const expireSession = () => { const expireSession = () => {
localStorage.clear(); localStorage.removeItem("uid");
localStorage.removeItem("member_id");
localStorage.removeItem("session_token");
navigate("/login", { replace: true }); // redirects user to login page after session expires navigate("/login", { replace: true }); // redirects user to login page after session expires
}; };
console.log(loadProfileDetails);
const checkInactivity = setInterval(() => { const checkInactivity = setInterval(() => {
if ( let { account_type } = loadProfileDetails;
Date.now() - lastActivityTime > if (account_type === "FAMILY") {
process.env.REACT_APP_SESSION_EXPIRE_MINUTES if (
) { Date.now() - lastActivityTime >
expireSession(); process.env.REACT_APP_SESSION_EXPIRE_MINUTES_FAMILY
) {
expireSession();
}
} else {
if (
Date.now() - lastActivityTime >
process.env.REACT_APP_SESSION_EXPIRE_MINUTES
) {
expireSession();
}
} }
}, process.env.REACT_APP_SESSION_EXPIRE_CHECKER); // Checks for inactivity every minute }, process.env.REACT_APP_SESSION_EXPIRE_CHECKER); // Checks for inactivity every minute
@@ -65,6 +79,7 @@ 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 });
}) })
@@ -76,22 +91,22 @@ const AuthRoute = ({ redirectPath = "/login", children }) => {
} }
}, []); }, []);
useEffect(()=>{ useEffect(() => {
const getMyJobList = async () => { const getMyJobList = async () => {
dispatch(updateUserJobList({loading: true, data:[]})) dispatch(updateUserJobList({ loading: true, data: [] }));
try { try {
const res = await apiCall.getMyJobList(); const res = await apiCall.getMyJobList();
// setMyJobList({loading: false, data:res.data}) // setMyJobList({loading: false, data:res.data})
// setMyJobList(res.data); // setMyJobList(res.data);
dispatch(updateUserJobList({loading: false, data:res.data})) dispatch(updateUserJobList({ loading: false, data: res.data }));
} catch (error) { } catch (error) {
dispatch(updateUserJobList({loading: false, data:[]})) dispatch(updateUserJobList({ loading: false, data: [] }));
// setMyJobList({loading: false, data:[]}) // setMyJobList({loading: false, data:[]})
console.log("Error getting mode"); console.log("Error getting mode");
} }
}; };
getMyJobList() getMyJobList();
},[jobListTable]) }, [jobListTable]);
useEffect(() => { useEffect(() => {
// Getting market data // Getting market data