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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    prescription: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    from_organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    to_patient: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    to_organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    dispatched_by_doctor: '',
    
    
    
    
    
    
    
    
    
    dispatched_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    expected_delivery_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    delivered_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    dispatch_status: 'created',
    
    
    
    
    
    
    
    tracking_reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_known_latitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_known_longitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    delivery_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="FromOrganization" labelFor="from_organization">
      <Field name="from_organization" id="from_organization" component={SelectField} options={[]} itemRef={'organizations'}></Field>
  </FormField>



























  <FormField label="ToPatient" labelFor="to_patient">
      <Field name="to_patient" id="to_patient" component={SelectField} options={[]} itemRef={'patient_profiles'}></Field>
  </FormField>



























  <FormField label="ToOrganization" labelFor="to_organization">
      <Field name="to_organization" id="to_organization" component={SelectField} options={[]} itemRef={'organizations'}></Field>
  </FormField>



























  <FormField label="DispatchedByDoctor" labelFor="dispatched_by_doctor">
      <Field name="dispatched_by_doctor" id="dispatched_by_doctor" component={SelectField} options={[]} itemRef={'doctor_profiles'}></Field>
  </FormField>



















  <FormField
      label="DispatchedAt"
  >
      <Field
          type="datetime-local"
          name="dispatched_at"
          placeholder="DispatchedAt"
      />
  </FormField>



























  <FormField
      label="ExpectedDeliveryAt"
  >
      <Field
          type="datetime-local"
          name="expected_delivery_at"
          placeholder="ExpectedDeliveryAt"
      />
  </FormField>



























  <FormField
      label="DeliveredAt"
  >
      <Field
          type="datetime-local"
          name="delivered_at"
          placeholder="DeliveredAt"
      />
  </FormField>































  <FormField label="DispatchStatus" labelFor="dispatch_status">
      <Field name="dispatch_status" id="dispatch_status" component="select">
      
        <option value="created">created</option>
      
        <option value="packed">packed</option>
      
        <option value="in_transit">in_transit</option>
      
        <option value="delivered">delivered</option>
      
        <option value="failed">failed</option>
      
        <option value="returned">returned</option>
      
        <option value="cancelled">cancelled</option>
      
      </Field>
  </FormField>













  <FormField
      label="TrackingReference"
  >
      <Field
          name="tracking_reference"
          placeholder="TrackingReference"
      />
  </FormField>

































    <FormField
        label="LastKnownLatitude"
    >
        <Field
            type="number"
            name="last_known_latitude"
            placeholder="LastKnownLatitude"
        />
    </FormField>



























    <FormField
        label="LastKnownLongitude"
    >
        <Field
            type="number"
            name="last_known_longitude"
            placeholder="LastKnownLongitude"
        />
    </FormField>























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

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

export default Medicine_dispatchesNew
