From 7daf96d15dc884becbf727b4688281a79b32d43f Mon Sep 17 00:00:00 2001 From: 9sneha-n <9sneha.n@gmail.com> Date: Fri, 26 Apr 2024 02:21:31 +0530 Subject: [PATCH] fix: handle reset of species question --- src/webapp/components/survey/GridSection.tsx | 31 ++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/webapp/components/survey/GridSection.tsx b/src/webapp/components/survey/GridSection.tsx index 7dd5bc1..88edd6b 100644 --- a/src/webapp/components/survey/GridSection.tsx +++ b/src/webapp/components/survey/GridSection.tsx @@ -26,8 +26,8 @@ interface GridSectionProps { export const GridSection: React.FC = React.memo( ({ speciesSection, antibioticStage, updateQuestion, viewOnly }) => { - const [gridOptions, setGridOptions] = useState(); const { getAntibioticOptions } = useASTGuidelinesOptions(); + const [gridOptions, setGridOptions] = useState(); const [antibioticSets, setAntibioticSets] = useState(); useEffect(() => { @@ -77,10 +77,37 @@ export const GridSection: React.FC = React.memo( if (question.type === "select" && isSpeciesQuestion(question)) { const options = getAntibioticOptions(question); setGridOptions(options); + antibioticSets?.map(antibioticSet => { + if (antibioticSet.addNewAntibioticQuestion?.value) { + updateQuestion({ + ...antibioticSet.addNewAntibioticQuestion, + value: false, + }); + } + if (antibioticSet.antibioticQuestion?.value) { + updateQuestion({ + ...antibioticSet.antibioticQuestion, + value: undefined, + }); + } + + if (antibioticSet.astResultsQuestion?.value) { + updateQuestion({ + ...antibioticSet.astResultsQuestion, + value: undefined, + }); + } + if (antibioticSet.valueQuestion?.value) { + updateQuestion({ + ...antibioticSet.valueQuestion, + value: undefined, + }); + } + }); } updateQuestion(question); }, - [getAntibioticOptions, updateQuestion] + [antibioticSets, getAntibioticOptions, updateQuestion, setGridOptions] ); return (