From 8707411dda0b91e6e7343ad877cc20782e52d39d Mon Sep 17 00:00:00 2001 From: ebube Date: Tue, 28 Nov 2023 21:02:17 -0800 Subject: [PATCH 1/2] added a linux checker --- src/components/AddJob/AddJob.jsx | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/components/AddJob/AddJob.jsx b/src/components/AddJob/AddJob.jsx index bbd0094..14c85f0 100644 --- a/src/components/AddJob/AddJob.jsx +++ b/src/components/AddJob/AddJob.jsx @@ -24,10 +24,7 @@ function AddJob({ popUpHandler, categories }) { let dispatch = useDispatch(); - const getWalletDetails = getWalletDetail( - userDetails.country, - walletDetails - ); + const getWalletDetails = getWalletDetail(userDetails.country, walletDetails); const walletAmount = getWalletDetails; // GETTING USER BALANCE BASED ON COUNTRY SELECTED const initialValues = { ...IV, country: walletAmount?.description }; const [requestStatus, setRequestStatus] = useState(initialReqState); // Holds state when submit button is pressed @@ -83,6 +80,9 @@ function AddJob({ popUpHandler, categories }) { // Check if the user is using iOS const isIOS = /MacIntel|MacPPC/.test(navigator.platform) && !window.MSStream; + // Check if the user is using Linux + const isLinux = /Linux/.test(navigator.platform); + // Check if the user is using Windows const isWindows = /Windows/.test(navigator.userAgent); @@ -187,7 +187,7 @@ function AddJob({ popUpHandler, categories }) {
+ className={`input-field p-2 mt-3 rounded-md placeholder:text-base text-dark-gray dark:text-white w-full h-10 bg-slate-100 dark:bg-[#11131F] focus:ring-0 focus:outline-none border`} + onChange={props.handleChange} + onBlur={props.handleBlur} + > + {walletDetails?.loading ? ( + + ) : walletDetails.data.length ? ( + <> + + {walletDetails.data?.map((item, index) => ( + + ))} + + ) : ( + + )} +
{/* Price */} @@ -210,55 +220,46 @@ function AddJob({ popUpHandler, categories }) {
- - + + {props.errors.category && + props.touched.category && + "please select a category"} + +
diff --git a/src/components/jobPopout/EditJobPopout.jsx b/src/components/jobPopout/EditJobPopout.jsx index a06d995..104251a 100644 --- a/src/components/jobPopout/EditJobPopout.jsx +++ b/src/components/jobPopout/EditJobPopout.jsx @@ -54,12 +54,17 @@ const EditJobPopOut = ({ const { userDetails } = useSelector((state) => state.userDetails); const { walletDetails } = useSelector((state) => state.walletDetails); - - const uploadedImage = `${userDetails.session_image_server}${localStorage.getItem('session_token')}/job/${details?.job_uid}` + const uploadedImage = `${ + userDetails.session_image_server + }${localStorage.getItem("session_token")}/job/${details?.job_uid}`; - const [taskImage, setTaskImage] = useState(uploadedImage) + const [taskImage, setTaskImage] = useState(uploadedImage); - let [uploadStatus, setUploadStatus] = useState({loading: false, status: false, message:''}) // HOLDS STATE FOR UPLOAD PROFILE PICTURE STATUS + let [uploadStatus, setUploadStatus] = useState({ + loading: false, + status: false, + message: "", + }); // HOLDS STATE FOR UPLOAD PROFILE PICTURE STATUS let [requestStatus, setRequestStatus] = useState({ loading: false, @@ -115,70 +120,99 @@ const EditJobPopOut = ({ ); const taskImgChangeHandler = (e) => { - setUploadStatus({loading: false, status: false, message:''}) - let acceptedFormat = ["jpeg", "jpg", "png", "bmp", "gif"] // ARRAY OF SUPPORTED FORMATS - let uploadedFile = e.target.files[0] //UPLOADED FILE + setUploadStatus({ loading: false, status: false, message: "" }); + let acceptedFormat = ["jpeg", "jpg", "png", "bmp", "gif"]; // ARRAY OF SUPPORTED FORMATS + let uploadedFile = e.target.files[0]; //UPLOADED FILE const fileFormat = uploadedFile?.type?.split("/")[1]?.toLowerCase(); - if(!acceptedFormat.includes(fileFormat)){ //CHECKING FOR CORRECT UPLOAD FORMAT - const msg = `Please select ${acceptedFormat.slice(0, -1).join(', ')} or ${acceptedFormat.slice(-1)}`; - setUploadStatus({loading: false, status: false, message:msg}) - return setTimeout(()=>{ + if (!acceptedFormat.includes(fileFormat)) { + //CHECKING FOR CORRECT UPLOAD FORMAT + const msg = `Please select ${acceptedFormat + .slice(0, -1) + .join(", ")} or ${acceptedFormat.slice(-1)}`; + setUploadStatus({ loading: false, status: false, message: msg }); + return setTimeout(() => { // profileImgInput.current.value = '' // clear the input - setUploadStatus({loading: false, status: false, message:''}) - },5000) + setUploadStatus({ loading: false, status: false, message: "" }); + }, 5000); } - if(uploadedFile.size > 5*1048576){ // CHECKING FOR CORRECT FILE SIZE - setUploadStatus({loading: false, status: false, message:'File must not exceed 5MB'}) - return setTimeout(()=>{ + if (uploadedFile.size > 5 * 1048576) { + // CHECKING FOR CORRECT FILE SIZE + setUploadStatus({ + loading: false, + status: false, + message: "File must not exceed 5MB", + }); + return setTimeout(() => { // profileImgInput.current.value = '' // clear the input - setUploadStatus({loading: false, status: false, message:''}) - },5000) + setUploadStatus({ loading: false, status: false, message: "" }); + }, 5000); } if (e.target.value !== "") { const imgReader = new FileReader(); imgReader.onload = (event) => { let base64Img = imgReader.result.split(",")[1]; - let reqData = { // PAYLOAD FOR API CALL + let reqData = { + // PAYLOAD FOR API CALL job_uid: details?.job_uid, - file_name: uploadedFile?.name.slice(0,19), + file_name: uploadedFile?.name.slice(0, 19), file_size: uploadedFile?.size, file_type: uploadedFile?.type?.split("/")[0]?.toLowerCase(), file_data: base64Img, - msg_type: 'FILE', - action: 11303 - } - setUploadStatus({loading: true, status: false, message:'Loading...'}) - jobApi.sendFiles(reqData).then(res=>{ - if(res.status != 200 || res.data.internal_return < 0){ - return setUploadStatus({loading: false, status: false, message: 'Something went wrong, try again'}) - } - setUploadStatus({loading: false, status: true, message: 'Uploaded successfully'}) - setTaskImage(event.target.result); - setTimeout(() => { - dispatch(tableReload({ type: "JOBTABLE" })); - navigate("/myjobs", { replace: true }); - onClose(); - }, 1000); - }).catch(error=>{ - setUploadStatus({loading: false, status: false, message: 'Network error, try again'}) - }).finally(()=>{ - setTimeout(()=>{ - setUploadStatus({loading: false, status: false, message: ''}) - },5000) - }) + msg_type: "FILE", + action: 11303, + }; + setUploadStatus({ + loading: true, + status: false, + message: "Loading...", + }); + jobApi + .sendFiles(reqData) + .then((res) => { + if (res.status != 200 || res.data.internal_return < 0) { + return setUploadStatus({ + loading: false, + status: false, + message: "Something went wrong, try again", + }); + } + setUploadStatus({ + loading: false, + status: true, + message: "Uploaded successfully", + }); + setTaskImage(event.target.result); + setTimeout(() => { + dispatch(tableReload({ type: "JOBTABLE" })); + navigate("/myjobs", { replace: true }); + onClose(); + }, 1000); + }) + .catch((error) => { + setUploadStatus({ + loading: false, + status: false, + message: "Network error, try again", + }); + }) + .finally(() => { + setTimeout(() => { + setUploadStatus({ loading: false, status: false, message: "" }); + }, 5000); + }); }; imgReader.readAsDataURL(e.target.files[0]); } }; - // Check if the user is using iOS - const isIOS = /MacIntel|MacPPC/.test(navigator.platform) && !window.MSStream; + // Check if the user is using iOS + const isIOS = /MacIntel|MacPPC/.test(navigator.platform) && !window.MSStream; - // Check if the user is using Windows - const isWindows = /Windows/.test(navigator.userAgent); + // Check if the user is using Windows + const isWindows = /Windows/.test(navigator.userAgent); return ( @@ -321,82 +355,77 @@ const EditJobPopOut = ({
- - -
+ + {props.errors.category && + props.touched.category && + "please select a category"} + + +
{/* FOR TASK IMAGE */}
- - {taskImage ? -
- uploaded task - setTaskImage('')} className="p-2 absolute text-sm top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 bg-white/80 hover:bg-white hover:shadow-md transition-all duration-500 cursor-pointer text-slate-800">Remove Image -
- : - + )}
{/* END OF TASK IMAGE */}
-
+
+ {/* DISPLAYS TASK IMAGE UPLOADING STATUS */} +
+ {uploadStatus.message && !uploadStatus.loading && ( +

+ {uploadStatus.message} +

+ )} + {uploadStatus.loading && ( +

{uploadStatus.message}

+ )} +
@@ -471,7 +512,9 @@ const EditJobPopOut = ({ type="submit" className="w-[120px] h-[40px] flex justify-center items-center btn-gradient text-base rounded-full text-white" // className='w-20 h-11 flex justify-center items-center btn-gradient text-base rounded-full text-white' - disabled={requestStatus.loading || uploadStatus.loading} + disabled={ + requestStatus.loading || uploadStatus.loading + } > Save