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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    sample: '',
    
    
    
    
    
    
    
    
    
    event_time: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    event_type: 'collected',
    
    
    
    
    
    
    
    from_party: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    to_party: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    location: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    shipping_reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    recorded_by: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



















  <FormField
      label="EventTime"
  >
      <Field
          type="datetime-local"
          name="event_time"
          placeholder="EventTime"
      />
  </FormField>































  <FormField label="EventType" labelFor="event_type">
      <Field name="event_type" id="event_type" component="select">
      
        <option value="collected">collected</option>
      
        <option value="sealed">sealed</option>
      
        <option value="shipped">shipped</option>
      
        <option value="received">received</option>
      
        <option value="prepared">prepared</option>
      
        <option value="subsampled">subsampled</option>
      
        <option value="analyzed">analyzed</option>
      
        <option value="stored">stored</option>
      
        <option value="disposed">disposed</option>
      
      </Field>
  </FormField>













  <FormField
      label="FromParty"
  >
      <Field
          name="from_party"
          placeholder="FromParty"
      />
  </FormField>



























  <FormField
      label="ToParty"
  >
      <Field
          name="to_party"
          placeholder="ToParty"
      />
  </FormField>



























  <FormField
      label="Location"
  >
      <Field
          name="location"
          placeholder="Location"
      />
  </FormField>



























  <FormField
      label="ShippingReference"
  >
      <Field
          name="shipping_reference"
          placeholder="ShippingReference"
      />
  </FormField>































      <FormField label='Notes' hasTextareaHeight>
          <Field
              name='notes'
              id='notes'
              component={RichTextField}
          ></Field>
      </FormField>









































  <FormField label="RecordedBy" labelFor="recorded_by">
      <Field name="recorded_by" id="recorded_by" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>



























  <FormField label="organizations" labelFor="organizations">
      <Field name="organizations" id="organizations" component={SelectField} options={[]} itemRef={'organizations'}></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('/chain_of_custody_events/chain_of_custody_events-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Chain_of_custody_eventsNew
