From 602bb0cf55c235d2181bba60414d4ea9d5632b77 Mon Sep 17 00:00:00 2001 From: Abishek Date: Thu, 9 Jan 2025 10:49:37 +0530 Subject: [PATCH] Resolved comments, made payload to facilityId --- .../example/public/index.html | 2 +- .../src/components/InboxFilterWrapper.js | 27 ++++++++++++------- .../microplan/src/pages/employee/PlanInbox.js | 8 +++--- .../microplan/src/pages/employee/PopInbox.js | 2 +- 4 files changed, 23 insertions(+), 16 deletions(-) diff --git a/health/micro-ui/web/micro-ui-internals/example/public/index.html b/health/micro-ui/web/micro-ui-internals/example/public/index.html index 8eddd4ce06..bb1241f61d 100644 --- a/health/micro-ui/web/micro-ui-internals/example/public/index.html +++ b/health/micro-ui/web/micro-ui-internals/example/public/index.html @@ -11,7 +11,7 @@ DIGIT - + diff --git a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js index 780bb8bf0a..dcbb418cb0 100644 --- a/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js +++ b/health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/components/InboxFilterWrapper.js @@ -11,13 +11,15 @@ const InboxFilterWrapper = (props) => { const {microplanId,...rest} = Digit.Hooks.useQueryParams() const tenantId = Digit.ULBService.getCurrentTenantId(); const [filterValues, setFilterValues] = useState( - { status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null,facilityName:null } + { status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null,facilityID:null } ); // Default selected option let defaultSelectedOptions = props.defaultValue ? Object.entries(props.defaultValue).reduce((acc, [key, value]) => { - if (value !== null) { + if (key === "facilityId") { + acc[key] = { code: value?.code, name: `${t(key)} (${value})` }; + } else if (value !== null) { acc[key] = { code: value, name: `${t(key)} (${value})` }; } else { acc[key] = null; @@ -32,7 +34,9 @@ const InboxFilterWrapper = (props) => { if (props.defaultValue && Object.keys(props.defaultValue).length > 0) { const newDefault = Object.entries(props.defaultValue).reduce((acc, [key, value]) => { acc[key] = value !== null - ? { code: value, name: `${t(key)} (${value})` } + ? key === 'facilityId' + ? { code: value?.code } + : { code: value, name: `${t(key)} (${value})` } : null; return acc; }, {}); @@ -67,7 +71,10 @@ const InboxFilterWrapper = (props) => { if (props.onApplyFilters) { const filtersToApply = {}; for (let key in filterValues) { - if (filterValues[key] && typeof filterValues[key] === 'object' && filterValues[key].hasOwnProperty('code')) { + if(filterValues[key] && typeof filterValues[key] === 'object' && String(key)==='facilityId' &&filterValues[key].hasOwnProperty('code') ){ + filtersToApply[key] = filterValues[key] + } + else if (filterValues[key] && typeof filterValues[key] === 'object' && filterValues[key].hasOwnProperty('code')) { filtersToApply[key] = filterValues[key].code; // Extract 'name' if it exists } else { filtersToApply[key] = filterValues[key]; // Keep the value as is (including null) @@ -107,10 +114,10 @@ const InboxFilterWrapper = (props) => { select: (data) => { if (!data?.PlanFacility || !Array.isArray(data.PlanFacility)) return []; - // Extract facilityName for each object + // Extract facilityName and facilityId for each object const facilityOptions = data.PlanFacility.map((facility) => ({ code: facility.facilityName, - name: facility.facilityName + id: facility.facilityId })); return facilityOptions; @@ -154,7 +161,7 @@ const InboxFilterWrapper = (props) => { /> )} - {props.isEstimate && + {props.isPlanInbox &&
{t("MP_VILLAGE_ROAD_CONDITION")}
@@ -185,8 +192,8 @@ const InboxFilterWrapper = (props) => { handleDropdownChange("facilityName", value)} + selected={filterValues["facilityId"] || defaultSelectedOptions?.facilityId } + select={(value) => handleDropdownChange("facilityId", value)} t={t} disabled={false} /> @@ -209,7 +216,7 @@ const InboxFilterWrapper = (props) => { vertical style={{ paddingBottom: isLastElement ? "1rem" : "0" }} > -
{t(`MP_SECURITY_QUESTION ${index+1}`)}
+
{t(`MP_SECURITY_QUESTION ${index + 1}`)}
{ const [hierarchyLevel, setHierarchyLevel] = useState(""); const [censusData, setCensusData] = useState([]); const [boundaries, setBoundaries] = useState([]); - const [selectedFilter, setSelectedFilter] = useState({status:"PENDING_FOR_VALIDATION",onRoadCondition:null,terrain:null,securityQ1:null,securityQ2:null,facilityName:null}); + const [selectedFilter, setSelectedFilter] = useState({status:"PENDING_FOR_VALIDATION",onRoadCondition:null,terrain:null,securityQ1:null,securityQ2:null,facilityId:null}); const [activeFilter, setActiveFilter] = useState({}); const [actionBarPopUp, setactionBarPopUp] = useState(false); const [selectedRows, setSelectedRows] = useState([]); @@ -176,7 +176,7 @@ const PlanInbox = () => { ...(selectedFilter?.terrain != null && { terrain: selectedFilter.terrain }), ...(selectedFilter?.securityQ1 != null && { securityQ1: selectedFilter.securityQ1 }), ...(selectedFilter?.securityQ2 != null && { securityQ2: selectedFilter.securityQ2 }), - ...(selectedFilter?.facilityName != null && { facilityName: selectedFilter.facilityName }), + ...(selectedFilter?.facilityId?.id != null && { facilityId: selectedFilter.facilityId.id }), assignee: user.info.uuid, planConfigurationId: microplanId, limit: limitAndOffset?.limit, @@ -217,7 +217,7 @@ const PlanInbox = () => { ...(selectedFilter?.onRoadCondition != null && { onRoadCondition: selectedFilter.onRoadCondition }), ...(selectedFilter?.securityQ1 != null && { securityQ1: selectedFilter.securityQ1 }), ...(selectedFilter?.securityQ2 != null && { securityQ2: selectedFilter.securityQ2 }), - ...(selectedFilter?.facilityName != null && { facilityName: selectedFilter.facilityName }), + ...(selectedFilter?.facilityId?.id != null && { facilityId: selectedFilter.facilityId.id }), planConfigurationId: microplanId, //list of plan ids limit: limitAndOffset?.limit, @@ -885,7 +885,7 @@ const PlanInbox = () => { }} > {