diff --git a/src/components/Questionnaire/QuestionRenderer.tsx b/src/components/Questionnaire/QuestionRenderer.tsx index 13fb5df13bd..af0787838bb 100644 --- a/src/components/Questionnaire/QuestionRenderer.tsx +++ b/src/components/Questionnaire/QuestionRenderer.tsx @@ -4,10 +4,18 @@ import { cn } from "@/lib/utils"; import { QuestionValidationError } from "@/types/questionnaire/batch"; import { QuestionnaireResponse } from "@/types/questionnaire/form"; -import { Question } from "@/types/questionnaire/question"; +import { + Question, + StructuredQuestionType, +} from "@/types/questionnaire/question"; import { QuestionGroup } from "./QuestionTypes/QuestionGroup"; +// Questions that should be rendered full width +const FULL_WIDTH_QUESTION_TYPES: StructuredQuestionType[] = [ + "medication_request", +]; + interface QuestionRendererProps { questions: Question[]; responses: QuestionnaireResponse[]; @@ -57,11 +65,11 @@ export function QuestionRenderer({ onResponseChange(newResponses); }; - const isMedicationRequest = (question: Question): boolean => { - return ( - question.type === "structured" && - question.structured_type === "medication_request" - ); + const shouldBeFullWidth = (question: Question): boolean => { + if (question.type !== "structured" || !question.structured_type) { + return false; + } + return FULL_WIDTH_QUESTION_TYPES.includes(question.structured_type); }; return ( @@ -71,7 +79,7 @@ export function QuestionRenderer({ key={question.id} ref={(el) => (questionRefs.current[question.id] = el)} className={cn( - isMedicationRequest(question) ? "md:w-auto" : "max-w-4xl", + shouldBeFullWidth(question) ? "md:w-auto" : "max-w-4xl", )} >