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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    prescription_date: '',
    
    
    
    
    
    
    
    
    
    
    right_sphere: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    right_cylinder: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    right_axis: '',
    
    
    
    
    
    
    
    
    
    
    
    
    left_sphere: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    left_cylinder: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    left_axis: '',
    
    
    
    
    
    
    
    
    
    
    
    
    add_power: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    pupillary_distance_mm: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    optometrist: '',
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



















  <FormField
      label="PrescriptionDate"
  >
      <Field
          type="datetime-local"
          name="prescription_date"
          placeholder="PrescriptionDate"
      />
  </FormField>























    <FormField
        label="RightSphere"
    >
        <Field
            type="number"
            name="right_sphere"
            placeholder="RightSphere"
        />
    </FormField>



























    <FormField
        label="RightCylinder"
    >
        <Field
            type="number"
            name="right_cylinder"
            placeholder="RightCylinder"
        />
    </FormField>



























    <FormField
        label="RightAxis"
    >
        <Field
            type="number"
            name="right_axis"
            placeholder="RightAxis"
        />
    </FormField>



























    <FormField
        label="LeftSphere"
    >
        <Field
            type="number"
            name="left_sphere"
            placeholder="LeftSphere"
        />
    </FormField>



























    <FormField
        label="LeftCylinder"
    >
        <Field
            type="number"
            name="left_cylinder"
            placeholder="LeftCylinder"
        />
    </FormField>



























    <FormField
        label="LeftAxis"
    >
        <Field
            type="number"
            name="left_axis"
            placeholder="LeftAxis"
        />
    </FormField>



























    <FormField
        label="AddPower"
    >
        <Field
            type="number"
            name="add_power"
            placeholder="AddPower"
        />
    </FormField>



























    <FormField
        label="PupillaryDistance(mm)"
    >
        <Field
            type="number"
            name="pupillary_distance_mm"
            placeholder="PupillaryDistance(mm)"
        />
    </FormField>







































  <FormField label="Optometrist" labelFor="optometrist">
      <Field name="optometrist" id="optometrist" component={SelectField} options={[]} itemRef={'healthcare_providers'}></Field>
  </FormField>











    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </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('/vision_prescriptions/vision_prescriptions-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Vision_prescriptionsNew
