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/clinical_reports/clinical_reportsSlice'
import { useAppDispatch } from '../../stores/hooks'
import { useRouter } from 'next/router'
import moment from 'moment';

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    patient: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    generated_by_user: '',
    
    
    
    
    
    
    
    
    
    period_start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    period_end_at: '',
    
    
    
    
    
    
    
    
    
    
    report_title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    report_file: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    share_scope: 'family',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    accounts: '',
    
    
    
}


const Clinical_reportsNew = () => {
  const router = useRouter()
  const dispatch = useAppDispatch()

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/clinical_reports/clinical_reports-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="Generatedbyuser" labelFor="generated_by_user">
      <Field name="generated_by_user" id="generated_by_user" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>



















  <FormField
      label="Periodstartat"
  >
      <Field
          type="datetime-local"
          name="period_start_at"
          placeholder="Periodstartat"
      />
  </FormField>



























  <FormField
      label="Periodendat"
  >
      <Field
          type="datetime-local"
          name="period_end_at"
          placeholder="Periodendat"
      />
  </FormField>

















  <FormField
      label="Reporttitle"
  >
      <Field
          name="report_title"
          placeholder="Reporttitle"
      />
  </FormField>































      <FormField label='Summary' hasTextareaHeight>
          <Field
              name='summary'
              id='summary'
              component={RichTextField}
          ></Field>
      </FormField>














































  <FormField>
      <Field
          label='Reportfile'
          color='info'
          icon={mdiUpload}
          path={'clinical_reports/report_file'}
          name='report_file'
          id='report_file'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>


















  <FormField label="Sharescope" labelFor="share_scope">
      <Field name="share_scope" id="share_scope" component="select">
      
        <option value="family">family</option>
      
        <option value="clinicians">clinicians</option>
      
        <option value="admin">admin</option>
      
      </Field>
  </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('/clinical_reports/clinical_reports-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

Clinical_reportsNew.getLayout = function getLayout(page: ReactElement) {
  return (
      <LayoutAuthenticated
        
          permission={'CREATE_CLINICAL_REPORTS'}
        
      >
          {page}
      </LayoutAuthenticated>
  )
}

export default Clinical_reportsNew
