Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FEATURE/HCMPRE-1712: Facility Dropdown for plan Inbox #2096

Merged
merged 27 commits into from
Jan 3, 2025
Merged
Changes from 24 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
8a956ab
Adding filters
abishekTa-egov Dec 17, 2024
34b8b7b
Merge branch 'console' into FEATURE/HCMPRE-1651
abishekTa-egov Dec 23, 2024
3ffaa6d
Working Filter Search
abishekTa-egov Dec 23, 2024
70d22e7
InboxFilter Changes
abishekTa-egov Dec 30, 2024
f08b5b6
Merge branch 'console' into FEATURE/HCMPRE-1651
abishekTa-egov Dec 30, 2024
34f5cdc
removing console.log
abishekTa-egov Dec 30, 2024
a27755b
Css package update
abishekTa-egov Dec 30, 2024
afb8820
changes
abishekTa-egov Dec 31, 2024
25e7cf9
changes
abishekTa-egov Dec 31, 2024
8af4357
Merge branch 'console' into FEATURE/HCMPRE-1709
abishekTa-egov Dec 31, 2024
df7873b
changes
abishekTa-egov Dec 31, 2024
28c580f
Merge branch 'FEATURE/HCMPRE-1709' of https://github.com/egovernments…
abishekTa-egov Dec 31, 2024
ca2b8cc
changes
abishekTa-egov Dec 31, 2024
f04ebfb
changes
abishekTa-egov Dec 31, 2024
2078b7f
A lot of changes
abishekTa-egov Jan 2, 2025
78f3e1b
changes
abishekTa-egov Jan 2, 2025
eb2a056
changes
abishekTa-egov Jan 2, 2025
ee90174
changes
abishekTa-egov Jan 3, 2025
4a89750
Merge branch 'console' into FEATURE/HCMPRE-1710
abishekTa-egov Jan 3, 2025
4dd2800
uniform payload structure
abishekTa-egov Jan 3, 2025
6c7885f
Adding Facility Dropdown
abishekTa-egov Jan 3, 2025
85ea908
resolved conflicts
abishekTa-egov Jan 3, 2025
23ebb4d
code replacing name attribute
abishekTa-egov Jan 3, 2025
f85e32d
Loader changes
abishekTa-egov Jan 3, 2025
dd4d02f
comments resolved
abishekTa-egov Jan 3, 2025
65245d3
Loader change
abishekTa-egov Jan 3, 2025
c423746
Id to id
abishekTa-egov Jan 3, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
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";



const InboxFilterWrapper = (props) => {
const { state } = useMyContext();
const { t } = useTranslation();
const url = Digit.Hooks.useQueryParams()
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
const tenantId = Digit.ULBService.getCurrentTenantId();
const [filterValues, setFilterValues] = useState(
{ status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null }
);
Expand Down Expand Up @@ -49,6 +51,7 @@ const InboxFilterWrapper = (props) => {
name: `${t(key)} (${value})`,
}));
};


// Generate options from props.options
const resultArray = createArrayFromObject(props?.options, t);
Expand Down Expand Up @@ -92,6 +95,32 @@ const InboxFilterWrapper = (props) => {
}));
};

const planFacilitySearchConfig = {
url: "/plan-service/plan/facility/_search",
body: {
PlanFacilitySearchCriteria: {
tenantId: tenantId,
planConfigurationId: url?.microplanId,
}
},
config: {
enabled: true,
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
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
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
}));

return facilityOptions;
},
}
};

const { isLoading: isPlanFacilityLoading,error:panFacilityerror, data: planFacility }=Digit.Hooks.useCustomAPIHook(planFacilitySearchConfig);
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved

return (

<FilterCard
Expand Down Expand Up @@ -145,6 +174,20 @@ const InboxFilterWrapper = (props) => {
disabled={false}
/>
</LabelFieldPair>
{
isPlanFacilityLoading?(<Loader/>):(
<LabelFieldPair vertical>
<TextBlock body={t(`MP_FILTER_FACILITY`)} />
<Dropdown
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
option={planFacility}
optionKey={"code"}
selected={filterValues["facility"] || defaultSelectedOptions?.facility}
select={(value) => handleDropdownChange("facility", value)}
t={t}
disabled={false}
/>
</LabelFieldPair>
)}


{state.securityQuestions.map((item, index) => {
Expand Down