|
|
@ -175,8 +175,15 @@ function getOrderedFields( |
|
|
return orderedFields; |
|
|
return orderedFields; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function getCurrentStep(fields: MarriageField[]) { |
|
|
|
|
|
return fields.filter((field) => hasQuestionAnswerValue(field.value)).length; |
|
|
|
|
|
|
|
|
function getCurrentStep(fields: MarriageField[], questions: readonly QuestionField[]) { |
|
|
|
|
|
return questions.filter((question, index) => { |
|
|
|
|
|
if (!question.required || question.logic?.dependsOn) { |
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
const key = getQuestionFieldKey(question, index); |
|
|
|
|
|
const field = fields.find((f) => f.key === key); |
|
|
|
|
|
return field && hasQuestionAnswerValue(field.value); |
|
|
|
|
|
}).length; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
function createPayload( |
|
|
function createPayload( |
|
|
@ -184,10 +191,13 @@ function createPayload( |
|
|
questions: readonly QuestionField[], |
|
|
questions: readonly QuestionField[], |
|
|
): UpdateMarriageSectionDataPayload { |
|
|
): UpdateMarriageSectionDataPayload { |
|
|
const fields = getOrderedFields(answers, questions); |
|
|
const fields = getOrderedFields(answers, questions); |
|
|
|
|
|
const targetQuestions = questions.filter( |
|
|
|
|
|
(q) => q.required && !q.logic?.dependsOn |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
current_step: getCurrentStep(fields), |
|
|
|
|
|
total_steps: questions.length, |
|
|
|
|
|
|
|
|
current_step: getCurrentStep(fields, questions), |
|
|
|
|
|
total_steps: targetQuestions.length, |
|
|
fields, |
|
|
fields, |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
|