diff --git a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/propertySearch.js b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/propertySearch.js index 11931f6495..f1fc481388 100644 --- a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/propertySearch.js +++ b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/propertySearch.js @@ -101,7 +101,6 @@ const screenConfig = { name: "propertySearch", beforeInitScreen: (action, state, dispatch) => { - debugger; resetFields(state, dispatch); getMDMSData(dispatch); return action; diff --git a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/searchResource/functions.js b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/searchResource/functions.js index f35fa7cd7f..cd27e17b37 100644 --- a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/searchResource/functions.js +++ b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/searchResource/functions.js @@ -78,28 +78,30 @@ export const searchApiCall = async (state, dispatch) => { // showHideProgress(true, dispatch); for (var key in searchScreenObject) { if ( - searchScreenObject.hasOwnProperty(key) && - searchScreenObject[key].trim() !== "" + searchScreenObject.hasOwnProperty(key) ) { - if (key === "fromDate") { - queryObject.push({ - key: key, - value: convertDateToEpoch(searchScreenObject[key], "daystart") - }); - } else if (key === "toDate") { - queryObject.push({ - key: key, - value: convertDateToEpoch(searchScreenObject[key], "dayend") - }); - } - // else if (key === "status") { - // queryObject.push({ - // key: "action", - // value: searchScreenObject[key].trim() - // }); - // } - else { - queryObject.push({ key: key, value: searchScreenObject[key].trim() }); + const value = searchScreenObject[key]; + if (value !== null && value !== undefined && String(value).trim() !== "") { + if (key === "fromDate") { + queryObject.push({ + key: key, + value: convertDateToEpoch(value, "daystart") + }); + } else if (key === "toDate") { + queryObject.push({ + key: key, + value: convertDateToEpoch(value, "dayend") + }); + } + // else if (key === "status") { + // queryObject.push({ + // key: "action", + // value: value.trim() + // }); + // } + else { + queryObject.push({ key: key, value: value.trim() }); + } } } } diff --git a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/searchResource/searchFunctions.js b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/searchResource/searchFunctions.js index a952a77ae7..40b34d4238 100644 --- a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/searchResource/searchFunctions.js +++ b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-common-screens/searchResource/searchFunctions.js @@ -59,10 +59,12 @@ const searchApiCall = async (state, dispatch) => { }else{ for (var key in searchScreenObject) { if ( - searchScreenObject.hasOwnProperty(key) && - searchScreenObject[key].trim() !== "" + searchScreenObject.hasOwnProperty(key) ) { - queryObject.push({ key: key, value: searchScreenObject[key].trim() }); + const value = searchScreenObject[key]; + if (value !== null && value !== undefined && String(value).trim() !== ""){ + queryObject.push({ key: key, value: searchScreenObject[key].trim() }); + } } } try { diff --git a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/functions.js b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/functions.js index e4606d023f..1486c20ca7 100644 --- a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/functions.js +++ b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/functions.js @@ -5,6 +5,8 @@ import get from "lodash/get"; import React from "react"; import { getSearchResults } from "../../../../ui-utils/commons"; import { validateFields } from "../utils/index"; +import { getTenantId,getLocale } from "egov-ui-kit/utils/localStorageUtils"; +import { fetchLocalizationLabel } from "egov-ui-kit/redux/app/actions"; export const propertySearch = async (state, dispatch) => { searchApiCall(state, dispatch, 0) @@ -161,6 +163,11 @@ const getAddress = (item) => { } const searchApiCall = async (state, dispatch, index) => { + // Ensure PT localization is loaded for toast messages + const tenantId = getTenantId(); + const locale = getLocale() || "en_IN"; + dispatch(fetchLocalizationLabel(locale, "pt", tenantId)); + showHideTable(false, dispatch, 0); showHideTable(false, dispatch, 1); @@ -193,58 +200,170 @@ const searchApiCall = async (state, dispatch, index) => { return; } - debugger; let query = { "tenantId": searchScreenObject.tenantId }; if (index == 1 && process.env.REACT_APP_NAME == "Citizen") { query = {} } + // New combination-based validation logic let formValid = false; if (index == 0) { - if (searchScreenObject.ids != '' || searchScreenObject.mobileNumber != '' || searchScreenObject.oldpropertyids != '' || searchScreenObject.locality != '' || searchScreenObject.name != '' || searchScreenObject.surveyId != '') { - formValid = true; + // Check individual field values + const hasPropertyId = searchScreenObject.ids && searchScreenObject.ids.trim() !== ""; + const hasSurveyId = searchScreenObject.surveyId && searchScreenObject.surveyId.trim() !== ""; + const hasMobileNumber = searchScreenObject.mobileNumber && searchScreenObject.mobileNumber.trim() !== ""; + const hasExistingId = searchScreenObject.oldpropertyids && searchScreenObject.oldpropertyids.trim() !== ""; + const hasOwnerName = searchScreenObject.name && searchScreenObject.name.trim() !== ""; + const hasLocality = searchScreenObject.locality !== null && searchScreenObject.locality !== undefined && String(searchScreenObject.locality).trim() !== "" + + // Check for mixed fields from different combinations + const combination1FieldsUsed = hasPropertyId || hasSurveyId || hasMobileNumber; + const combination2FieldsUsed = hasOwnerName || hasLocality || hasExistingId; + + const combinationsWithFields = [combination1FieldsUsed, combination2FieldsUsed].filter(Boolean).length; + + if (combinationsWithFields > 1) { + dispatch( + toggleSnackbar( + true, + { + labelName: "Please select fields from only one combination. You cannot mix fields from different combinations.", + labelKey: "ERR_PT_MIXED_COMBINATIONS" + }, + "error" + ) + ); + return; + } + + // Define the three valid combinations + const combination1 = hasPropertyId || hasSurveyId || hasMobileNumber; // Property ID OR Survey ID OR Mobile Number (any one) + const combination2 = hasExistingId || hasLocality || hasOwnerName; // Existing ID,Locality, or Owner Name + // Check if any valid combination is selected + const validCombinations = [combination1, combination2]; + const selectedCombinationsCount = validCombinations.filter(combo => combo).length; + + if (selectedCombinationsCount === 0) { + dispatch( + toggleSnackbar( + true, + { + labelName: "Please select one of the valid combinations: 1) Property ID or Survey ID or Mobile Number 2) Existing Property ID, Locality, or Owner Name ", + labelKey: "ERR_PT_SELECT_VALID_COMBINATION" + }, + "error" + ) + ); + return; } - // Additional validation: If only owner name is filled, require at least one other field - const hasOwnerName = - searchScreenObject.name && searchScreenObject.name.trim() !== ""; - const hasOtherFields = - (searchScreenObject.ids && searchScreenObject.ids.trim() !== "") || - (searchScreenObject.mobileNumber &&searchScreenObject.mobileNumber.trim() !== "") || - (searchScreenObject.oldpropertyids &&searchScreenObject.oldpropertyids.trim() !== "") || - (searchScreenObject.locality &&searchScreenObject.locality.trim() !== "") || - (searchScreenObject.surveyId &&searchScreenObject.surveyId.trim() !== ""); - - if (hasOwnerName && !hasOtherFields) { + + if (selectedCombinationsCount > 1) { dispatch( toggleSnackbar( true, { - labelName: - "Please provide at least one additional field (Property ID, Mobile Number, Existing Property ID, Locality, or Survey ID)", - labelKey: "ERR_PT_OWNER_NAME_REQUIRES_ADDITIONAL_FIELD", + labelName: "Please select fields from only one combination. You cannot mix fields from different combinations.", + labelKey: "ERR_PT_MULTIPLE_COMBINATIONS_SELECTED" }, "error" ) ); return; } + + // Validate specific combination requirements + if (combination1) { + // Combination 1: Either Property ID OR Survey ID or Mobile Number (not all required) + if (!hasPropertyId && !hasSurveyId && !hasMobileNumber) { + dispatch( + toggleSnackbar( + true, + { + labelName: "For Combination 1, either Property Tax Unique ID or Survey ID or Mobile Number is required", + labelKey: "ERR_PT_COMBINATION1_INCOMPLETE" + }, + "error" + ) + ); + return; + } + // Check if any other fields from different combinations are filled + if (hasExistingId && hasOwnerName && hasLocality) { + dispatch( + toggleSnackbar( + true, + { + labelName: "Please use only Property Tax Unique ID or Survey ID or Mobile Number for this combination", + labelKey: "ERR_PT_COMBINATION1_MIXED_FIELDS" + }, + "error" + ) + ); + return; + } + } else if (combination2) { + // Special validation: if Owner Name is filled, Locality must also be filled + if (hasOwnerName && !hasLocality) { + dispatch( + toggleSnackbar( + true, + { + labelName: "When Owner Name is selected, Locality is mandatory", + labelKey: "ERR_PT_OWNER_NAME_REQUIRES_LOCALITY" + }, + "error" + ) + ); + return; + } + if (hasLocality && !hasOwnerName) { + dispatch( + toggleSnackbar( + true, + { + labelName: "When Locality is selected, Owner Name is mandatory", + labelKey: "ERR_PT_OLOCALITY_REQUIRES_OWNER_NAME" + }, + "error" + ) + ); + return; + } + // Check if any other fields from different combinations are filled + if (hasPropertyId || hasSurveyId || hasMobileNumber) { + dispatch( + toggleSnackbar( + true, + { + labelName: "Please only use Existing Property ID, Locality, or Owner Name + Locality for this combination", + labelKey: "ERR_PT_COMBINATION3_MIXED_FIELDS" + }, + "error" + ) + ); + return; + } + } + + formValid = true; } else { + // For application search (index == 1), keep existing logic if (searchScreenObject.ids != '' || searchScreenObject.mobileNumber != '' || searchScreenObject.acknowledgementIds != '' || searchScreenObject.locality != '' || searchScreenObject.name != '' || searchScreenObject.surveyId != '') { formValid = true; } - } - if (!formValid) { - dispatch( - toggleSnackbar( - true, - { - labelName: "Please fill valid fields to search", - labelKey: "ERR_PT_FILL_VALID_FIELDS" - }, - "error" - ) - ); - return; + if (!formValid) { + dispatch( + toggleSnackbar( + true, + { + labelName: "Please fill valid fields to search", + labelKey: "ERR_PT_FILL_VALID_FIELDS" + }, + "error" + ) + ); + return; + } } let form1 = validateFields("components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails", state, dispatch, "propertySearch"); let form2 = validateFields("components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[1].tabContent.searchApplicationDetails", state, dispatch, "propertySearch"); @@ -370,18 +489,22 @@ const searchApiCall = async (state, dispatch, index) => { removeValidation(state, dispatch, index); for (var key in searchScreenObject) { if ( - searchScreenObject.hasOwnProperty(key) && - searchScreenObject[key].trim() !== "" + searchScreenObject.hasOwnProperty(key) ) { - if (key === "tenantId") { + const value = searchScreenObject[key]; + if (value !== null && value !== undefined && String(value).trim() !== "") { + if (key === "tenantId") { + + } + else if (key === "ids") { + query["propertyIds"] = searchScreenObject[key].trim(); + } + else { + query[key] = searchScreenObject[key].trim(); + } } - else if (key === "ids") { - query["propertyIds"] = searchScreenObject[key].trim(); - } - else { - query[key] = searchScreenObject[key].trim(); - } + } } let queryObject = []; diff --git a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/mutation-methods.js b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/mutation-methods.js index 2cdcc79b90..e7270e647a 100644 --- a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/mutation-methods.js +++ b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/mutation-methods.js @@ -1,4 +1,3 @@ - import { getTextField, getSelectField, @@ -18,11 +17,12 @@ import { propertySearch, applicationSearch, dumm } from "./functions"; export const resetFields = (state, dispatch) => { + // Reset ULB City field if (process.env.REACT_APP_NAME == "Citizen") { dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.ulbCityContainer.children.ulbCity", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.mandatorySection.children.ulbCity", "props.value", "" ) @@ -35,7 +35,7 @@ export const resetFields = (state, dispatch) => { dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.ulbCityContainer.children.ulbCity", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.mandatorySection.children.ulbCity", "props.isDisabled", false ) @@ -43,16 +43,16 @@ export const resetFields = (state, dispatch) => { dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.ulbCityContainer.children.ulbCity", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.mandatorySection.children.ulbCity", "isDisabled", false ) ); - }else{ + } else { dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.ulbCityContainer.children.ulbCity", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.mandatorySection.children.ulbCity", "props.isDisabled", true ) @@ -60,17 +60,18 @@ export const resetFields = (state, dispatch) => { dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.ulbCityContainer.children.ulbCity", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.mandatorySection.children.ulbCity", "isDisabled", true ) ); } + // Reset Combination 1 fields (Property Tax Unique ID + Survey ID + Mobile Number) dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.ulbCityContainer.children.ownerMobNo", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.propertyTaxUniqueId", "props.value", "" ) @@ -78,23 +79,26 @@ export const resetFields = (state, dispatch) => { dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.ulbCityContainer.children.propertyTaxUniqueId", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.surveyId", "props.value", "" ) ); + dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.ulbCityContainer.children.existingPropertyId", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.ownerMobNo", "props.value", "" ) ); + + // Reset Combination 2 fields (Existing Property ID + Owner Name + Locality) dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[1].tabContent.searchApplicationDetails.children.cardContent.children.appNumberContainer.children.propertyTaxApplicationNo", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.existingPropertyId", "props.value", "" ) @@ -102,7 +106,7 @@ export const resetFields = (state, dispatch) => { dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[1].tabContent.searchApplicationDetails.children.cardContent.children.appNumberContainer.children.ownerMobNoProp", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.ownerName", "props.value", "" ) @@ -110,7 +114,17 @@ export const resetFields = (state, dispatch) => { dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.ulbCityContainer.children.ownerName", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.propertyMohalla", + "props.value", + [] + ) + ); + + // Reset Application Search tab fields + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[1].tabContent.searchApplicationDetails.children.cardContent.children.appNumberContainer.children.propertyTaxApplicationNo", "props.value", "" ) @@ -118,7 +132,7 @@ export const resetFields = (state, dispatch) => { dispatch( handleField( "propertySearch", - "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.ulbCityContainer.children.surveyId", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[1].tabContent.searchApplicationDetails.children.cardContent.children.appNumberContainer.children.ownerMobNoProp", "props.value", "" ) @@ -131,34 +145,15 @@ export const resetFields = (state, dispatch) => { "" ) ); - dispatch(prepareFinalObject( - "ptSearchScreen.acknowledgementIds", - '' - )) - dispatch(prepareFinalObject( - "ptSearchScreen.ids", - '' - )) - dispatch(prepareFinalObject( - "ptSearchScreen.mobileNumber", - '' - )) - dispatch(prepareFinalObject( - "ptSearchScreen.oldpropertyids", - '' - )) - dispatch(prepareFinalObject( - "ptSearchScreen.locality", - '' - )) - dispatch(prepareFinalObject( - "ptSearchScreen.name", - '' - )) - dispatch(prepareFinalObject( - "ptSearchScreen.surveyId", - '' - )) + + // Reset all state objects + dispatch(prepareFinalObject("ptSearchScreen.acknowledgementIds", '')) + dispatch(prepareFinalObject("ptSearchScreen.ids", '')) + dispatch(prepareFinalObject("ptSearchScreen.mobileNumber", '')) + dispatch(prepareFinalObject("ptSearchScreen.oldpropertyids", '')) + dispatch(prepareFinalObject("ptSearchScreen.locality", [])) + dispatch(prepareFinalObject("ptSearchScreen.name", '')) + dispatch(prepareFinalObject("ptSearchScreen.surveyId", '')) }; @@ -169,124 +164,235 @@ export const searchPropertyDetails = getCommonCard({ }), subParagraph: getCommonParagraph({ - labelName: "Provide at least one non-mandatory parameter to search for an application (In case of Search by locality and name . please select city name again)", - //labelKey: "PT_HOME_SEARCH_RESULTS_DESC" - labelKey: "Provide at least one non-mandatory parameter to search for an application (In case of search by locality and name . please select city name again)", - + labelName: "Select ULB City (mandatory), then choose ONE combination: 1) Property ID or Survey ID or Mobile Number, 2) Existing Property ID, Locality, or Owner Name + Locality", + labelKey: "PT_SEARCH_COMBINATION_DESC", } ), - ulbCityContainer: getCommonContainer({ + // Mandatory ULB City Field + mandatorySection: getCommonContainer({ ulbCity: { ...getSelectField({ - uiFramework: "custom-containers-local", - moduleName: "egov-pt", - componentPath: "AutosuggestContainer", - props: { - className: "autocomplete-dropdown", - suggestions: [], - label: { - labelName: "ULB", - labelKey: "PT_ULB_CITY" - }, - placeholder: { - labelName: "Select ULB", - labelKey: "PT_ULB_CITY_PLACEHOLDER" - }, - localePrefix: { - moduleName: "TENANT", - masterName: "TENANTS" + uiFramework: "custom-containers-local", + moduleName: "egov-pt", + componentPath: "AutosuggestContainer", + props: { + className: "autocomplete-dropdown", + suggestions: [], + label: { + labelName: "ULB (Mandatory)", + labelKey: "PT_ULB_CITY_MANDATORY" + }, + placeholder: { + labelName: "Select ULB", + labelKey: "PT_ULB_CITY_PLACEHOLDER" + }, + localePrefix: { + moduleName: "TENANT", + masterName: "TENANTS" + }, + jsonPath: "ptSearchScreen.tenantId", + sourceJsonPath: "searchScreenMdmsData.tenant.tenants", + labelsFromLocalisation: true, + required: true, + isClearable: true, + disabled: process.env.REACT_APP_NAME === "Citizen" ? false : true, + inputLabelProps: { + shrink: true + } }, + required: true, jsonPath: "ptSearchScreen.tenantId", sourceJsonPath: "searchScreenMdmsData.tenant.tenants", - labelsFromLocalisation: true, - required: true, - isClearable: true, - disabled: process.env.REACT_APP_NAME === "Citizen" ? false : true, - inputLabelProps: { - shrink: true - } - }, - required: true, - jsonPath: "ptSearchScreen.tenantId", - sourceJsonPath: "searchScreenMdmsData.tenant.tenants", - }), - beforeFieldChange: async (action, state, dispatch) => { - //Below only runs for citizen - not required here in employee - - try { - let payload = await httpRequest( - "post", - "/egov-location/location/v11/boundarys/_search?hierarchyTypeCode=REVENUE&boundaryType=Locality", - "_search", - [{ key: "tenantId", value: action.value }], - {} - ); - console.log("payload", payload) - const mohallaData = - payload && - payload.TenantBoundary[0] && - payload.TenantBoundary[0].boundary && - payload.TenantBoundary[0].boundary.reduce((result, item) => { - result.push({ - ...item, - name: `${action.value - .toUpperCase() - .replace( - /[.]/g, - "_" - )}_REVENUE_${item.code + }), + beforeFieldChange: async (action, state, dispatch) => { + //Below only runs for citizen - not required here in employee + + try { + let payload = await httpRequest( + "post", + "/egov-location/location/v11/boundarys/_search?hierarchyTypeCode=REVENUE&boundaryType=Locality", + "_search", + [{ key: "tenantId", value: action.value }], + {} + ); + console.log("payload", payload) + const mohallaData = + payload && + payload.TenantBoundary[0] && + payload.TenantBoundary[0].boundary && + payload.TenantBoundary[0].boundary.reduce((result, item) => { + result.push({ + ...item, + name: `${action.value .toUpperCase() - .replace(/[._:-\s\/]/g, "_")}` - }); - return result; - }, []); - - console.log(mohallaData, "mohallaData") - + .replace( + /[.]/g, + "_" + )}_REVENUE_${item.code + .toUpperCase() + .replace(/[._:-\s\/]/g, "_")}` + }); + return result; + }, []); + + console.log(mohallaData, "mohallaData") + + dispatch( + prepareFinalObject( + "applyScreenMdmsData.tenant.localities", + mohallaData + ) + ); + dispatch( + handleField( + "apply", + "components.div.children.formwizardSecondStep.children.propertyLocationDetails.children.cardContent.children.propertyDetailsConatiner.children.propertyMohalla", + "props.suggestions", + mohallaData + ) + ); + const mohallaLocalePrefix = { + moduleName: action.value, + masterName: "REVENUE" + }; + dispatch( + handleField( + "apply", + "components.div.children.formwizardSecondStep.children.propertyLocationDetails.children.cardContent.children.propertyDetailsConatiner.children.propertyMohalla", + "props.localePrefix", + mohallaLocalePrefix + ) + ); + + dispatch( + fetchLocalizationLabel(getLocale(), action.value, action.value) + ); + + } catch (e) { + console.log(e); + } + }, + gridDefination: { + xs: 12, + sm: 12 + } + } + }), + // Combination 1 Fields + combination1Container: getCommonContainer({ + propertyTaxUniqueId: getTextField({ + label: { + labelName: "Property Tax Unique Id", + labelKey: "PT_PROPERTY_UNIQUE_ID" + }, + placeholder: { + labelName: "Enter Property Tax Unique Id", + labelKey: "PT_PROPERTY_UNIQUE_ID_PLACEHOLDER" + }, + gridDefination: { + xs: 12, + sm: 4, + }, + required: false, + pattern: /^[a-zA-Z0-9-]*$/i, + errorMessage: "ERR_INVALID_PROPERTY_ID", + jsonPath: "ptSearchScreen.ids", + beforeFieldChange: async (action, state, dispatch) => { + // Only reset when user starts typing (not on clear/empty) + const value = typeof action.value === 'string' ? action.value.trim() : action.value; + if (!value || value === "") return; + + // Clear combination 2 data from state + dispatch(prepareFinalObject("ptSearchScreen.oldpropertyids", "")); + dispatch(prepareFinalObject("ptSearchScreen.name", "")); + dispatch(prepareFinalObject("ptSearchScreen.locality", [])); + + // Reset UI fields dispatch( - prepareFinalObject( - "applyScreenMdmsData.tenant.localities", - mohallaData + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.existingPropertyId", + "props.value", + "" ) ); dispatch( handleField( - "apply", - "components.div.children.formwizardSecondStep.children.propertyLocationDetails.children.cardContent.children.propertyDetailsConatiner.children.propertyMohalla", - "props.suggestions", - mohallaData + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.ownerName", + "props.value", + "" ) ); - const mohallaLocalePrefix = { - moduleName: action.value, - masterName: "REVENUE" - }; dispatch( handleField( - "apply", - "components.div.children.formwizardSecondStep.children.propertyLocationDetails.children.cardContent.children.propertyDetailsConatiner.children.propertyMohalla", - "props.localePrefix", - mohallaLocalePrefix + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.propertyMohalla", + "props.value", + [] ) ); + }, + }), - dispatch( - fetchLocalizationLabel(getLocale(), action.value, action.value) - ); - - } catch (e) { - console.log(e); - } - - }, + surveyId: getTextField({ + label: { + labelName: "Survey Id", + labelKey: "Survey Id" + }, + placeholder: { + labelName: "Enter Survey Id", + labelKey: "Survey Id" + }, gridDefination: { xs: 12, - sm: 4 - } - }, + sm: 4, + }, + required: false, + errorMessage: "ERR_INVALID_SURVEY_ID", + jsonPath: "ptSearchScreen.surveyId", + disabled: process.env.REACT_APP_NAME === "Citizen" ? true : false, + beforeFieldChange: async (action, state, dispatch) => { + // Only reset when user starts typing (not on clear/empty) + const value = typeof action.value === 'string' ? action.value.trim() : action.value; + if (!value || value === "") return; + + // Clear combination 2 data from state + dispatch(prepareFinalObject("ptSearchScreen.oldpropertyids", "")); + dispatch(prepareFinalObject("ptSearchScreen.name", "")); + dispatch(prepareFinalObject("ptSearchScreen.locality", [])); + + // Reset UI fields + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.existingPropertyId", + "props.value", + "" + ) + ); + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.ownerName", + "props.value", + "" + ) + ); + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.propertyMohalla", + "props.value", + [] + ) + ); + }, + }), + ownerMobNo: getTextField({ label: { labelName: "Owner Mobile No.", @@ -299,8 +405,6 @@ export const searchPropertyDetails = getCommonCard({ gridDefination: { xs: 12, sm: 4, - - }, iconObj: { label: "+91 |", @@ -309,142 +413,251 @@ export const searchPropertyDetails = getCommonCard({ required: false, pattern: getPattern("MobileNo"), jsonPath: "ptSearchScreen.mobileNumber", - // disabled: process.env.REACT_APP_NAME === "Citizen" ? true : false, - errorMessage: "ERR_INVALID_MOBILE_NUMBER" - }), - propertyTaxUniqueId: getTextField({ + errorMessage: "ERR_INVALID_MOBILE_NUMBER", + beforeFieldChange: async (action, state, dispatch) => { + // Only reset when user starts typing (not on clear/empty) + const value = typeof action.value === 'string' ? action.value.trim() : action.value; + if (!value || value === "") return; + + // Clear combination 2 data from state + dispatch(prepareFinalObject("ptSearchScreen.oldpropertyids", "")); + dispatch(prepareFinalObject("ptSearchScreen.name", "")); + dispatch(prepareFinalObject("ptSearchScreen.locality", [])); + + // Reset UI fields + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.existingPropertyId", + "props.value", + "" + ) + ); + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.ownerName", + "props.value", + "" + ) + ); + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination2Container.children.propertyMohalla", + "props.value", + [] + ) + ); + }, + }) + }), + + // OR separator + orText: { + uiFramework: "custom-atoms", + componentPath: "Label", + props: { + label: "OR", + style: { + textAlign: "center", + fontSize: "16px", + fontWeight: "bold", + margin: "16px 0", + color: "#666", + display: "block" + } + }, + gridDefination: { + xs: 12, + sm: 12 + } + }, + + // Combination 2 Fields + combination2Container: getCommonContainer({ + existingPropertyId: getTextField({ label: { - labelName: "Property Tax Unique Id", - labelKey: "PT_PROPERTY_UNIQUE_ID" + labelName: "Existing Property ID", + labelKey: "PT_EXISTING_PROPERTY_ID" }, placeholder: { - labelName: "Enter Property Tax Unique Id", - labelKey: "PT_PROPERTY_UNIQUE_ID_PLACEHOLDER" + labelName: "Enter Existing Property ID", + labelKey: "PT_EXISTING_PROPERTY_ID_PLACEHOLDER" }, gridDefination: { xs: 12, sm: 4, - }, required: false, - pattern: /^[a-zA-Z0-9-]*$/i, + pattern: /^[^\$\"'<>?\\\\~`!@$%^()+={}\[\]*:;""'']{1,64}$/i, errorMessage: "ERR_INVALID_PROPERTY_ID", - jsonPath: "ptSearchScreen.ids" + jsonPath: "ptSearchScreen.oldpropertyids", + beforeFieldChange: async (action, state, dispatch) => { + // Only reset when user starts typing (not on clear/empty) + const value = typeof action.value === 'string' ? action.value.trim() : action.value; + if (!value || value === "") return; + + // Clear combination 1 data from state + dispatch(prepareFinalObject("ptSearchScreen.ids", "")); + dispatch(prepareFinalObject("ptSearchScreen.surveyId", "")); + dispatch(prepareFinalObject("ptSearchScreen.mobileNumber", "")); + + // Reset UI fields + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.propertyTaxUniqueId", + "props.value", + "" + ) + ); + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.surveyId", + "props.value", + "" + ) + ); + + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.ownerMobNo", + "props.value", + "" + ) + ); + }, }), - existingPropertyId: getTextField({ + + ownerName: getTextField({ label: { - labelName: "Existing Property ID", - labelKey: "PT_EXISTING_PROPERTY_ID" + labelName: "Owner Name", + labelKey: "Owner Name" }, placeholder: { - labelName: "Enter Existing Property ID", - labelKey: "PT_EXISTING_PROPERTY_ID_PLACEHOLDER" + labelName: "Enter Owner Name", + labelKey: "Owner Name" }, gridDefination: { xs: 12, sm: 4, - }, required: false, - pattern: /^[^\$\"'<>?\\\\~`!@$%^()+={}\[\]*:;“”‘’]{1,64}$/i, errorMessage: "ERR_INVALID_PROPERTY_ID", - jsonPath: "ptSearchScreen.oldpropertyids" + jsonPath: "ptSearchScreen.name", + beforeFieldChange: async (action, state, dispatch) => { + // Only reset when user starts typing (not on clear/empty) + const value = typeof action.value === 'string' ? action.value.trim() : action.value; + if (!value || value === "") return; + + // Clear combination 1 data from state + dispatch(prepareFinalObject("ptSearchScreen.ids", "")); + dispatch(prepareFinalObject("ptSearchScreen.surveyId", "")); + dispatch(prepareFinalObject("ptSearchScreen.mobileNumber", "")); + + // Reset UI fields + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.propertyTaxUniqueId", + "props.value", + "" + ) + ); + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.surveyId", + "props.value", + "" + ) + ); + + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.ownerMobNo", + "props.value", + "" + ) + ); + }, }), - - //-------------locality-------------- - propertyMohalla: { - uiFramework: "custom-containers", - componentPath: "AutosuggestContainer", - jsonPath:"ptSearchScreen.locality", - required: true, - props: { - style: { - width: "100%", - cursor: "pointer" + + propertyMohalla: { + uiFramework: "custom-containers", + componentPath: "AutosuggestContainer", + jsonPath: "ptSearchScreen.locality", + required: false, + props: { + style: { + width: "100%", + cursor: "pointer" + }, + label: { + labelName: "Locality/Mohalla", + }, + placeholder: { + labelName: "Select Locality/Mohalla", + }, + jsonPath: "ptSearchScreen.locality", + sourceJsonPath: "applyScreenMdmsData.tenant.localities", + labelsFromLocalisation: true, + errorMessage: "ERR_DEFAULT_INPUT_FIELD_MSG", + suggestions: [], + fullwidth: true, + required: false, + inputLabelProps: { + shrink: true + } }, - label: { - labelName: "Locality/Mohalla", - // labelKey: "NOC_PROPERTY_DETAILS_MOHALLA_LABEL" + beforeFieldChange: async (action, state, dispatch) => { + // Only reset when user starts typing (not on clear/empty) + const value = typeof action.value === 'string' ? action.value.trim() : action.value; + if (!value || value === "") return; + + // Clear combination 1 data from state + dispatch(prepareFinalObject("ptSearchScreen.ids", "")); + dispatch(prepareFinalObject("ptSearchScreen.surveyId", "")); + dispatch(prepareFinalObject("ptSearchScreen.mobileNumber", "")); + + // Reset UI fields + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.propertyTaxUniqueId", + "props.value", + "" + ) + ); + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.surveyId", + "props.value", + "" + ) + ); + + dispatch( + handleField( + "propertySearch", + "components.div.children.propertySearchTabs.children.cardContent.children.tabSection.props.tabs[0].tabContent.searchPropertyDetails.children.cardContent.children.combination1Container.children.ownerMobNo", + "props.value", + "" + ) + ); }, - placeholder: { - labelName: "Select Locality/Mohalla", - //labelKey: "NOC_PROPERTY_DETAILS_MOHALLA_PLACEHOLDER" - }, - jsonPath:"ptSearchScreen.locality", - sourceJsonPath: "applyScreenMdmsData.tenant.localities", - labelsFromLocalisation: true, - errorMessage: "ERR_DEFAULT_INPUT_FIELD_MSG", - suggestions: [], - fullwidth: true, - required: false, - // disabled: process.env.REACT_APP_NAME === "Citizen" ? true : false, - // type:hidden, - inputLabelProps: { - shrink: true + gridDefination: { + xs: 12, + sm: 4 } - // className: "tradelicense-mohalla-apply" - }, - beforeFieldChange: async (action, state, dispatch) => { - // dispatch( - // prepareFinalObject( - // "Licenses[0].tradeLicenseDetail.address.locality.name", - // action.value && action.value.label - // ) - // ); - }, - gridDefination: { - xs: 12, - sm: 4 } - }, - //---------------locality-end-------------- - //-------------------Owner Name---------------------- - ownerName: getTextField({ - label: { - labelName: "Owner Name", - labelKey: "Owner Name" - }, - placeholder: { - labelName: "Enter Owner Name", - labelKey: "Owner Name" - }, - gridDefination: { - xs: 12, - sm: 4, - - }, - required: false, - // pattern: /^[^\$\"'<>?\\\\~`!@$%^()+={}\[\]*:;“”‘’]{1,64}$/i, - errorMessage: "ERR_INVALID_PROPERTY_ID", - jsonPath: "ptSearchScreen.name", - // disabled: process.env.REACT_APP_NAME === "Citizen" ? true : false, - }), - - surveyId: getTextField({ - label: { - labelName: "Survey Id", - labelKey: "Survey Id" - }, - placeholder: { - labelName: "Enter Survey Id", - labelKey: "Survey Id" - }, - gridDefination: { - xs: 12, - sm: 4, - - }, - required: false, - // pattern: /^[^\$\"'<>?\\\\~`!@$%^()+={}\[\]*:;“”‘’]{1,64}$/i, - errorMessage: "ERR_INVALID_SURVEY_ID", - jsonPath: "ptSearchScreen.surveyId", - disabled: process.env.REACT_APP_NAME === "Citizen" ? true : false, }), - - //-------------------End SurveyId -------------------------------- - }), - button: getCommonContainer({ buttonContainer: getCommonContainer({ resetButton: { @@ -560,7 +773,7 @@ export const searchApplicationDetails = getCommonCard({ position: "start" }, required: false, - // disabled: process.env.REACT_APP_NAME === "Citizen" ? true : false, + // disabled: process.env.REACT_APP_NAME === "Citizen" ? true : false, pattern: getPattern("MobileNo"), jsonPath: "ptSearchScreen.mobileNumber", errorMessage: "ERR_INVALID_MOBILE_NUMBER" @@ -580,7 +793,7 @@ export const searchApplicationDetails = getCommonCard({ }, required: false, - // disabled: process.env.REACT_APP_NAME === "Citizen" ? true : false, + // disabled: process.env.REACT_APP_NAME === "Citizen" ? true : false, pattern: /^[a-zA-Z0-9-]*$/i, errorMessage: "ERR_INVALID_PROPERTY_ID", jsonPath: "ptSearchScreen.ids" diff --git a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/propertySearch.js b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/propertySearch.js index 46cfffe17a..2c1dc0394c 100644 --- a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/propertySearch.js +++ b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/propertySearch.js @@ -2,13 +2,14 @@ import commonConfig from "config/common.js"; import { getBreak, getCommonHeader, getLabel } from "egov-ui-framework/ui-config/screens/specs/utils"; import { prepareFinalObject } from "egov-ui-framework/ui-redux/screen-configuration/actions"; import { getQueryArg, getRequiredDocData,showHideAdhocPopup } from "egov-ui-framework/ui-utils/commons"; -import { getTenantId } from "egov-ui-kit/utils/localStorageUtils"; +import { getTenantId,getLocale } from "egov-ui-kit/utils/localStorageUtils"; import {getLocality} from "../utils/index" import "./index.css"; import get from "lodash/get"; import { resetFields } from "./mutation-methods"; import propertySearchTabs from "./property-search-tabs"; import { searchApplicationTable, searchPropertyTable } from "./searchResource/searchResults"; +import { fetchLocalizationLabel } from "egov-ui-kit/redux/app/actions"; const hasButton = getQueryArg(window.location.href, "hasButton"); let enableButton = true; enableButton = hasButton && hasButton === "false" ? false : true; @@ -133,7 +134,10 @@ const screenConfig = { resetFields(state, dispatch); getMDMSData(action, dispatch); - getLocalityData(action, dispatch,tenant) + getLocalityData(action, dispatch,tenant); + const tenantId = getTenantId(); + const locale = getLocale() || "en_IN"; + dispatch(fetchLocalizationLabel(locale, "pt", tenantId)); return action; }, diff --git a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/searchResource/functions.js b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/searchResource/functions.js index f35fa7cd7f..f14c6a7991 100644 --- a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/searchResource/functions.js +++ b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/searchResource/functions.js @@ -78,29 +78,33 @@ export const searchApiCall = async (state, dispatch) => { // showHideProgress(true, dispatch); for (var key in searchScreenObject) { if ( - searchScreenObject.hasOwnProperty(key) && - searchScreenObject[key].trim() !== "" + searchScreenObject.hasOwnProperty(key) ) { - if (key === "fromDate") { - queryObject.push({ - key: key, - value: convertDateToEpoch(searchScreenObject[key], "daystart") - }); - } else if (key === "toDate") { - queryObject.push({ - key: key, - value: convertDateToEpoch(searchScreenObject[key], "dayend") - }); - } - // else if (key === "status") { - // queryObject.push({ - // key: "action", - // value: searchScreenObject[key].trim() - // }); - // } - else { - queryObject.push({ key: key, value: searchScreenObject[key].trim() }); + const value = searchScreenObject[key]; + + if (value !== null && value !== undefined && String(value).trim() !== "") { + if (key === "fromDate") { + queryObject.push({ + key: key, + value: convertDateToEpoch(value, "daystart") + }); + } else if (key === "toDate") { + queryObject.push({ + key: key, + value: convertDateToEpoch(value, "dayend") + }); + } + // else if (key === "status") { + // queryObject.push({ + // key: "action", + // value: value.trim() + // }); + // } + else { + queryObject.push({ key: key, value: value.trim() }); + } } + } } try { diff --git a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/searchResource/searchResults.js b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/searchResource/searchResults.js index 68d2e21400..512a771f94 100644 --- a/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/searchResource/searchResults.js +++ b/web/rainmaker/dev-packages/egov-pt-dev/src/ui-config/screens/specs/pt-mutation/searchResource/searchResults.js @@ -323,7 +323,7 @@ const navigate=(url)=>{ } const propertyInformationScreenLink=(propertyId,tenantId)=>{ - debugger + // debugger if(process.env.REACT_APP_NAME == "Citizen"){ return `/property-tax/my-properties/property/${propertyId}/${tenantId}`; }else{ diff --git a/web/rainmaker/dev-packages/egov-ui-kit-dev/src/common/propertyTax/AssessmentList/components/PTInformation/index.js b/web/rainmaker/dev-packages/egov-ui-kit-dev/src/common/propertyTax/AssessmentList/components/PTInformation/index.js index 439da0d7c4..00008d4fd5 100644 --- a/web/rainmaker/dev-packages/egov-ui-kit-dev/src/common/propertyTax/AssessmentList/components/PTInformation/index.js +++ b/web/rainmaker/dev-packages/egov-ui-kit-dev/src/common/propertyTax/AssessmentList/components/PTInformation/index.js @@ -34,110 +34,6 @@ class PTInformation extends React.Component { }; componentDidMount = async () => { let { propertiesAudit, properties } = this.props; - let fetchBillQueryObject = null; - const purpose = getPurpose(); - if (window.location.href.includes("citizen")) { - fetchBillQueryObject = [ - { - key: "tenantId", - value: getTenantId(), - }, - { - key: "consumerCode", - value: window.location.href.split("/")[7], - }, - { - key: "businessService", - value: "PT", - }, - ]; - } else if (window.location.href.includes("localhost")) { - if (window.location.href.includes("my-properties")) { - fetchBillQueryObject = [ - { - key: "tenantId", - value: window.location.href.split("/")[7], - }, - { - key: "consumerCode", - value: window.location.href.split("/")[6], - }, - { - key: "businessService", - value: "PT", - }, - ]; - } else if (window.location.href.includes("pt-acknowledgment")) { - fetchBillQueryObject = [ - { - key: "tenantId", - value: getQueryArg(window.location.href, "tenantId"), - }, - { - key: "consumerCode", - value: getQueryArg(window.location.href, "propertyId"), - }, - { - key: "businessService", - value: "PT", - }, - ]; - } else { - fetchBillQueryObject = [ - { - key: "tenantId", - value: getTenantId(), - }, - { - key: "consumerCode", - value: window.location.href.split("/")[5], - }, - { - key: "businessService", - value: "PT", - }, - ]; - } - } else { - fetchBillQueryObject = [ - { - key: "tenantId", - value: getTenantId(), - }, - { - key: "consumerCode", - value: window.location.href.split("/")[6], - }, - { - key: "businessService", - value: "PT", - }, - ]; - } - const FETCHBILL = { - GET: { - URL: "/billing-service/bill/v2/_fetchbill", - ACTION: "_get", - }, - }; - // if (purpose != PROPERTY_FORM_PURPOSE.CREATE) { - const payloadProperty = await httpRequest(FETCHBILL.GET.URL, FETCHBILL.GET.ACTION, fetchBillQueryObject); - let paymentDueYears = ""; - if (payloadProperty.Bill != null && payloadProperty.Bill.length >= 0) { - payloadProperty.Bill[0].billDetails.map((item) => { - console.log(item.toPeriod); - console.log(item.fromPeriod); - if (item.amount > 0) { - let toDate = convertEpochToDate(item.toPeriod).split("/")[2]; - let fromDate = convertEpochToDate(item.fromPeriod).split("/")[2]; - paymentDueYears = paymentDueYears == "" ? fromDate + "-" + toDate + "(Rs." + item.amount + ")" : paymentDueYears + "," + fromDate + "-" + toDate + "(Rs." + item.amount + ")"; - - } - }); - } - - this.setState({ paymentDueYears }); - // } const mdmsBody = { MdmsCriteria: { tenantId: commonConfig.tenantId, @@ -246,6 +142,23 @@ class PTInformation extends React.Component { return filteredCity ? get(filteredCity[0], "logoId") : ""; }; + componentDidUpdate = (prevProps) => { + const { Bill } = this.props; + if (Bill && Bill !== prevProps.Bill) { + let paymentDueYears = ""; + if (Bill != null && Bill.length >= 0 && Bill[0] && Bill[0].billDetails) { + Bill[0].billDetails.map((item) => { + if (item.amount > 0) { + let toDate = convertEpochToDate(item.toPeriod).split("/")[2]; + let fromDate = convertEpochToDate(item.fromPeriod).split("/")[2]; + paymentDueYears = paymentDueYears == "" ? fromDate + "-" + toDate + "(Rs." + item.amount + ")" : paymentDueYears + "," + fromDate + "-" + toDate + "(Rs." + item.amount + ")"; + } + }); + } + this.setState({ paymentDueYears }); + } + }; + render() { const { label, @@ -456,13 +369,14 @@ class PTInformation extends React.Component { } const mapStateToProps = (state) => { - const { screenConfiguration = {} } = state; + const { screenConfiguration = {}, properties = {} } = state; const { cities } = state.common || []; + const { Bill } = properties; const { preparedFinalObject } = screenConfiguration; let { propertiesAudit = [] } = preparedFinalObject; const updateNumberConfig = get(preparedFinalObject, "updateNumberConfig", []); - return { cities, propertiesAudit, updateNumberConfig }; + return { cities, propertiesAudit, updateNumberConfig, Bill }; }; export default connect(mapStateToProps, null)(PTInformation);