From ecc419c69a30751fafd9e16f91d364c4f6676813 Mon Sep 17 00:00:00 2001 From: Nicholas Summers Date: Wed, 18 Sep 2024 14:34:46 -0400 Subject: [PATCH] Make it so 3c Part 5 Question 2 No doesnt crash page --- services/ui-src/src/components/fields/Integer.jsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/services/ui-src/src/components/fields/Integer.jsx b/services/ui-src/src/components/fields/Integer.jsx index 2841c2a3d..ecd344142 100644 --- a/services/ui-src/src/components/fields/Integer.jsx +++ b/services/ui-src/src/components/fields/Integer.jsx @@ -31,16 +31,16 @@ const getPrevYearValue = (question, lastYearFormData) => { // Get questions from last years JSON const questions = - lastYearFormData[3].contents.section.subsections[2].parts[partIndex] + lastYearFormData?.[3]?.contents.section.subsections[2].parts[partIndex] .questions; // Filter down to this question - const matchingQuestion = questions.filter( + const matchingQuestion = questions?.filter( (question) => fieldsetId === question?.fieldset_info?.id ); // The first will always be correct - if (matchingQuestion[0]) { + if (matchingQuestion?.[0]) { prevYearValue = matchingQuestion[0].questions[0].answer?.entry; } }