Skip to content

Commit

Permalink
Changes to facility filter and security Question
Browse files Browse the repository at this point in the history
  • Loading branch information
abishekTa-egov committed Jan 8, 2025
1 parent dfcf608 commit 5137405
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,7 @@ const InboxFilterWrapper = (props) => {
// Default selected option
let defaultSelectedOptions = props.defaultValue
? Object.entries(props.defaultValue).reduce((acc, [key, value]) => {
if (key === "facilityId") {
acc[key] = { code: value?.code, name: `${t(key)} (${value})` };
} else if (value !== null) {
if (value !== null) {
acc[key] = { code: value, name: `${t(key)} (${value})` };
} else {
acc[key] = null;
Expand All @@ -34,9 +32,7 @@ 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
? key === 'facilityId'
? { code: value?.code }
: { code: value, name: `${t(key)} (${value})` }
? { code: value, name: `${t(key)} (${value})` }
: null;
return acc;
}, {});
Expand Down Expand Up @@ -71,10 +67,7 @@ const InboxFilterWrapper = (props) => {
if (props.onApplyFilters) {
const filtersToApply = {};
for (let key in filterValues) {
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')) {
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 @@ -192,8 +185,8 @@ const InboxFilterWrapper = (props) => {
<Dropdown
option={planFacility}
optionKey={"code"}
selected={filterValues["facilityId"] || defaultSelectedOptions?.facilityId }
select={(value) => handleDropdownChange("facilityId", value)}
selected={filterValues["facilityName"] || defaultSelectedOptions?.facilityName }
select={(value) => handleDropdownChange("facilityName", value)}
t={t}
disabled={false}
/>
Expand All @@ -209,18 +202,19 @@ const InboxFilterWrapper = (props) => {
}));

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

return (
<LabelFieldPair
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"}
selected={filterValues[`securityQ${index + 1}`]}
select={(value) => handleDropdownChange(`securityQ${index + 1}`, value)}
selected={filterValues[`securityQ${questionNumber}`]}
select={(value) => handleDropdownChange(`securityQ${questionNumber}`, value)}
t={t}
disabled={false}
/>
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,facilityId: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,7 +176,7 @@ const PlanInbox = () => {
...(selectedFilter?.terrain != null && { terrain: selectedFilter.terrain }),
...(selectedFilter?.securityQ1 != null && { securityQ1: selectedFilter.securityQ1 }),
...(selectedFilter?.securityQ2 != null && { securityQ2: selectedFilter.securityQ2 }),
...(selectedFilter?.facilityId?.id != null && { facilityId: selectedFilter.facilityId.id }),
...(selectedFilter?.facilityName != null && { facilityName: selectedFilter.facilityName }),
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?.facilityId?.id != null && { facilityId: selectedFilter.facilityId.id }),
...(selectedFilter?.facilityName != null && { facilityName: selectedFilter.facilityName }),

planConfigurationId: microplanId, //list of plan ids
limit: limitAndOffset?.limit,
Expand Down

0 comments on commit 5137405

Please sign in to comment.