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 9e61ca145c..bd33733d7c 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 @@ -1,6 +1,6 @@ import React, { useState, useEffect } from "react"; import { useTranslation } from "react-i18next"; -import { FilterCard, Dropdown, LabelFieldPair, RadioButtons, TextBlock } from "@egovernments/digit-ui-components"; +import { FilterCard, Dropdown, LabelFieldPair, RadioButtons, TextBlock, Loader } from "@egovernments/digit-ui-components"; import { useMyContext } from "../utils/context"; @@ -8,6 +8,8 @@ import { useMyContext } from "../utils/context"; const InboxFilterWrapper = (props) => { const { state } = useMyContext(); const { t } = useTranslation(); + 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 } ); @@ -49,6 +51,7 @@ const InboxFilterWrapper = (props) => { name: `${t(key)} (${value})`, })); }; + // Generate options from props.options const resultArray = createArrayFromObject(props?.options, t); @@ -92,6 +95,37 @@ const InboxFilterWrapper = (props) => { })); }; + const planFacilitySearchConfig = { + url: "/plan-service/plan/facility/_search", + body: { + PlanFacilitySearchCriteria: { + tenantId: tenantId, + planConfigurationId: microplanId, + } + }, + config: { + enabled: true, + select: (data) => { + if (!data?.PlanFacility || !Array.isArray(data.PlanFacility)) return []; + + // Extract facilityName and facilityId for each object + const facilityOptions = data.PlanFacility.map((facility) => ({ + code: facility.facilityName, + id: facility.facilityId + })); + + return facilityOptions; + }, + cacheTime:Infinity + } + }; + + const { isLoading: isPlanFacilityLoading,error:planFacilityerror, data: planFacility }=Digit.Hooks.useCustomAPIHook(planFacilitySearchConfig); + + if(isPlanFacilityLoading){ + return + } + return ( { disabled={false} /> + + + + handleDropdownChange("facility", value)} + t={t} + disabled={false} + /> + {state.securityQuestions.map((item, index) => {