From 84e66d560338f5ab3d73b0766ba6d7cd70edea4c Mon Sep 17 00:00:00 2001 From: Shivankshuklaa Date: Tue, 21 May 2024 10:50:02 +0530 Subject: [PATCH] Architect and Citizen Undertaking Disable Button issue and latitude and longitude issue resolved --- .../src/pageComponents/DocumentDetails.js | 18 ++++++++-- .../citizen/ArchitectInbox/ApplicationCard.js | 2 +- .../BpaApplicationDetail/CitizenConsent.js | 16 ++++++--- .../citizen/BpaApplicationDetail/index.js | 35 +++++++++++++------ .../NewBuildingPermit/Architectconcent.js | 10 ++++-- .../citizen/NewBuildingPermit/CheckPage.js | 9 ++++- 6 files changed, 69 insertions(+), 21 deletions(-) diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/DocumentDetails.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/DocumentDetails.js index 813493eadaf..b38b8e9b5d0 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/DocumentDetails.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/DocumentDetails.js @@ -50,6 +50,10 @@ const DocumentDetails = ({ t, config, onSelect, userType, formData, setError: se const [enableSubmit, setEnableSubmit] = useState(true) const [checkRequiredFields, setCheckRequiredFields] = useState(false); const checkingFlow = formData?.uiFlow?.flow; + + const [isNextButtonDisabled, setIsNextButtonDisabled] = useState(false); + + const beforeUploadDocuments = cloneDeep(formData?.PrevStateDocuments || []); const {data: bpaTaxDocuments, isLoading} = Digit.Hooks.obps.useBPATaxDocuments(stateId, formData, beforeUploadDocuments || []); const handleSubmit = () => { @@ -93,7 +97,8 @@ const DocumentDetails = ({ t, config, onSelect, userType, formData, setError: se config={config} onSelect={handleSubmit} onSkip={onSkip} - isDisabled={window.location.href.includes("editApplication")||window.location.href.includes("sendbacktocitizen")?false:enableSubmit} + // isDisabled={window.location.href.includes("editApplication")||window.location.href.includes("sendbacktocitizen")?false:enableSubmit} + isDisabled={(window.location.href.includes("editApplication") || window.location.href.includes("sendbacktocitizen") ? false : enableSubmit) || isNextButtonDisabled} onAdd={onAdd} > {/* {bpaTaxDocuments?.map((document, index) => { */} @@ -111,6 +116,8 @@ const DocumentDetails = ({ t, config, onSelect, userType, formData, setError: se setCheckRequiredFields={setCheckRequiredFields} formData={formData} beforeUploadDocuments={beforeUploadDocuments || []} + isNextButtonDisabled={isNextButtonDisabled} + setIsNextButtonDisabled={setIsNextButtonDisabled} /> ); @@ -131,7 +138,8 @@ const SelectDocument = React.memo(function MyComponent({ documents, setCheckRequiredFields, formData, - beforeUploadDocuments + beforeUploadDocuments, + setIsNextButtonDisabled // Add this line }) { const filteredDocument = documents?.filter((item) => item?.documentType?.includes(doc?.code))[0] || beforeUploadDocuments?.filter((item) => item?.documentType?.includes(doc?.code))[0]; const tenantId = Digit.ULBService.getStateId(); //Digit.ULBService.getCurrentTenantId(); @@ -408,10 +416,14 @@ const SelectDocument = React.memo(function MyComponent({

Latitude: {latitude}

Longitude: {longitude}

+ {setIsNextButtonDisabled(false)} {/* Enable the "Next" button */}
): ( -

Please upload a Photo with Location details.

+
+

Please upload a Photo with Location details.

+ {setIsNextButtonDisabled(true)} {/* Disable the "Next" button */} +
) )} diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/ArchitectInbox/ApplicationCard.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/ArchitectInbox/ApplicationCard.js index 779ab961a68..29dd8a41553 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/ArchitectInbox/ApplicationCard.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/ArchitectInbox/ApplicationCard.js @@ -117,7 +117,7 @@ const ApplicationCard = ({ )} {type === "SORT" && (
- {} + {}
)} diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/BpaApplicationDetail/CitizenConsent.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/BpaApplicationDetail/CitizenConsent.js index 0c3bfbb6612..0927cfe6369 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/BpaApplicationDetail/CitizenConsent.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/BpaApplicationDetail/CitizenConsent.js @@ -31,6 +31,9 @@ enabled: !!data } }); + + const [isUploading, setIsUploading] = useState(false); // it will check whether the file upload is in process or not + const [isFileUploaded, setIsFileUploaded] = useState(false); const architectname = workflowDetails?.data?.timeline?.[0]?.assigner?.name const mobileNumber = workflowDetails?.data?.timeline?.[0]?.assigner?.mobileNumber const khasranumber = data?.applicationData?.additionalDetails?.khasraNumber; @@ -92,6 +95,7 @@ const uploadSelfDeclaration = async () => { try { + setIsUploading(true); // Set isUploading to true before starting the upload const doc = new jsPDF(); const leftMargin = 15; const topMargin = 10; @@ -138,12 +142,16 @@ if (response?.data?.files?.length > 0) { alert("File Uploaded Successfully"); sessionStorage.setItem("CitizenConsentdocFilestoreid",response?.data?.files[0]?.fileStoreId); + setIsFileUploaded(true); // Set isFileUploaded to true on successful upload } else { alert("File Upload Failed"); } - } catch (error) { - alert("Error Uploading PDF:", error); // Error handling - } + } catch (error) { + alert("Error Uploading PDF:", error); // Error handling + } + finally { + setIsUploading(false); // Set isUploading to false after the upload is complete + } }; @@ -217,7 +225,7 @@



- + diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/BpaApplicationDetail/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/BpaApplicationDetail/index.js index 198d536850e..6307017aec2 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/BpaApplicationDetail/index.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/BpaApplicationDetail/index.js @@ -153,6 +153,7 @@ const BpaApplicationDetail = () => { }; const isValidMobileNumber = mobileNumber.length === 10 && /^[0-9]+$/.test(mobileNumber); + const citizenvalidations = sessionStorage.getItem("CitizenConsentdocFilestoreid") ? true : false ; let businessService = []; @@ -304,8 +305,7 @@ const BpaApplicationDetail = () => { else return false; } - const Citizenconsentform = sessionStorage.getItem("CitizenConsentdocFilestoreid"); - console.log("Citizenconsentform",Citizenconsentform); + // const submitAction = (workflow) => { // setIsEnableLoader(true); @@ -331,17 +331,32 @@ const BpaApplicationDetail = () => { // ); // } + + const submitAction = (workflow) => { setIsEnableLoader(true); - // Create a new array with the existing documents and the new Citizenconsentform + // Check if "CITIZEN.UNDERTAKING" document already exists + const citizenUndertakingExists = data?.applicationData?.documents?.some( + (doc) => doc.documentType === "CITIZEN.UNDERTAKING" + ); + + // Create a new array with the existing documents and the new Citizenconsentform (if it doesn't exist) const updatedDocuments = [ - ...data?.applicationData?.documents, - { - documentType: "CITIZEN.UNDERTAKING", - fileStoreId: sessionStorage.getItem("CitizenConsentdocFilestoreid"), - fileStore: sessionStorage.getItem("CitizenConsentdocFilestoreid"), - }, + ...data?.applicationData?.documents.filter( + (doc) => doc.documentType !== "CITIZEN.UNDERTAKING" + ), + ...(citizenUndertakingExists + ? data?.applicationData?.documents.filter( + (doc) => doc.documentType === "CITIZEN.UNDERTAKING" + ) + : [ + { + documentType: "CITIZEN.UNDERTAKING", + fileStoreId: sessionStorage.getItem("CitizenConsentdocFilestoreid"), + fileStore: sessionStorage.getItem("CitizenConsentdocFilestoreid"), + }, + ]), ]; // Update the applicationData object with the new documents array @@ -715,7 +730,7 @@ const BpaApplicationDetail = () => { onSelect={onActionSelect} /> ) : null} - setDisplayMenu(!displayMenu)} /> + setDisplayMenu(!displayMenu)} /> )} diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/NewBuildingPermit/Architectconcent.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/NewBuildingPermit/Architectconcent.js index 50713c98540..cc0d8943fd1 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/NewBuildingPermit/Architectconcent.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/NewBuildingPermit/Architectconcent.js @@ -36,7 +36,8 @@ const architectmobileNumber = user?.info.mobileNumber const [params] = Digit.Hooks.useSessionStorage("BUILDING_PERMIT", state?.edcrNumber ? { data: { scrutinyNumber: { edcrNumber: state?.edcrNumber } } } : {}); - + const [isUploading, setIsUploading] = useState(false); // it will check whether the file upload is in process or not + const [isFileUploaded, setIsFileUploaded] = useState(false); const architectid = params?.additionalDetails?.architectid; const ownername = params?.owners?.owners?.[0]?.name; const architecttype = params?.additionalDetails?.typeOfArchitect; @@ -120,6 +121,7 @@ const uploadSelfDeclaration = async () => { try { + setIsUploading(true); // Set isUploading to true before starting the upload const doc = new jsPDF(); const leftMargin = 15; const topMargin = 10; @@ -166,12 +168,16 @@ if (response?.data?.files?.length > 0) { alert("File Uploaded Successfully"); sessionStorage.setItem("ArchitectConsentdocFilestoreid",response?.data?.files[0]?.fileStoreId); + setIsFileUploaded(true); // Set isFileUploaded to true on successful upload } else { alert("File Upload Failed"); } } catch (error) { alert("Error Uploading PDF:", error); // Error handling } + finally { + setIsUploading(false); // Set isUploading to false after the upload is complete + } }; @@ -250,7 +256,7 @@



- + diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/NewBuildingPermit/CheckPage.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/NewBuildingPermit/CheckPage.js index 14427869f43..6974cf09145 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/NewBuildingPermit/CheckPage.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pages/citizen/NewBuildingPermit/CheckPage.js @@ -53,6 +53,13 @@ import { setAgree(!agree); }; + + + + + + const Architectvalidations = sessionStorage.getItem("ArchitectConsentdocFilestoreid") ? true : false ; + @@ -754,7 +761,7 @@ function selectfile(e) {
{/* {t("BPA_COMMON_TOTAL_AMT")} ₹ {paymentDetails?.Bill?.[0]?.billDetails[0]?.amount || "0"} */} - + );