Skip to content

Commit

Permalink
Merge pull request #283 from akvo/develop
Browse files Browse the repository at this point in the history
[#202] Fix explore studies page filter feature
  • Loading branch information
wayangalihpratama authored Feb 14, 2024
2 parents b94a08b + bb8c653 commit 2e97b7b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ const ChartMonetaryContribution = ({
replacedCurrentValues
) + data.total_current_diversified_income;
const resValue = newTotalValue - data.total_current_income;
// CoP
if (d.toLowerCase().includes("cost")) {
return resValue * -1;
}
// CoP - multiplied by 1
// if (d.toLowerCase().includes("cost")) {
// return resValue * -1;
// }
return resValue;
}
return 0;
Expand Down
14 changes: 11 additions & 3 deletions frontend/src/pages/explore-studies/ExploreStudiesPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -331,12 +331,13 @@ const ExploreStudiesPage = () => {
});
fetchReferenceData(country, commodity, driver, source);
} else {
setFilterInitialValues({});
fetchReferenceData();
const { country, commodity, driver, source } = filterInitialValues;
fetchReferenceData(country, commodity, driver, source);
}
}, [fetchReferenceData, currentPage, location]);
}, [fetchReferenceData, currentPage, location, filterInitialValues]);

const onFilter = (values) => {
setCurrentPage(1);
const { country, commodity, driver, source } = values;
if (countryId && commodityId && driverId) {
setFilterInitialValues({});
Expand All @@ -349,11 +350,18 @@ const ExploreStudiesPage = () => {
},
});
} else {
setFilterInitialValues({
country: country,
commodity: commodity,
driver: driver,
source: source,
});
fetchReferenceData(country, commodity, driver, source);
}
};

const handleClearFilter = () => {
setCurrentPage(1);
form.resetFields();
if (countryId && commodityId && driverId) {
setFilterInitialValues({});
Expand Down

0 comments on commit 2e97b7b

Please # to comment.