Skip to content

Commit

Permalink
Resolved comments, made payload to facilityId
Browse files Browse the repository at this point in the history
  • Loading branch information
abishekTa-egov committed Jan 9, 2025
1 parent 20d8039 commit 602bb0c
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<meta name="theme-color" content="#00bcd1" />
<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].43/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected].44/dist/index.css" />
<link rel="stylesheet" href="https://unpkg.com/@egovernments/[email protected]/dist/index.css" />


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}, {});
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -154,7 +161,7 @@ const InboxFilterWrapper = (props) => {
/>
</LabelFieldPair>
)}
{props.isEstimate &&
{props.isPlanInbox &&
<Fragment>
<LabelFieldPair vertical>
<div className="custom-filter-names">{t("MP_VILLAGE_ROAD_CONDITION")}</div>
Expand Down Expand Up @@ -185,8 +192,8 @@ const InboxFilterWrapper = (props) => {
<Dropdown
option={planFacility}
optionKey={"code"}
selected={filterValues["facilityName"] || defaultSelectedOptions?.facilityName }
select={(value) => handleDropdownChange("facilityName", value)}
selected={filterValues["facilityId"] || defaultSelectedOptions?.facilityId }
select={(value) => handleDropdownChange("facilityId", value)}
t={t}
disabled={false}
/>
Expand All @@ -209,7 +216,7 @@ const InboxFilterWrapper = (props) => {
vertical
style={{ paddingBottom: isLastElement ? "1rem" : "0" }}
>
<div className="custom-filter-names">{t(`MP_SECURITY_QUESTION ${index+1}`)}</div>
<div className="custom-filter-names">{t(`MP_SECURITY_QUESTION ${index + 1}`)}</div>
<Dropdown
option={options}
optionKey={"code"}
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,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([]);
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -885,7 +885,7 @@ const PlanInbox = () => {
}}
>
<InboxFilterWrapper
isEstimate={true}
isPlanInbox={true}
options={activeFilter}
onApplyFilters={onFilter}
clearFilters={clearFilters}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -640,7 +640,7 @@ const PopInbox = () => {

<div className="pop-inbox-wrapper-filter-table-wrapper" style={{ marginBottom: (isRootApprover && isStatusConditionMet(totalStatusCount) && planObject?.status === "CENSUS_DATA_APPROVAL_IN_PROGRESS") || (!isRootApprover && totalcount===0) || disabledAction ? "2.5rem" : "0rem" }}>
<InboxFilterWrapper
isEstimate={false}
isPlanInbox={false}
options={activeFilter}
onApplyFilters={onFilter}
clearFilters={clearFilters}
Expand Down

0 comments on commit 602bb0c

Please sign in to comment.