-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Resolves conflict with dev branch
- Loading branch information
Showing
12 changed files
with
1,298 additions
and
593 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import React, { useEffect, useState, useLayoutEffect, Fragment } from 'react'; | ||
import { Field, ErrorMessage } from 'formik'; | ||
import Question from './RegistrationQuestion'; | ||
|
||
/** | ||
*Display registration questions Component | ||
* | ||
* | ||
*/ | ||
|
||
function DisplayQuestion(props) { | ||
return ( | ||
<Fragment> | ||
{/* Display text input questions */} | ||
{props.obj.textInputQuestions?.map((inputObj) => ( | ||
<Question key={inputObj.id} type="text" question={inputObj} /> | ||
))} | ||
{/* Display number input questions */} | ||
{props.obj.numberInputQuestions?.map((inputObj) => ( | ||
<Question | ||
key={inputObj.id} | ||
type="number" | ||
question={inputObj} | ||
value={props.values[inputObj.name]} | ||
onChange={props.onChange} | ||
/> | ||
))} | ||
{/* Display dropdown input questions */} | ||
{props.obj.dropdownQuestions?.map((inputObj) => ( | ||
<Question key={inputObj.id} type="dropdown" question={inputObj} /> | ||
))} | ||
{/* Display datalist input questions */} | ||
{props.obj.datalistQuestions?.map((inputObj) => ( | ||
<Question key={inputObj.id} type="datalist" question={inputObj} /> | ||
))} | ||
{/* Display checkbox input questions */} | ||
{props.obj.checkboxQuestions?.map((inputObj) => ( | ||
<Question key={inputObj.id} type="checkbox" question={inputObj} /> | ||
))} | ||
{/* Display text area input questions */} | ||
{props.obj.textAreaQuestions?.map((inputObj) => ( | ||
<Question key={inputObj.id} type="textArea" question={inputObj} /> | ||
))} | ||
</Fragment> | ||
); | ||
} | ||
|
||
export default DisplayQuestion; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import React, { useEffect, useState, useLayoutEffect, Fragment } from 'react'; | ||
import { Field, ErrorMessage } from 'formik'; | ||
|
||
/** | ||
*Text input question Component | ||
* | ||
* | ||
*/ | ||
function Question(props) { | ||
if (props.type === 'text') { | ||
return ( | ||
<Fragment> | ||
<label htmlFor={props.question.id} className="mt-4"> | ||
{props.question.required ? '*' : ''} | ||
{props.question.question} | ||
</label> | ||
<Field | ||
id={props.question.id} | ||
name={props.question.name} | ||
className="border-2 border-gray-400 rounded-md p-1" | ||
/> | ||
<ErrorMessage | ||
name={props.question.name} | ||
render={(msg) => <div className="text-red-600">{msg}</div>} | ||
/> | ||
</Fragment> | ||
); | ||
} else if (props.type === 'number') { | ||
return ( | ||
<Fragment key={props.question.id}> | ||
<label htmlFor={props.question.id} className="mt-4"> | ||
{props.question.required ? '*' : ''} | ||
{props.question.question} | ||
</label> | ||
<input | ||
id={props.question.id} | ||
className="border-2 border-gray-400 rounded-md p-1" | ||
name={props.question.name} | ||
type="number" | ||
min={props.question.min} | ||
max={props.question.max} | ||
pattern={props.question.pattern} | ||
onChange={props.onChange} | ||
value={props.value} | ||
/> | ||
<ErrorMessage | ||
name={props.question.name} | ||
render={(msg) => <div className="text-red-600">{msg}</div>} | ||
/> | ||
</Fragment> | ||
); | ||
} else if (props.type === 'dropdown') { | ||
return ( | ||
<Fragment> | ||
<label htmlFor={props.question.id} className="mt-4"> | ||
{props.question.required ? '*' : ''} | ||
{props.question.question} | ||
</label> | ||
<Field | ||
as="select" | ||
name={props.question.name} | ||
id={props.question.id} | ||
className="border-2 border-gray-400 rounded-md p-1 mr-auto" | ||
> | ||
<option value="" disabled selected></option> | ||
{props.question.options.map((option) => ( | ||
<option key={option.value} value={option.value}> | ||
{option.title} | ||
</option> | ||
))} | ||
</Field> | ||
<ErrorMessage | ||
name={props.question.name} | ||
render={(msg) => <div className="text-red-600">{msg}</div>} | ||
/> | ||
</Fragment> | ||
); | ||
} else if (props.type === 'checkbox') { | ||
return ( | ||
<Fragment> | ||
<label htmlFor={props.question.name} className="mt-4"> | ||
{props.question.required ? '*' : ''} | ||
{props.question.question} | ||
</label> | ||
<div role="group" aria-labelledby="checkbox-group" className="flex flex-col"> | ||
{props.question.options.map((option) => ( | ||
<label key={option.value}> | ||
<Field type="checkbox" name={props.question.name} value={option.value} /> | ||
{option.title} | ||
</label> | ||
))} | ||
</div> | ||
<ErrorMessage | ||
name={props.question.name} | ||
render={(msg) => <div className="text-red-600">{msg}</div>} | ||
/> | ||
</Fragment> | ||
); | ||
} else if (props.type === 'datalist') { | ||
return ( | ||
<Fragment> | ||
<label htmlFor={props.question.name} className="mt-4"> | ||
{props.question.required ? '*' : ''} | ||
{props.question.question} | ||
</label> | ||
<Field | ||
type="text" | ||
id={props.question.id} | ||
name={props.question.name} | ||
list={props.question.datalist} | ||
className="border-2 border-gray-400 rounded-md p-1" | ||
autoComplete="off" | ||
></Field> | ||
<datalist id={props.question.datalist}> | ||
<option value="" disabled selected></option> | ||
</datalist> | ||
<ErrorMessage | ||
name={props.question.name} | ||
render={(msg) => <div className="text-red-600">{msg}</div>} | ||
/> | ||
</Fragment> | ||
); | ||
} else if (props.type === 'textArea') { | ||
return ( | ||
<Fragment> | ||
<label htmlFor={props.question.name} className="mt-4"> | ||
{props.question.required ? '*' : ''} | ||
{props.question.question} | ||
</label> | ||
<Field | ||
as="textarea" | ||
name={props.question.name} | ||
placeholder={props.question.placeholder} | ||
className="border-2 border-gray-400 rounded-md p-1" | ||
></Field> | ||
<ErrorMessage | ||
name={props.question.name} | ||
render={(msg) => <div className="text-red-600">{msg}</div>} | ||
/> | ||
</Fragment> | ||
); | ||
} | ||
} | ||
|
||
export default Question; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.