From 99359d7568b826268b989d2f5ecde4393c8a5023 Mon Sep 17 00:00:00 2001 From: victorAnumudu Date: Thu, 1 Jun 2023 12:53:30 +0100 Subject: [PATCH] Height changed for textarea and upload area, max single file upload set to 1mb --- .env | 3 +++ .env.development | 5 ++++- .env.production | 3 +++ src/components/MyActiveJobs/ActiveJobs.jsx | 24 ++++++++++++++++++---- 4 files changed, 30 insertions(+), 5 deletions(-) diff --git a/.env b/.env index 6931de2..330d22f 100644 --- a/.env +++ b/.env @@ -45,6 +45,9 @@ REACT_APP_FACEBOOK_CLIENT_ID=390204307987009 REACT_APP_FACEBOOK_CLIENT_SECRET=19f778e312f2ab96d147bacb612910c2 REACT_APP_FACEBOOK_CLIENT_SCOPE="email, public_profile" +REACT_APP_MAX_FILE_SIZE=1000000 +REACT_APP_TOTAL_NUM_FILE=4 + #apigate.lotus.g1.wrenchboard.com:76.209.103.227 #apigate.orion.g1.wrenchboard.com:76.209.103.227 diff --git a/.env.development b/.env.development index 7783b2d..288f294 100644 --- a/.env.development +++ b/.env.development @@ -37,4 +37,7 @@ REACT_APP_ITEM_PER_PAGE=5 REACT_APP_GOOGLE_CLIENT_ID=817021856543-ad9nsjgdpsu2s2jrl63j3ihrv7lbf6ma.apps.googleusercontent.com REACT_APP_GOOGLE_CLIENT_SECRET=aozK_2G8UjaCmLgPPkv9abIm REACT_APP_GOOGLE_CLIENT_SCOPE="https://www.googleapis.com/auth/plus.login https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile" -REACT_APP_GOOGLE_REDIRECT_URL=http://localhost:9082/login/auth/ \ No newline at end of file +REACT_APP_GOOGLE_REDIRECT_URL=http://localhost:9082/login/auth/ + +REACT_APP_MAX_FILE_SIZE=1000000 +REACT_APP_TOTAL_NUM_FILE=4 \ No newline at end of file diff --git a/.env.production b/.env.production index 2f75776..d5d045f 100644 --- a/.env.production +++ b/.env.production @@ -41,3 +41,6 @@ REACT_APP_GOOGLE_REDIRECT_URL=https://users.wrenchboard.com/login/auth/ DISABLE_ESLINT_PLUGIN=true +REACT_APP_MAX_FILE_SIZE=1000000 +REACT_APP_TOTAL_NUM_FILE=4 + diff --git a/src/components/MyActiveJobs/ActiveJobs.jsx b/src/components/MyActiveJobs/ActiveJobs.jsx index 5a71898..e0a493f 100644 --- a/src/components/MyActiveJobs/ActiveJobs.jsx +++ b/src/components/MyActiveJobs/ActiveJobs.jsx @@ -26,8 +26,24 @@ function ActiveJobs(props) { setMessageToSend(value) } - // FUNCTION TO HANDLE FILE UplOAD CHANGE + // FUNCTION TO HANDLE FILE UPlOAD CHANGE const handleFileChange = ({target:{files}}) => { + setRequestStatus({loading: false, status: false, message: ''}) // State to determine error state + if(files[0].size > Number(process.env.REACT_APP_MAX_FILE_SIZE)){ + setRequestStatus({loading: false, status: false, message: 'File must be <= 1mb'}) + setTimeout(()=>{ + setRequestStatus({loading: false, status: false, message: ''}) + }, 5000) + return + } + if(filesToSend.length >= Number(process.env.REACT_APP_TOTAL_NUM_FILE)){ + setRequestStatus({loading: false, status: false, message: `Total number of attachment is ${Number(process.env.REACT_APP_TOTAL_NUM_FILE)}`}) + setTimeout(()=>{ + setRequestStatus({loading: false, status: false, message: ''}) + }, 5000) + return + } + // INCLUDE FILE IF NO ERROR setFilesToSend(prev => ([...prev, files[0]])) } @@ -170,8 +186,8 @@ function ActiveJobs(props) { {tab == 'message' ? (