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 = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    requested_by_rural_doctor: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approved_by_admin: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    coordinated_by_city_doctor: '',
    
    
    
    
    
    
    
    
    
    requested_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approved_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    dispatched_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    delivered_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    dispatch_note: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    destination_address: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    destination_latitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    destination_longitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tracking_reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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="RequestedByRuralDoctor" labelFor="requested_by_rural_doctor">
      <Field name="requested_by_rural_doctor" id="requested_by_rural_doctor" component={SelectField} options={[]} itemRef={'rural_doctors'}></Field>
  </FormField>



























  <FormField label="ApprovedByAdmin" labelFor="approved_by_admin">
      <Field name="approved_by_admin" id="approved_by_admin" component={SelectField} options={[]} itemRef={'admins'}></Field>
  </FormField>



























  <FormField label="CoordinatedByCityDoctor" labelFor="coordinated_by_city_doctor">
      <Field name="coordinated_by_city_doctor" id="coordinated_by_city_doctor" component={SelectField} options={[]} itemRef={'city_doctors'}></Field>
  </FormField>



















  <FormField
      label="RequestedAt"
  >
      <Field
          type="datetime-local"
          name="requested_at"
          placeholder="RequestedAt"
      />
  </FormField>



























  <FormField
      label="ApprovedAt"
  >
      <Field
          type="datetime-local"
          name="approved_at"
          placeholder="ApprovedAt"
      />
  </FormField>



























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



























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































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="requested">requested</option>
      
        <option value="approved">approved</option>
      
        <option value="packed">packed</option>
      
        <option value="dispatched">dispatched</option>
      
        <option value="in_transit">in_transit</option>
      
        <option value="delivered">delivered</option>
      
        <option value="cancelled">cancelled</option>
      
      </Field>
  </FormField>















    <FormField label="DispatchNote" hasTextareaHeight>
        <Field name="dispatch_note" as="textarea" placeholder="DispatchNote" />
    </FormField>

























  <FormField
      label="DestinationAddress"
  >
      <Field
          name="destination_address"
          placeholder="DestinationAddress"
      />
  </FormField>

































    <FormField
        label="DestinationLatitude"
    >
        <Field
            type="number"
            name="destination_latitude"
            placeholder="DestinationLatitude"
        />
    </FormField>



























    <FormField
        label="DestinationLongitude"
    >
        <Field
            type="number"
            name="destination_longitude"
            placeholder="DestinationLongitude"
        />
    </FormField>





















  <FormField
      label="TrackingReference"
  >
      <Field
          name="tracking_reference"
          placeholder="TrackingReference"
      />
  </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
