From bedd22d280a0d5ad2fa2bcc10e66ba7773b95a62 Mon Sep 17 00:00:00 2001 From: Pauline Date: Fri, 19 Jul 2024 19:46:25 +0100 Subject: [PATCH] Get study info externally --- data/study-questionnaire.ts | 29 +++++++++++++++++++++++++++++ pages/study.tsx | 35 +++++++++++++++++++++++++---------- 2 files changed, 54 insertions(+), 10 deletions(-) create mode 100644 data/study-questionnaire.ts diff --git a/data/study-questionnaire.ts b/data/study-questionnaire.ts new file mode 100644 index 0000000..6b0d067 --- /dev/null +++ b/data/study-questionnaire.ts @@ -0,0 +1,29 @@ +export const studyInfo = [ + { + field_name: "consent", + form_name: "consent", + section_header: "", + field_type: "info", + field_label: "", + select_choices_or_calculations: [ + { + label: + "This study aims to understand the effects of eating disorders. Participants will be askeed to fill out questionnaires and undergo non-invaise tests over the course of one year.", + code: "Study Overview", + }, + ], + field_note: "", + text_validation_type_or_show_slider_number: "", + text_validation_min: "", + text_validation_max: "", + identifier: "", + branching_logic: "", + required_field: "", + custom_alignment: "", + question_number: "", + matrix_group_name: "2MW", + matrix_ranking: "", + field_annotation: "", + evaluated_logic: "", + }, +] diff --git a/pages/study.tsx b/pages/study.tsx index 9ddc4a4..ccc8f92 100644 --- a/pages/study.tsx +++ b/pages/study.tsx @@ -2,6 +2,7 @@ import type { NextPage } from "next" import Head from "next/head" import { useRouter } from "next/router" import { useEffect, useState } from "react" +import { studyInfo } from "../data/study-questionnaire" // Import render helpers import { MarginCard, CardTitle, TextCenterButton, InnerCard } from "../pkg" @@ -9,6 +10,7 @@ import { MarginCard, CardTitle, TextCenterButton, InnerCard } from "../pkg" // Renders the eligibility page const Study: NextPage = () => { const router = useRouter() + const projectId = "EDIFY" useEffect(() => { // If the router is not ready yet, or we already have a flow, do nothing. @@ -21,19 +23,11 @@ const Study: NextPage = () => { <> Welcome - - EDIFY Research Study + {projectId} Research Study -
- - - This study aims to understand the effects of eating disorders. - Participants will be askeed to fill out questionnaires and undergo - non-invaise tests over the course of one year. - -
+ { ) } +const StudyInfo: React.FC = ({ questions }) => { + return ( +
+ {questions.map((question, index) => { + if (question.field_type === "info") { + return ( + question.select_choices_or_calculations instanceof Array && + question.select_choices_or_calculations.map((info, idx) => ( +
+ + {info.label} +
+ )) + ) + } + return null + })} +
+ ) +} + export default Study