From d40f8d98d7346745bf2cf596d2bab830b07aad1c Mon Sep 17 00:00:00 2001 From: Shivankshuklaa Date: Mon, 1 Jul 2024 11:57:16 +0530 Subject: [PATCH] Architect and citizen consent format corrected, Dropdowns are started coming from MDMS instead of locally --- .../pageComponents/BPANewBuildingdetails.js | 167 +++++++++--------- .../obps/src/pageComponents/OwnerDetails.js | 6 + .../BpaApplicationDetail/CitizenConsent.js | 111 ++---------- .../citizen/BpaApplicationDetail/index.js | 9 +- .../NewBuildingPermit/Architectconcent.js | 115 ++---------- .../citizen/NewBuildingPermit/CheckPage.js | 8 +- .../packages/modules/obps/src/utils/index.js | 1 + 7 files changed, 134 insertions(+), 283 deletions(-) diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/BPANewBuildingdetails.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/BPANewBuildingdetails.js index 3a1dea840b9..97161eb62f8 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/BPANewBuildingdetails.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/BPANewBuildingdetails.js @@ -93,9 +93,6 @@ }, [files]); - - - const approvedcolonyStatus = [ { code: "YES", @@ -110,20 +107,7 @@ i18nKey: "LAL LAKEER" } ] - const ratingvalue = [ - { - code: "PLATINUM", - i18nKey: "PLATINUM" - }, - { - code: "GOLD", - i18nKey: "GOLD" - }, - { - code: "BRONZE", - i18nKey: "BRONZE" - } - ] + const common = [ { @@ -143,64 +127,12 @@ } ] - const schemesselectiontype = [ - { - code: "SCHEME", - i18nKey: "SCHEME" - }, - { - code: "NON_SCHEME", - i18nKey: "NON SCHEME" - }, - ] - - const forschemes = [ - { - code: "TP_SCHEMES", - i18nKey: "TP SCHEMES" - }, - { - code: "DEVELOPMENT_SCHEMES", - i18nKey: "DEVELOPMENT SCHEMES" - }, - { - code: "AFFORDABLE", - i18nKey: "AFFORDABLE" - } - ] - - const status = [ - { - code: "AUTHORIZED", - i18nKey: "Authorized" - }, - { - code: "REGULARIZED", - i18nKey: "Regularized" - } - ] - - const masterdropfields = [ - { - code: "RESIDENT", - i18nKey: "Resident" - }, - { - code: "COMMERCIAL", - i18nKey: "Commercial" - }, - { - code: "INDUSTRIAL", - i18nKey: "Industrial" - } - ] - const tenantId = Digit.ULBService.getCurrentTenantId(); const stateId = Digit.ULBService.getStateId(); - const { data: ULBLIST } = Digit.Hooks.obps.useUlbType(stateId, "BPA", "UlbType"); + const { data: ulbList } = Digit.Hooks.obps.useUlbType(stateId, "BPA", "UlbType"); - const { data: Menu } = Digit.Hooks.obps.useDistricts(stateId, "BPA", "Districts"); + const { data: districtMenu } = Digit.Hooks.obps.useDistricts(stateId, "BPA", "Districts"); const { data: ULB } = Digit.Hooks.obps.useULBList(stateId, "BPA", "Ulb"); let ulblists = []; @@ -208,23 +140,23 @@ let menu = []; let ulb = []; - ULBLIST && - ULBLIST.map((ulbtypelist) => { + ulbList && + ulbList.map((ulbtypelist) => { if(ulbtypelist?.Districts === UlbName?.code) - ulblists.push({ i18nKey: `${ulbtypelist.code}`, code: `${ulbtypelist.code}`, value: `${ulbtypelist.name}` }); + ulblists.push({ i18nKey: `${ulbtypelist.name}`, code: `${ulbtypelist.code}`, value: `${ulbtypelist.name}` }); }); - Menu && - Menu.map((districts) => { + districtMenu && + districtMenu.map((districts) => { // if(districts.UlbType == Ulblisttype?.code) - menu.push({ i18nKey: `${districts.code}`, code: `${districts.code}`, value: `${districts.name}` }); + menu.push({ i18nKey: `${districts.name}`, code: `${districts.code}`, value: `${districts.name}` }); }); ULB && ULB.map((ulblist) => { if (ulblist.Districts == UlbName?.code) { ulb.push({ - i18nKey: `${ulblist.code}`, + i18nKey: `${ulblist.name}`, code: `${ulblist.code}`, value: `${ulblist.name}` }); @@ -232,6 +164,75 @@ }); + + // Custom hooks to get the Data directly from MDMS, No need to make file inside Libraries --> Hooks Folder + + const { data: commonBuilding } = Digit.Hooks.useCustomMDMS(Digit.ULBService.getStateId(), "BPA", [{ name: "BuildingStatus" }], + { + select: (data) => { + const formattedData = data?.["BPA"]?.["BuildingStatus"] + return formattedData; + }, + }); + let building_status = []; + + commonBuilding && commonBuilding.map((selectBuilding) => { + building_status.push({i18nKey: `BPA_${selectBuilding.code}`, code: `${selectBuilding.code}`, value: `${selectBuilding.name}`}) + }) + + const { data: commonrating } = Digit.Hooks.useCustomMDMS(Digit.ULBService.getStateId(), "BPA", [{ name: "RatingValue" }], + { + select: (data) => { + const formattedData = data?.["BPA"]?.["RatingValue"] + return formattedData; + }, + }); + let selectRating = []; + + commonrating && commonrating.map((selectRatings) => { + selectRating.push({i18nKey: `BPA_${selectRatings.code}`, code: `${selectRatings.code}`, value: `${selectRatings.name}`}) + }) + + const { data: commonmasterFields } = Digit.Hooks.useCustomMDMS(Digit.ULBService.getStateId(), "BPA", [{ name: "MasterFields" }], + { + select: (data) => { + const formattedData = data?.["BPA"]?.["MasterFields"] + return formattedData; + }, + }); + let selectmasterDrop = []; + + commonmasterFields && commonmasterFields.map((selectMaster) => { + selectmasterDrop.push({i18nKey: `BPA_${selectMaster.code}`, code: `${selectMaster.code}`, value: `${selectMaster.name}`}) + }) + + const { data: commonScheme } = Digit.Hooks.useCustomMDMS(Digit.ULBService.getStateId(), "BPA", [{ name: "Scheme" }], + { + select: (data) => { + const formattedData = data?.["BPA"]?.["Scheme"] + return formattedData; + }, + }); + let selectscheme = []; + + commonScheme && commonScheme.map((selectScheme) => { + selectscheme.push({i18nKey: `BPA_${selectScheme.code}`, code: `${selectScheme.code}`, value: `${selectScheme.name}`}) + }) + + const { data: commonSchemeType } = Digit.Hooks.useCustomMDMS(Digit.ULBService.getStateId(), "BPA", [{ name: "SchemeType" }], + { + select: (data) => { + const formattedData = data?.["BPA"]?.["SchemeType"] + return formattedData; + }, + }); + let selectschemetypes = []; + + commonSchemeType && commonSchemeType.map((selectscheme) => { + selectschemetypes.push({i18nKey: `BPA_${selectscheme.code}`, code: `${selectscheme.code}`, value: `${selectscheme.name}`}) + }) + + const { control } = useForm(); @@ -464,7 +465,7 @@ className="form-field" selected={rating} select={setrating} - option={ratingvalue} + option={selectRating} optionKey="i18nKey" t={t} /> @@ -497,7 +498,7 @@ className="form-field" selected={use} select={setUse} - option={masterdropfields} + option={selectmasterDrop} optionKey="i18nKey" t={t} /> @@ -531,7 +532,7 @@ className="form-field" selected={schemesselection} select={setSchemeselection} - option={forschemes} + option={selectschemetypes} optionKey="i18nKey" t={t} /> @@ -732,7 +733,7 @@ className="form-field" selected={buildingStatus} select={setbuildingStatus} - option={status} + option={building_status} optionKey="i18nKey" t={t} /> @@ -750,7 +751,7 @@ className="form-field" selected={schemes} select={setschemes} - option={schemesselectiontype} + option={selectscheme} optionKey="i18nKey" t={t} /> diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/OwnerDetails.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/OwnerDetails.js index 03f14a2baaa..c240fade84d 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/OwnerDetails.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/pageComponents/OwnerDetails.js @@ -33,6 +33,9 @@ const OwnerDetails = ({ t, config, onSelect, userType, formData }) => { (formData?.owners && formData?.owners?.owners) || [{ name: "", gender: "", mobileNumber: null, isPrimaryOwner: true }] ); + const user = Digit.UserService.getUser(); + console.log("userrrr",user); + useEffect(() => { var flag=0; fields.map((ob) => { @@ -387,6 +390,9 @@ const OwnerDetails = ({ t, config, onSelect, userType, formData }) => { if (formData?.owners?.greenuploadedFile) payload.additionalDetails.uploadedFileGreenBuilding = formData?.owners?.greenuploadedFile; if (formData?.owners?.use?.code) payload.additionalDetails.use = formData?.owners?.use?.code; + //adding Architect name and his mobilenumber so that i can use it in Consent form + if (user?.info?.name) payload.additionalDetails.architectName = user?.info?.name; + if (user?.info?.mobileNumber) payload.additionalDetails.architectMobileNumber = user?.info?.mobileNumber; //For LandInfo payload.landInfo = {}; 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 386c6c8e8e6..bebbf71a271 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 @@ -119,104 +119,25 @@ const uploadSelfDeclaration = async () => { try { setIsUploading(true); // Set isUploading to true before starting the upload - const doc = new jsPDF(); - const leftMargin = 15; - const topMargin = 10; - const lineSpacing = 5; - const pageWidth = doc.internal.pageSize.getWidth(); - const maxLineWidth = pageWidth - 2 * leftMargin; - - let currentY = topMargin; - - doc.setFont("Times-Roman"); - doc.setFontSize(12); - - // Split and write text into the PDF - const lines = selfdeclarationform.split("\n"); - // lines.forEach((line) => { - // const wrappedLines = doc.splitTextToSize(line, maxLineWidth); - // wrappedLines.forEach((wrappedLine) => { - // if (currentY + lineSpacing > doc.internal.pageSize.getHeight() - topMargin) { - // doc.addPage(); - // currentY = topMargin; - // } - // doc.text(leftMargin, currentY, wrappedLine); - // currentY += lineSpacing; - // }); - // }); - lines.forEach((line) => { - const segments = line.split(/(|<\/b>)/g); // Split line by and tags - let isBold = false; - let currentX = leftMargin; - - segments.forEach((segment) => { - if (segment === "") { - isBold = true; - } else if (segment === "") { - isBold = false; - } else { - const words = segment.split(' '); - words.forEach((word, index) => { - const wordWithSpace = index < words.length - 1 ? `${word} ` : word; - const textWidth = doc.getTextWidth(wordWithSpace); - - if (currentX + textWidth > maxLineWidth) { - currentY += lineSpacing; - currentX = leftMargin; - if (currentY + lineSpacing > doc.internal.pageSize.getHeight() - topMargin) { - doc.addPage(); - currentY = topMargin; - } - } - - doc.setFont(isBold ? "Times-Bold" : "Times-Roman"); - doc.text(currentX, currentY, wordWithSpace); - currentX += textWidth; - }); - } - }); - - currentY += lineSpacing; - if (currentY + lineSpacing > doc.internal.pageSize.getHeight() - topMargin) { - doc.addPage(); - currentY = topMargin; + + let result = await Digit.PaymentService.generatePdf(Digit.ULBService.getStateId(), { Bpa: [data] }, "ownerconsent"); + + if (result?.filestoreIds[0]?.length > 0) { + alert("File Uploaded Successfully"); + sessionStorage.setItem("CitizenConsentdocFilestoreid",result?.filestoreIds[0]); + setIsFileUploaded(true); // Set isFileUploaded to true on successful upload + } else { + alert("File Upload Failed"); } - }); - - - // Convert the PDF to a Blob - - const pdfBlob = doc.output("blob", "declaration.pdf"); - - // Prepare FormData for the upload - const formData = new FormData(); - formData.append("file", pdfBlob, "declaration.pdf"); - formData.append("tenantId", "pg"); - formData.append("module", "BPA"); + } catch (error) { + alert("Error Uploading PDF:", error); // Error handling + } + finally { + setIsUploading(false); // Set isUploading to false after the upload is complete + } +}; - - const response = await Axios({ - method: "post", - url: `${Urls.FileStore}`, - data: formData, - headers: { "auth-token": Digit.UserService.getUser()?.access_token }, - }); - 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 - } - finally { - setIsUploading(false); // Set isUploading to false after the upload is complete - } -}; - const modalStyles = { 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 568eb6ef814..04506d51e90 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 @@ -140,7 +140,9 @@ const BpaApplicationDetail = () => { if (response.ResponseInfo.status==="Access Token generated successfully") { setIsOTPVerified(true); setOTPError(t("VERIFIED")); - setOTPVerifiedTimestamp(new Date()); + const currentTimestamp = new Date(); + setOTPVerifiedTimestamp(currentTimestamp); + sessionStorage.setItem('otpVerifiedTimestampcitizen', currentTimestamp.toISOString()); } else { setIsOTPVerified(false); setOTPError(t("WRONG OTP")); @@ -383,6 +385,7 @@ const BpaApplicationDetail = () => { const updatedApplicationData = { ...data?.applicationData, documents: updatedDocuments, + additionalDetails: sessionStorage.getItem("otpVerifiedTimestampcitizen") }; mutation.mutate( @@ -789,7 +792,7 @@ const BpaApplicationDetail = () => {
{t("ARCHITECT_SHOULD_VERIFY_HIMSELF_BY_CLICKING_BELOW_BUTTON")} - +

{showMobileInput && ( @@ -806,7 +809,7 @@ const BpaApplicationDetail = () => { {...{ required: true, pattern: "[0-9]{10}", type: "tel", title: t('CORE_COMMON_APPLICANT_MOBILE_NUMBER_INVALID') }} /> - + )} {showOTPInput && ( 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 a4059fdf4d0..01b6125d197 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 @@ -17,12 +17,10 @@ */ import React, { useState } from 'react'; import Modal from 'react-modal'; - import jsPDF from 'jspdf'; import { useLocation } from "react-router-dom"; - import { SubmitBar, CitizenConsentForm } from '@upyog/digit-ui-react-components'; + import { SubmitBar } from '@upyog/digit-ui-react-components'; import { useTranslation } from "react-i18next"; - import Axios from "axios"; - import Urls from '../../../../../../libraries/src/services/atoms/urls'; + @@ -35,6 +33,7 @@ const architecname = user?.info?.name; const architectmobileNumber = user?.info.mobileNumber const [params] = Digit.Hooks.useSessionStorage("BUILDING_PERMIT", state?.edcrNumber ? { data: { scrutinyNumber: { edcrNumber: state?.edcrNumber } } } : {}); + console.log("paramdkjagdew",params); 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; @@ -149,103 +148,21 @@ const uploadSelfDeclaration = async () => { try { setIsUploading(true); // Set isUploading to true before starting the upload - const doc = new jsPDF(); - const leftMargin = 15; - const topMargin = 10; - const lineSpacing = 4.6; // Adjusted for Better Spacing - const pageWidth = doc.internal.pageSize.getWidth(); - const maxLineWidth = pageWidth - 2 * leftMargin; - - let currentY = topMargin; - - doc.setFont("Times-Roman"); - doc.setFontSize(12); - - // Split and write text into the PDF - const lines = selfdeclarationform.split("\n"); - // lines.forEach((line) => { - - - // const wrappedLines = doc.splitTextToSize(line, maxLineWidth); - // wrappedLines.forEach((wrappedLine) => { - // if (currentY + lineSpacing > doc.internal.pageSize.getHeight() - topMargin) { - // doc.addPage(); - // currentY = topMargin; - // } - // doc.text(leftMargin, currentY, wrappedLine); - // currentY += lineSpacing; - // }); - // }); - lines.forEach((line) => { - const segments = line.split(/(|<\/b>)/g); // Split line by and tags - let isBold = false; - let currentX = leftMargin; - - segments.forEach((segment) => { - if (segment === "") { - isBold = true; - } else if (segment === "") { - isBold = false; - } else { - const words = segment.split(' '); - words.forEach((word, index) => { - const wordWithSpace = index < words.length - 1 ? `${word} ` : word; - const textWidth = doc.getTextWidth(wordWithSpace); - - if (currentX + textWidth > maxLineWidth) { - currentY += lineSpacing; - currentX = leftMargin; - if (currentY + lineSpacing > doc.internal.pageSize.getHeight() - topMargin) { - doc.addPage(); - currentY = topMargin; - } - } - - doc.setFont(isBold ? "Times-Bold" : "Times-Roman"); - doc.text(currentX, currentY, wordWithSpace); - currentX += textWidth; - }); - } - }); - - currentY += lineSpacing; - if (currentY + lineSpacing > doc.internal.pageSize.getHeight() - topMargin) { - doc.addPage(); - currentY = topMargin; + let result = await Digit.PaymentService.generatePdf(Digit.ULBService.getStateId(), { Bpa: [params] }, "architectconsent"); + + if (result?.filestoreIds[0]?.length > 0) { + alert("File Uploaded Successfully"); + sessionStorage.setItem("ArchitectConsentdocFilestoreid",result?.filestoreIds[0]); + setIsFileUploaded(true); // Set isFileUploaded to true on successful upload + } else { + alert("File Upload Failed"); } - }); - // Convert the PDF to a Blob - - - const pdfBlob = doc.output("blob", "declaration.pdf"); - - // Prepare FormData for the upload - const formData = new FormData(); - formData.append("file", pdfBlob, "declaration.pdf"); - formData.append("tenantId", "pg"); - formData.append("module", "BPA"); - - - const response = await Axios({ - method: "post", - url: `${Urls.FileStore}`, - data: formData, - headers: { "auth-token": Digit.UserService.getUser()?.access_token }, - }); - - 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 } - } catch (error) { - alert("Error Uploading PDF:", error); // Error handling - } - finally { - setIsUploading(false); // Set isUploading to false after the upload is complete - } }; 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 2773f7a4b48..1256b647eae 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 @@ -152,7 +152,9 @@ import { if (response.ResponseInfo.status==="Access Token generated successfully") { setIsOTPVerified(true); setOTPError(t("VERIFIED")); - setOTPVerifiedTimestamp(new Date()); + const currentTimestamp = new Date(); + setOTPVerifiedTimestamp(currentTimestamp); + sessionStorage.setItem('otpVerifiedTimestamp', currentTimestamp.toISOString()); } else { setIsOTPVerified(false); setOTPError(t("WRONG OTP")); @@ -711,7 +713,7 @@ function selectfile(e) { {value?.status==="INITIATED" && (
{t("ARCHITECT_SHOULD_VERIFY_HIMSELF_BY_CLICKING_BELOW_BUTTON")} - +

{showMobileInput && ( @@ -728,7 +730,7 @@ function selectfile(e) { {...{ required: true, pattern: "[0-9]{10}", type: "tel", title: t('CORE_COMMON_APPLICANT_MOBILE_NUMBER_INVALID') }} /> - + )}

diff --git a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/utils/index.js b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/utils/index.js index 21a35f45e9b..986ef20b5cc 100644 --- a/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/utils/index.js +++ b/frontend/micro-ui/web/micro-ui-internals/packages/modules/obps/src/utils/index.js @@ -483,6 +483,7 @@ export const convertToBPAObject = (data, isOCBPA = false, isSendBackTOCitizen = auditDetails: data?.auditDetails, additionalDetails: { ...data?.additionalDetails, + OTPverfiedTimeSamp: sessionStorage.getItem("otpVerifiedTimestamp"), otherFeesDiscription:sessionStorage.getItem("otherChargesDisc"), lessAdjustmentFeeFiles:JSON.parse(sessionStorage.getItem("uploadedFileLess")), selfCertificationCharges:{