Skip to content

Commit 422a043

Browse files
committed
Fix bug with contact step
1 parent 62cc355 commit 422a043

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

app/mobile/screens/steps/CovidContactStep.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,23 +26,32 @@ export default function CovidContactStep(props) {
2626
{key: 'true', value: t('basics.yes')},
2727
{key: 'false', value: t('basics.no')},
2828
];
29-
29+
3030
const [selection, setSelection] = useState(props.caseReport.covid_contact !== undefined && props.caseReport.covid_contact !== null ? String(props.caseReport.covid_contact) : undefined);
3131

3232
const onSelect = item => {
3333
setSelection(item);
3434
if (AUTO_NEXT_ENABLED) {
3535
// onNext is triggers faster then the state change?
36-
props.onNext(getStateToBeSaved(item === 'true'));
36+
props.onNext(getStateToBeSaved(item));
3737
}
3838
};
3939

4040
const getStateToBeSaved = (status = null) => {
4141
const caseReport = {...props.caseReport};
4242

4343
if (status == null) {
44-
status = selection == 'true';
44+
status = selection;
45+
}
46+
47+
if (status === 'true') {
48+
caseReport.covid_contact = true;
4549
}
50+
51+
if (status === 'false') {
52+
caseReport.covid_contact = false;
53+
}
54+
4655
caseReport.covid_contact = status;
4756
return caseReport;
4857
};

0 commit comments

Comments
 (0)