534 lines
5.7 KiB
TypeScript
534 lines
5.7 KiB
TypeScript
import { mdiAccount, mdiChartTimelineVariant, mdiMail, mdiUpload } from '@mdi/js'
|
|
import Head from 'next/head'
|
|
import React, { ReactElement } from 'react'
|
|
import CardBox from '../../components/CardBox'
|
|
import LayoutAuthenticated from '../../layouts/Authenticated'
|
|
import SectionMain from '../../components/SectionMain'
|
|
import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton'
|
|
import { getPageTitle } from '../../config'
|
|
|
|
import { Field, Form, Formik } from 'formik'
|
|
import FormField from '../../components/FormField'
|
|
import BaseDivider from '../../components/BaseDivider'
|
|
import BaseButtons from '../../components/BaseButtons'
|
|
import BaseButton from '../../components/BaseButton'
|
|
import FormCheckRadio from '../../components/FormCheckRadio'
|
|
import FormCheckRadioGroup from '../../components/FormCheckRadioGroup'
|
|
import FormFilePicker from '../../components/FormFilePicker'
|
|
import FormImagePicker from '../../components/FormImagePicker'
|
|
import { SwitchField } from '../../components/SwitchField'
|
|
|
|
import { SelectField } from '../../components/SelectField'
|
|
import { SelectFieldMany } from "../../components/SelectFieldMany";
|
|
import {RichTextField} from "../../components/RichTextField";
|
|
|
|
import { create } from '../../stores/cognitive_sessions/cognitive_sessionsSlice'
|
|
import { useAppDispatch } from '../../stores/hooks'
|
|
import { useRouter } from 'next/router'
|
|
import moment from 'moment';
|
|
|
|
const initialValues = {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
patient: '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
program: '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
started_by_user: '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
started_at: '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ended_at: '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
completion_status: 'in_progress',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
total_score: '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
session_notes: '',
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
accounts: '',
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
const Cognitive_sessionsNew = () => {
|
|
const router = useRouter()
|
|
const dispatch = useAppDispatch()
|
|
|
|
|
|
|
|
|
|
const handleSubmit = async (data) => {
|
|
await dispatch(create(data))
|
|
await router.push('/cognitive_sessions/cognitive_sessions-list')
|
|
}
|
|
return (
|
|
<>
|
|
<Head>
|
|
<title>{getPageTitle('New Item')}</title>
|
|
</Head>
|
|
<SectionMain>
|
|
<SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
|
|
{''}
|
|
</SectionTitleLineWithButton>
|
|
<CardBox>
|
|
<Formik
|
|
initialValues={
|
|
|
|
initialValues
|
|
|
|
}
|
|
onSubmit={(values) => handleSubmit(values)}
|
|
>
|
|
<Form>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<FormField label="Patient" labelFor="patient">
|
|
<Field name="patient" id="patient" component={SelectField} options={[]} itemRef={'patients'}></Field>
|
|
</FormField>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<FormField label="Program" labelFor="program">
|
|
<Field name="program" id="program" component={SelectField} options={[]} itemRef={'cognitive_programs'}></Field>
|
|
</FormField>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<FormField label="Startedbyuser" labelFor="started_by_user">
|
|
<Field name="started_by_user" id="started_by_user" component={SelectField} options={[]} itemRef={'users'}></Field>
|
|
</FormField>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<FormField
|
|
label="Startedat"
|
|
>
|
|
<Field
|
|
type="datetime-local"
|
|
name="started_at"
|
|
placeholder="Startedat"
|
|
/>
|
|
</FormField>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<FormField
|
|
label="Endedat"
|
|
>
|
|
<Field
|
|
type="datetime-local"
|
|
name="ended_at"
|
|
placeholder="Endedat"
|
|
/>
|
|
</FormField>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<FormField label="Completionstatus" labelFor="completion_status">
|
|
<Field name="completion_status" id="completion_status" component="select">
|
|
|
|
<option value="in_progress">in_progress</option>
|
|
|
|
<option value="completed">completed</option>
|
|
|
|
<option value="abandoned">abandoned</option>
|
|
|
|
</Field>
|
|
</FormField>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<FormField
|
|
label="Totalscore"
|
|
>
|
|
<Field
|
|
type="number"
|
|
name="total_score"
|
|
placeholder="Totalscore"
|
|
/>
|
|
</FormField>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<FormField label="Sessionnotes" hasTextareaHeight>
|
|
<Field name="session_notes" as="textarea" placeholder="Sessionnotes" />
|
|
</FormField>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<FormField label="accounts" labelFor="accounts">
|
|
<Field name="accounts" id="accounts" component={SelectField} options={[]} itemRef={'accounts'}></Field>
|
|
</FormField>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<BaseDivider />
|
|
<BaseButtons>
|
|
<BaseButton type="submit" color="info" label="Submit" />
|
|
<BaseButton type="reset" color="info" outline label="Reset" />
|
|
<BaseButton type='reset' color='danger' outline label='Cancel' onClick={() => router.push('/cognitive_sessions/cognitive_sessions-list')}/>
|
|
</BaseButtons>
|
|
</Form>
|
|
</Formik>
|
|
</CardBox>
|
|
</SectionMain>
|
|
</>
|
|
)
|
|
}
|
|
|
|
Cognitive_sessionsNew.getLayout = function getLayout(page: ReactElement) {
|
|
return (
|
|
<LayoutAuthenticated
|
|
|
|
permission={'CREATE_COGNITIVE_SESSIONS'}
|
|
|
|
>
|
|
{page}
|
|
</LayoutAuthenticated>
|
|
)
|
|
}
|
|
|
|
export default Cognitive_sessionsNew
|