Skip to content

Commit

Permalink
Merge pull request #38 from ShivankShuklaa/Dev-2.0
Browse files Browse the repository at this point in the history
Architect and Citizen Undertaking Disable Button issue and latitude and longitude issue resolved
  • Loading branch information
abhijniua authored May 21, 2024
2 parents c678e9b + 84e66d5 commit 88135e5
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = () => {
Expand Down Expand Up @@ -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) => { */}
Expand All @@ -111,6 +116,8 @@ const DocumentDetails = ({ t, config, onSelect, userType, formData, setError: se
setCheckRequiredFields={setCheckRequiredFields}
formData={formData}
beforeUploadDocuments={beforeUploadDocuments || []}
isNextButtonDisabled={isNextButtonDisabled}
setIsNextButtonDisabled={setIsNextButtonDisabled}
/>
</div>
);
Expand All @@ -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();
Expand Down Expand Up @@ -408,10 +416,14 @@ const SelectDocument = React.memo(function MyComponent({
<div>
<p>Latitude: {latitude}</p>
<p>Longitude: {longitude}</p>
{setIsNextButtonDisabled(false)} {/* Enable the "Next" button */}
</div>
):
(
<p style={{ color: 'red' }}>Please upload a Photo with Location details.</p>
<div>
<p style={{ color: 'red' }}>Please upload a Photo with Location details.</p>
{setIsNextButtonDisabled(true)} {/* Disable the "Next" button */}
</div>
)
)}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ const ApplicationCard = ({
)}
{type === "SORT" && (
<div className="popup-module w-fullwidth">
{<SortBy type="mobile" sortParams={sortParams} onClose={handlePopupClose} type="mobile" onSort={onSort} />}
{<SortBy type="mobile" sortParams={sortParams} onClose={handlePopupClose} onSort={onSort} />}
</div>
)}
</PopUp>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
};


Expand Down Expand Up @@ -217,7 +225,7 @@
<SubmitBar label={t("BPA_CLOSE")} onSubmit={closeModal} />
<br></br>
<br></br>
<SubmitBar label={t("BPA_UPLOAD")} onSubmit={uploadSelfDeclaration} />
<SubmitBar label={t("BPA_UPLOAD")} onSubmit={uploadSelfDeclaration} disabled={isUploading || isFileUploaded} />
</div>
</div>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ const BpaApplicationDetail = () => {
};

const isValidMobileNumber = mobileNumber.length === 10 && /^[0-9]+$/.test(mobileNumber);
const citizenvalidations = sessionStorage.getItem("CitizenConsentdocFilestoreid") ? true : false ;


let businessService = [];
Expand Down Expand Up @@ -304,8 +305,7 @@ const BpaApplicationDetail = () => {
else return false;
}

const Citizenconsentform = sessionStorage.getItem("CitizenConsentdocFilestoreid");
console.log("Citizenconsentform",Citizenconsentform);


// const submitAction = (workflow) => {
// setIsEnableLoader(true);
Expand All @@ -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
Expand Down Expand Up @@ -715,7 +730,7 @@ const BpaApplicationDetail = () => {
onSelect={onActionSelect}
/>
) : null}
<SubmitBar /*style={{ width: "100%" }}*/ disabled={checkForSubmitDisable(isFromSendBack, isTocAccepted) || (!agree || !isOTPVerified)} label={t("ES_COMMON_TAKE_ACTION")} onSubmit={() => setDisplayMenu(!displayMenu)} />
<SubmitBar /*style={{ width: "100%" }}*/ disabled={checkForSubmitDisable(isFromSendBack, isTocAccepted) || (!agree || !isOTPVerified || !citizenvalidations)} label={t("ES_COMMON_TAKE_ACTION")} onSubmit={() => setDisplayMenu(!displayMenu)} />
</div>
</ActionBar>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
}
};


Expand Down Expand Up @@ -250,7 +256,7 @@
<SubmitBar label={t("BPA_CLOSE")} onSubmit={closeModal} />
<br></br>
<br></br>
<SubmitBar label={t("BPA_UPLOAD")} onSubmit={uploadSelfDeclaration} />
<SubmitBar label={t("BPA_UPLOAD")} onSubmit={uploadSelfDeclaration} disabled={isUploading || isFileUploaded} />
</div>
</div>
</Modal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,13 @@ import {
setAgree(!agree);
};






const Architectvalidations = sessionStorage.getItem("ArchitectConsentdocFilestoreid") ? true : false ;




Expand Down Expand Up @@ -754,7 +761,7 @@ function selectfile(e) {
<hr style={{color:"#cccccc",backgroundColor:"#cccccc",height:"2px",marginTop:"20px",marginBottom:"20px"}}/>
{/* <CardHeader>{t("BPA_COMMON_TOTAL_AMT")}</CardHeader>
<CardHeader>₹ {paymentDetails?.Bill?.[0]?.billDetails[0]?.amount || "0"}</CardHeader> */}
<SubmitBar label={t("BPA_SEND_TO_CITIZEN_LABEL")} onSubmit={onSubmitCheck} disabled={ (!development||!otherCharges||!lessAdjusment || !agree || !isOTPVerified || !otherChargesDisc)} id/>
<SubmitBar label={t("BPA_SEND_TO_CITIZEN_LABEL")} onSubmit={onSubmitCheck} disabled={ (!development||!otherCharges||!lessAdjusment || !agree || !isOTPVerified || !otherChargesDisc || !Architectvalidations)} id/>
</Card>
</React.Fragment>
);
Expand Down

0 comments on commit 88135e5

Please sign in to comment.