From f8f050e76c5f65692fb4595e115b46a0260c1897 Mon Sep 17 00:00:00 2001 From: Simon Demaziere Date: Tue, 16 Apr 2024 10:35:06 +0200 Subject: [PATCH] fix: handle no identification data from API --- package.json | 2 +- src/utils/hooks/useIdentificationQuestions.js | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index f25f6ab1c..9c30790b5 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "pearl", - "version": "2.0.6", + "version": "2.0.7", "private": true, "dependencies": { "@emotion/react": "^11.11.1", diff --git a/src/utils/hooks/useIdentificationQuestions.js b/src/utils/hooks/useIdentificationQuestions.js index 6990be101..dc51f5542 100644 --- a/src/utils/hooks/useIdentificationQuestions.js +++ b/src/utils/hooks/useIdentificationQuestions.js @@ -62,7 +62,7 @@ export function useIdentificationQuestions(surveyUnit) { const question = { ...q, disabled: concluded, - answer: concluded ? undefined : getAnswerFromValue(q.type, surveyUnit.identification[key]), + answer: concluded ? undefined : getAnswerFromValue(q.type, surveyUnit?.identification?.[key]), }; if (question.answer?.concluding) { concluded = true; @@ -86,7 +86,7 @@ export function useIdentificationQuestions(surveyUnit) { const identification = Object.fromEntries( questions.map(question => { const key = question.type.toLowerCase(); - const previousAnswer = surveyUnit.identification[question.type.toLowerCase()]; + const previousAnswer = surveyUnit?.identification?.[question.type.toLowerCase()]; let newAnswer = question.type === answer.questionType ? answer.value : previousAnswer; // For a concluding answer, mark the questions as "concluded" for the next question if (question.type === answer.questionType && answer.concluding) {