|
|
|
@ -261,7 +261,18 @@ function createPayload( |
|
|
|
|
|
|
|
function fieldsToAnswers(fields: MarriageField[]) { |
|
|
|
return fields.reduce<QuestionAnswersByKey>((nextAnswers, field) => { |
|
|
|
if (field.option_id !== undefined && field.option_id !== null) { |
|
|
|
const isChoice = |
|
|
|
field.type === "dropdown" || |
|
|
|
field.type === "radio" || |
|
|
|
field.type === "checkbox" || |
|
|
|
field.type === "scale"; |
|
|
|
|
|
|
|
if ( |
|
|
|
isChoice && |
|
|
|
field.option_id !== undefined && |
|
|
|
field.option_id !== null && |
|
|
|
(!Array.isArray(field.option_id) || field.option_id.length > 0 || field.type === "checkbox") |
|
|
|
) { |
|
|
|
nextAnswers[field.key] = { |
|
|
|
...field, |
|
|
|
value: field.option_id, |
|
|
|
@ -640,11 +651,27 @@ export function QuestionAnswersProvider({ |
|
|
|
if (question) { |
|
|
|
// Only update if there are no newer local dirty edits for this key
|
|
|
|
if (!dirtyKeysRef.current.has(key)) { |
|
|
|
const isChoice = |
|
|
|
question.type === "dropdown" || |
|
|
|
question.type === "radio" || |
|
|
|
question.type === "checkbox" || |
|
|
|
question.type === "scale"; |
|
|
|
|
|
|
|
const resolvedVal = |
|
|
|
isChoice && |
|
|
|
answer.option_id !== undefined && |
|
|
|
answer.option_id !== null && |
|
|
|
(!Array.isArray(answer.option_id) || |
|
|
|
answer.option_id.length > 0 || |
|
|
|
question.type === "checkbox") |
|
|
|
? answer.option_id |
|
|
|
: answer.value; |
|
|
|
|
|
|
|
nextAnswers[key] = { |
|
|
|
key, |
|
|
|
label: question.title, |
|
|
|
type: question.type, |
|
|
|
value: answer.option_id ?? answer.value, |
|
|
|
value: resolvedVal, |
|
|
|
option_id: answer.option_id, |
|
|
|
} as MarriageField; |
|
|
|
} |
|
|
|
|