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-1713: PopInbox and filtering integration #2108

Merged
merged 10 commits into from
Jan 9, 2025
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
<title>DIGIT</title>
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].33/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].34/dist/index.css" />
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved


<!-- added below css for hcm-workbench module inclusion-->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@egovernments/digit-ui-health-css",
"version": "0.2.33",
"version": "0.2.34",
"license": "MIT",
"main": "dist/index.css",
"author": "Jagankumar <[email protected]>",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -538,4 +538,13 @@ tbody tr:last-child td:last-child .digit-dropdown-employee-select-wrap .digit-dr
flex-direction: column;
gap: 1rem;

}
}

.custom-filter-names {
font-family: Roboto;
font-style: normal;
font-weight: 400;
line-height: 1.37rem;
color: #363636;
font-size: 1.1rem;
}
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React, { useState, useEffect } from "react";
import React, { useState, useEffect, Fragment } from "react";
import { useTranslation } from "react-i18next";
import { FilterCard, Dropdown, LabelFieldPair, RadioButtons, TextBlock, Loader } from "@egovernments/digit-ui-components";
import { useMyContext } from "../utils/context";
Expand All @@ -11,21 +11,21 @@ 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 }
{ status: null, onRoadCondition: null, terrain: null, securityQ1: null, securityQ2: null,facilityName:null }
);


// Default selected option
let defaultSelectedOptions = props.defaultValue
? Object.entries(props.defaultValue).reduce((acc, [key, value]) => {
if (value !== null) {
? Object.entries(props.defaultValue).reduce((acc, [key, value]) => {
if (value !== null) {
acc[key] = { code: value, name: `${t(key)} (${value})` };
} else {
acc[key] = null;
}
return acc;
}, {})
: null;
: null;


// Initialize state with the default selected option
useEffect(() => {
Expand All @@ -39,6 +39,7 @@ const InboxFilterWrapper = (props) => {
setFilterValues(newDefault);
}
}, [props.defaultValue, t]);




Expand All @@ -65,15 +66,13 @@ const InboxFilterWrapper = (props) => {
const handleApplyFilters = () => {
if (props.onApplyFilters) {
const filtersToApply = {};

for (let key in filterValues) {
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)
}
}

props.onApplyFilters(filtersToApply); // Pass the new array to onApplyFilters
}
};
Expand Down Expand Up @@ -108,10 +107,10 @@ const InboxFilterWrapper = (props) => {
select: (data) => {
if (!data?.PlanFacility || !Array.isArray(data.PlanFacility)) return [];

// Extract facilityName and facilityId for each object
// Extract facilityName for each object
const facilityOptions = data.PlanFacility.map((facility) => ({
code: facility.facilityName,
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
id: facility.facilityId
name: facility.facilityName
}));

return facilityOptions;
Expand All @@ -125,7 +124,7 @@ const InboxFilterWrapper = (props) => {
if(isPlanFacilityLoading){
return <Loader/>
}

return (

<FilterCard
Expand Down Expand Up @@ -155,9 +154,10 @@ const InboxFilterWrapper = (props) => {
/>
</LabelFieldPair>
)}

{props.isEstimate &&
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
<Fragment>
<LabelFieldPair vertical>
<TextBlock body={t(`MP_VILLAGE_ROAD_CONDITION`)} />
<div className="custom-filter-names">{t("MP_VILLAGE_ROAD_CONDITION")}</div>
<Dropdown
option={state.villageRoadCondition}
optionKey={"code"}
Expand All @@ -169,8 +169,8 @@ const InboxFilterWrapper = (props) => {
</LabelFieldPair>

<LabelFieldPair vertical>
<TextBlock body={t(`MP_VILLAGE_TERRAIN`)} />
<Dropdown
<div className="custom-filter-names">{t("MP_VILLAGE_TERRAIN")}</div>
<Dropdown
option={state.villageTerrain}
optionKey={"code"}
selected={filterValues["terrain"] || defaultSelectedOptions?.terrain}
Expand All @@ -181,12 +181,12 @@ const InboxFilterWrapper = (props) => {
</LabelFieldPair>

<LabelFieldPair vertical>
<TextBlock body={t(`MP_FILTER_FACILITY`)} />
<div className="custom-filter-names">{t("MP_FILTER_FACILITY")}</div>
<Dropdown
option={planFacility}
optionKey={"code"}
selected={filterValues["facility"] || defaultSelectedOptions?.facility}
select={(value) => handleDropdownChange("facility", value)}
selected={filterValues["facilityName"] || defaultSelectedOptions?.facilityName }
select={(value) => handleDropdownChange("facilityName", value)}
t={t}
disabled={false}
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
/>
Expand All @@ -202,24 +202,27 @@ const InboxFilterWrapper = (props) => {
}));

const isLastElement = index === state.securityQuestions.length - 1;
const questionNumber = parseInt(item.id, 10);

return (
<LabelFieldPair
vertical
style={{ paddingBottom: isLastElement ? "1rem" : "0" }}
>
<TextBlock body={t(`MP_SECURITY_QUESTION ${index + 1}`)} />
<div className="custom-filter-names">{t(`MP_SECURITY_QUESTION ${index+1}`)}</div>
<Dropdown
option={options}
optionKey="code"
selected={filterValues[`securityQ${index + 1}`]}
select={(value) => handleDropdownChange(`securityQ${index + 1}`, value)}
t={(key) => key}
optionKey={"code"}
selected={filterValues[`securityQ${questionNumber}`]}
select={(value) => handleDropdownChange(`securityQ${questionNumber}`, value)}
t={t}
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
disabled={false}
/>
</LabelFieldPair>
);
})}
</Fragment>
}


</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ function RoleTableComposer({ nationalRoles }) {
enabled: true,
select: (data) => {
const resp = data?.Employees
?.filter((emp)=> emp?.user?.userServiceUuid!== null)
?.map((item, index) => {
return {
rowIndex: index + 1,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const PlanInbox = () => {
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});
const [selectedFilter, setSelectedFilter] = useState({status:"PENDING_FOR_VALIDATION",onRoadCondition:null,terrain:null,securityQ1:null,securityQ2:null,facilityName:null});
const [activeFilter, setActiveFilter] = useState({});
const [actionBarPopUp, setactionBarPopUp] = useState(false);
const [selectedRows, setSelectedRows] = useState([]);
Expand Down Expand Up @@ -176,6 +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 }),
assignee: user.info.uuid,
planConfigurationId: microplanId,
limit: limitAndOffset?.limit,
Expand Down Expand Up @@ -216,6 +217,8 @@ 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 }),

planConfigurationId: microplanId, //list of plan ids
limit: limitAndOffset?.limit,
offset: limitAndOffset?.offset,
Expand Down Expand Up @@ -882,6 +885,7 @@ const PlanInbox = () => {
}}
>
<InboxFilterWrapper
isEstimate={true}
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
abishekTa-egov marked this conversation as resolved.
Show resolved Hide resolved
options={activeFilter}
onApplyFilters={onFilter}
clearFilters={clearFilters}
Expand Down
Loading