diff --git a/pmp-reactjs-ui/src/pages/UploadCertificate.js b/pmp-reactjs-ui/src/pages/UploadCertificate.js index d7e46f562..31d9716a1 100644 --- a/pmp-reactjs-ui/src/pages/UploadCertificate.js +++ b/pmp-reactjs-ui/src/pages/UploadCertificate.js @@ -11,6 +11,7 @@ function UploadCertificate({ closePopup, partnerData }) { const [certificateData, setCertificateData] = useState(""); const [formattedDate, setFormattedDate] = useState(""); const [rotation, setRotation] = useState(0); + const [dataLoaded, setDataLoaded] = useState(true); const openDropdown = () => { setIsDropdownOpen(!isDropdownOpen); @@ -22,6 +23,7 @@ function UploadCertificate({ closePopup, partnerData }) { if (uploadSuccess) { closePopup(); } else { + setDataLoaded(false); let request = { request: { partnerId: partnerData.partnerId, @@ -31,15 +33,20 @@ function UploadCertificate({ closePopup, partnerData }) { } try { const response = await HttpService.post('/api/partners/certificate/upload', request) - const resData = response.data.response; - if (response.data.errors && response.data.errors.length > 0) { - const errorMessage = response.data.errors[0].message; - setErrorMsg(errorMessage); - } else if (resData === null) { - setErrorMsg("Unable to upload partner certificate"); + if (response !== null) { + const resData = response.data.response; + if (response.data.errors && response.data.errors.length > 0) { + const errorMessage = response.data.errors[0].message; + setErrorMsg(errorMessage); + } else if (resData === null) { + setErrorMsg("Unable to upload partner certificate"); + } else { + setUploadSuccess(true); + } } else { - setUploadSuccess(true); + setErrorMsg("There is some error in uploading the certificate. Try again later!"); } + setDataLoaded(true); } catch (err) { setErrorMsg(err); console.log("Unable to upload partner certificate: ", err); @@ -131,185 +138,202 @@ function UploadCertificate({ closePopup, partnerData }) { return (
Please select the fields and upload certificate.
-