-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added routing for project and created prototype of landing page
- Loading branch information
Showing
6 changed files
with
85 additions
and
8 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
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
Empty file.
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,43 @@ | ||
import * as React from 'react'; | ||
import { Formik, Field, Form, FormikHelpers } from 'formik'; | ||
import { useHistory } from 'react-router-dom'; | ||
|
||
interface Values { | ||
id: number; // Selected questionnaire's id | ||
} | ||
|
||
const questionnaireIds = [2638765, 2638766, 2638767, 2638768, 2638769]; // hardcoded for now | ||
const idList = questionnaireIds.map((id) => <option value={id}>{id}</option>); | ||
|
||
const LandingPage = () => { | ||
const history = useHistory(); | ||
|
||
return ( | ||
<div> | ||
<h1>Select a questionnaire by id</h1> | ||
<Formik | ||
initialValues={{ | ||
id: questionnaireIds[0], | ||
}} | ||
onSubmit={(values: Values, { setSubmitting }: FormikHelpers<Values>) => { | ||
console.log(JSON.stringify(values, null, 2)); // for debugging | ||
setSubmitting(false); | ||
history.push({ | ||
pathname: `/form`, | ||
search: `?id=${values.id}`, | ||
}); | ||
}} | ||
> | ||
<Form> | ||
<Field as="select" name="id"> | ||
{idList} | ||
</Field> | ||
|
||
<button type="submit">Submit</button> | ||
</Form> | ||
</Formik> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LandingPage; |
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