From 139bf5a539b9af3fd991085317f9ef68018cd0f4 Mon Sep 17 00:00:00 2001 From: SwethaKrish4 <110164892+SwethaKrish4@users.noreply.github.com> Date: Fri, 10 May 2024 13:51:38 +0530 Subject: [PATCH] MOSIP-32672: Added loading for upload and re-upload certificate (#295) * MOSIP-32672: Added loading for upload and re-upload certificate Signed-off-by: SwethaKrish4 <110164892+SwethaKrish4@users.noreply.github.com> * MOSIP-32672: Added loading for upload and re-upload certificate Signed-off-by: SwethaKrish4 <110164892+SwethaKrish4@users.noreply.github.com> --------- Signed-off-by: SwethaKrish4 <110164892+SwethaKrish4@users.noreply.github.com> --- pmp-reactjs-ui/src/pages/UploadCertificate.js | 382 ++++++++++-------- 1 file changed, 203 insertions(+), 179 deletions(-) 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.
-