Skip to content

Commit

Permalink
Merge pull request #84 from akvo/feature/83-manual-target-not-loaded-…
Browse files Browse the repository at this point in the history
…correctly

[#83] Fix manual target value load
  • Loading branch information
dedenbangkit authored Nov 9, 2023
2 parents 6c4db60 + 0ae6c40 commit 454519b
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend/src/pages/cases/components/IncomeDriverTarget.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,11 @@ const IncomeDriverTarget = ({

const onValuesChange = (changedValues, allValues) => {
const { target, region } = allValues;
const regionData = { region: region };
const HHSize = calculateHouseholdSize(allValues);
setHouseholdSize(HHSize);
// eslint-disable-next-line no-undefined
if (changedValues.manual_target !== undefined) {
// manual target
setDisableTarget(!changedValues.manual_target);
if (changedValues.manual_target && target) {
form.setFieldsValue({ region: null });
Expand All @@ -133,11 +133,13 @@ const IncomeDriverTarget = ({
updateFormValues({ region: null, target: 0 });
}
}
// manual target
if (changedValues.target && !disableTarget) {
setIncomeTarget(target);
updateFormValues({ ...regionData, target: target });
updateFormValues({ region: null, target: target });
}
if (changedValues.region && disableTarget) {
const regionData = { region: region };
// get from API
if (currentCase?.country && currentCase?.year && region) {
let url = `country_region_benchmark?country_id=${currentCase.country}`;
Expand Down

0 comments on commit 454519b

Please # to comment.