Skip to content

Commit

Permalink
(feat) Support for static specific answers (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
icrc-jofrancisco authored Dec 11, 2024
1 parent 23df68f commit f8fc00c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/hooks/useSpecificQuestions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,24 @@ function getQuestions(specificQuestions: Array<SpecificQuestionConfig>, formSche
.map((question) => {
const specificQuestion = specificQuestionsMap.get(question.id) || {};

const answers =
(specificQuestion as SpecificQuestionConfig).answers?.map((a) => ({
value: a,
display: conceptLabels[a]?.display,
})) ||
(question.questionOptions.answers ?? []).map((answer) => ({
value: answer.concept,
display: answer.label ?? conceptLabels[answer.concept]?.display,
}));

return {
question: {
display: question.label ?? conceptLabels[question.questionOptions.concept]?.display,
id: question.id,
disabled: (specificQuestion as SpecificQuestionConfig).disabled,
defaultAnswer: (specificQuestion as SpecificQuestionConfig).defaultAnswer,
},
answers: (question.questionOptions.answers ?? []).map((answer) => ({
value: answer.concept,
display: answer.label ?? conceptLabels[answer.concept]?.display,
})),
answers,
};
}),
),
Expand Down
1 change: 1 addition & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ export interface SpecificQuestion {
export interface SpecificQuestionConfig {
forms: Array<string>;
questionId: string;
answers?: Array<string>;
defaultAnswer?: string;
disabled?: boolean;
}

0 comments on commit f8fc00c

Please sign in to comment.