Skip to content

Commit

Permalink
Merge pull request #137 from InseeFr/fix-identification
Browse files Browse the repository at this point in the history
fix: handle no identification data from API
  • Loading branch information
MickaelMenet authored Apr 16, 2024
2 parents fe2cc1a + f8f050e commit 7809ee2
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pearl",
"version": "2.0.6",
"version": "2.0.7",
"private": true,
"dependencies": {
"@emotion/react": "^11.11.1",
Expand Down
4 changes: 2 additions & 2 deletions src/utils/hooks/useIdentificationQuestions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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) {
Expand Down

0 comments on commit 7809ee2

Please sign in to comment.