Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
Merge pull request #229 from kkchu791/create_participant
Browse files Browse the repository at this point in the history
#228: Add create participant logic for intake form
  • Loading branch information
abregorivas authored Aug 13, 2019
2 parents 1c2792a + d6f7468 commit 1e06b81
Show file tree
Hide file tree
Showing 3 changed files with 71 additions and 39 deletions.
16 changes: 16 additions & 0 deletions main-app/client/src/actions/participant.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,20 @@ export const updateParticipant = (id, data) => {
.catch(err => err)
}

export const createParticipant = (data) => {
const authToken = UserAuth.getAuthToken()
let config = {
headers: {
Authorization: `Bearer ${authToken}`,
},
}
return axios
.post(`${API_BASE_URL}/participants`, { data, timeout: 5000 }, config)
.then(res => {
console.log(res)
return res.data
})
.catch(err => err)
}

export default updateParticipant
41 changes: 2 additions & 39 deletions main-app/client/src/components/Intake/Intake.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,9 @@ import IntakeForm from './IntakeForm'
import { Formik, Form } from 'formik'
import { Button } from '@material-ui/core'
import FormTabs from '../Form/FormTabs'
import ClinicFormGroup from './ClinicFormGroup'
import ContactInfoFormGroup from './ContactInfoFormGroup'
import GeneralInfoFormGroup from './GeneralInfoFormGroup'
import FamilyAndIncomeFormGroup from './FamilyAndIncomeFormGroup'
import ProgramInfoFormGroup from './ProgramInfoFormGroup'
import OnsiteObligationsFormGroup from './OnsiteObligationsFormGroup'
import AgreementsFormGroup from './AgreementsFormGroup'
import PersonalInfoForm from './PersonalInfoForm'
import { Grid } from '@material-ui/core'

export const Intake = () => {
Expand All @@ -31,40 +27,7 @@ export const Intake = () => {
{
label: 'Personal Information',
Form: () => (
<Formik onSubmit={values => console.log(values)}>
{props => (
<Form>
<ClinicFormGroup {...props} />
<ContactInfoFormGroup {...props} />
<GeneralInfoFormGroup {...props} />
<FamilyAndIncomeFormGroup {...props} />
<AgreementsFormGroup {...props} />
{/*The rest of the form groups could go here */}
<br />
<br />
<Grid container justify="center" spacing={4}>
<Grid item xs={6}>
<Button
variant="contained"
size="large"
color="default"
>
Save For Later
</Button>
</Grid>
<Grid item xs={6}>
<Button
variant="contained"
size="large"
color="primary"
>
Continue to Obligations
</Button>
</Grid>
</Grid>
</Form>
)}
</Formik>
<PersonalInfoForm />
),
},
{
Expand Down
53 changes: 53 additions & 0 deletions main-app/client/src/components/Intake/PersonalInfoForm.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import React from 'react'
import { Formik, Form } from 'formik'
import { Button } from '@material-ui/core'
import ClinicFormGroup from './ClinicFormGroup'
import ContactInfoFormGroup from './ContactInfoFormGroup'
import GeneralInfoFormGroup from './GeneralInfoFormGroup'
import FamilyAndIncomeFormGroup from './FamilyAndIncomeFormGroup'
import AgreementsFormGroup from './AgreementsFormGroup'
import { Grid } from '@material-ui/core'
import {createParticipant} from '../../actions/participant'

const PersonalInfoForm = () => {
return (
<Formik onSubmit={values => console.log(values, "onSubmit")}>
{props => (
<Form>
<ClinicFormGroup {...props} />
<ContactInfoFormGroup {...props} />
<GeneralInfoFormGroup {...props} />
<FamilyAndIncomeFormGroup {...props} />
<AgreementsFormGroup {...props} />
{/*The rest of the form groups could go here */}
<br />
<br />
<Grid container justify="center" spacing={4}>
<Grid item xs={6}>
<Button
variant="contained"
size="large"
color="default"
onClick={() => createParticipant(props.values)}
>
Save and Exit
</Button>
</Grid>
<Grid item xs={6}>
<Button
variant="contained"
size="large"
color="primary"
onClick={() => createParticipant(props.values)}
>
Save and Continue
</Button>
</Grid>
</Grid>
</Form>
)}
</Formik>
)
}

export default PersonalInfoForm

0 comments on commit 1e06b81

Please sign in to comment.