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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    load: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    type: 'PICKUP',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'PLANNED',
    
    
    
    
    
    
    
    
    
    
    sequence: '',
    
    
    
    
    
    
    
    
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address_line1: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address_line2: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    postal_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    city: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    state: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    country_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    window_start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    window_end_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    planned_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    arrived_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    departed_at: '',
    
    
    
    
    
    
    
    
    
    
    contact_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    contact_phone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    contact_email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    instructions: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reference_no: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Load" labelFor="load">
      <Field name="load" id="load" component={SelectField} options={[]} itemRef={'loads'}></Field>
  </FormField>























  <FormField label="StopType" labelFor="type">
      <Field name="type" id="type" component="select">
      
        <option value="PICKUP">PICKUP</option>
      
        <option value="DELIVERY">DELIVERY</option>
      
        <option value="WAYPOINT">WAYPOINT</option>
      
        <option value="DEPOT">DEPOT</option>
      
        <option value="BORDER">BORDER</option>
      
        <option value="OTHER">OTHER</option>
      
      </Field>
  </FormField>



























  <FormField label="StopStatus" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="PLANNED">PLANNED</option>
      
        <option value="ARRIVED">ARRIVED</option>
      
        <option value="LOADED">LOADED</option>
      
        <option value="DEPARTED">DEPARTED</option>
      
        <option value="DELIVERED">DELIVERED</option>
      
        <option value="SKIPPED">SKIPPED</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Sequence"
    >
        <Field
            type="number"
            name="sequence"
            placeholder="Sequence"
        />
    </FormField>





















  <FormField
      label="Name"
  >
      <Field
          name="name"
          placeholder="Name"
      />
  </FormField>



























  <FormField
      label="AddressLine1"
  >
      <Field
          name="address_line1"
          placeholder="AddressLine1"
      />
  </FormField>



























  <FormField
      label="AddressLine2"
  >
      <Field
          name="address_line2"
          placeholder="AddressLine2"
      />
  </FormField>



























  <FormField
      label="PostalCode"
  >
      <Field
          name="postal_code"
          placeholder="PostalCode"
      />
  </FormField>



























  <FormField
      label="City"
  >
      <Field
          name="city"
          placeholder="City"
      />
  </FormField>



























  <FormField
      label="State"
  >
      <Field
          name="state"
          placeholder="State"
      />
  </FormField>



























  <FormField
      label="CountryCode"
  >
      <Field
          name="country_code"
          placeholder="CountryCode"
      />
  </FormField>





































  <FormField
      label="WindowStartAt"
  >
      <Field
          type="datetime-local"
          name="window_start_at"
          placeholder="WindowStartAt"
      />
  </FormField>



























  <FormField
      label="WindowEndAt"
  >
      <Field
          type="datetime-local"
          name="window_end_at"
          placeholder="WindowEndAt"
      />
  </FormField>



























  <FormField
      label="PlannedAt"
  >
      <Field
          type="datetime-local"
          name="planned_at"
          placeholder="PlannedAt"
      />
  </FormField>



























  <FormField
      label="ArrivedAt"
  >
      <Field
          type="datetime-local"
          name="arrived_at"
          placeholder="ArrivedAt"
      />
  </FormField>



























  <FormField
      label="DepartedAt"
  >
      <Field
          type="datetime-local"
          name="departed_at"
          placeholder="DepartedAt"
      />
  </FormField>

















  <FormField
      label="ContactName"
  >
      <Field
          name="contact_name"
          placeholder="ContactName"
      />
  </FormField>



























  <FormField
      label="ContactPhone"
  >
      <Field
          name="contact_phone"
          placeholder="ContactPhone"
      />
  </FormField>



























  <FormField
      label="ContactEmail"
  >
      <Field
          name="contact_email"
          placeholder="ContactEmail"
      />
  </FormField>





























    <FormField label="Instructions" hasTextareaHeight>
        <Field name="instructions" as="textarea" placeholder="Instructions" />
    </FormField>

























  <FormField
      label="ReferenceNo"
  >
      <Field
          name="reference_no"
          placeholder="ReferenceNo"
      />
  </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('/load_stops/load_stops-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Load_stopsNew
