Skip to content

Commit

Permalink
Get study info externally
Browse files Browse the repository at this point in the history
  • Loading branch information
mpgxvii committed Jul 19, 2024
1 parent d5a29ad commit bedd22d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 10 deletions.
29 changes: 29 additions & 0 deletions data/study-questionnaire.ts
Original file line number Diff line number Diff line change
@@ -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: "",
},
]
35 changes: 25 additions & 10 deletions pages/study.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@ 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"

// 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.
Expand All @@ -21,19 +23,11 @@ const Study: NextPage = () => {
<>
<Head>
<title>Welcome</title>
<meta name="description" content="NextJS + React + Vercel + Ory" />
</Head>
<MarginCard>
<CardTitle>EDIFY Research Study</CardTitle>
<CardTitle>{projectId} Research Study</CardTitle>
<img src="image.png" />
<div className="center">
<label className="inputLabel">Study Overview</label>
<InnerCard>
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.
</InnerCard>
</div>
<StudyInfo questions={studyInfo} />
<TextCenterButton
className=""
disabled=""
Expand All @@ -48,4 +42,25 @@ const Study: NextPage = () => {
)
}

const StudyInfo: React.FC<any> = ({ questions }) => {
return (
<div className="center">
{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) => (
<div key={`${index}-${idx}`}>
<label className="inputLabel">{info.code}</label>
<InnerCard>{info.label}</InnerCard>
</div>
))
)
}
return null
})}
</div>
)
}

export default Study

0 comments on commit bedd22d

Please sign in to comment.