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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    surgery_case: '',
    
    
    
    
    
    medications: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    start_time: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    end_time: '',
    
    
    
    
    
    
    
    
    
    
    
    recovery_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    price: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    
    // get from url params
    const { dateRangeStart, dateRangeEnd } = router.query
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/anesthesia_records/anesthesia_records-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    start_time: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    end_time: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>





















  <FormField label="الحالةالجراحية" labelFor="surgery_case">
      <Field name="surgery_case" id="surgery_case" component={SelectField} options={[]} itemRef={'surgery_cases'}></Field>
  </FormField>











    <FormField label="موادالتخدير" hasTextareaHeight>
        <Field name="medications" as="textarea" placeholder="موادالتخدير" />
    </FormField>



































  <FormField
      label="ساعةالدخول"
  >
      <Field
          type="datetime-local"
          name="start_time"
          placeholder="ساعةالدخول"
      />
  </FormField>



























  <FormField
      label="ساعةالخروج"
  >
      <Field
          type="datetime-local"
          name="end_time"
          placeholder="ساعةالخروج"
      />
  </FormField>



















    <FormField label="سجلالاستفاقة" hasTextareaHeight>
        <Field name="recovery_notes" as="textarea" placeholder="سجلالاستفاقة" />
    </FormField>































    <FormField
        label="سعرالتخدير"
    >
        <Field
            type="number"
            name="price"
            placeholder="سعرالتخدير"
        />
    </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('/anesthesia_records/anesthesia_records-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Anesthesia_recordsNew
