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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    vehicle_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    plate_no: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    engine_no: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    chassis_no: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    make: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    model: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    year: '',
    
    
    
    
    
    
    
    
    
    
    
    
    colour: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    category: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    purchase_date: '',
    
    
    
    
    
    
    
    
    
    
    purchase_cost: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ownership_type: 'owned',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'available',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    current_driver: '',
    
    
    
    
    branch: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    odometer: '',
    
    
    
    
    
    
    
    
    
    
    
    
    insurance_policy_no: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    created_on: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    modified_on: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/vehicles/vehicles-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="VehicleCode"
  >
      <Field
          name="vehicle_code"
          placeholder="VehicleCode"
      />
  </FormField>



























  <FormField
      label="PlateNo"
  >
      <Field
          name="plate_no"
          placeholder="PlateNo"
      />
  </FormField>



























  <FormField
      label="EngineNo"
  >
      <Field
          name="engine_no"
          placeholder="EngineNo"
      />
  </FormField>



























  <FormField
      label="ChassisNo"
  >
      <Field
          name="chassis_no"
          placeholder="ChassisNo"
      />
  </FormField>



























  <FormField
      label="Make"
  >
      <Field
          name="make"
          placeholder="Make"
      />
  </FormField>



























  <FormField
      label="Model"
  >
      <Field
          name="model"
          placeholder="Model"
      />
  </FormField>

































    <FormField
        label="Year"
    >
        <Field
            type="number"
            name="year"
            placeholder="Year"
        />
    </FormField>





















  <FormField
      label="Colour"
  >
      <Field
          name="colour"
          placeholder="Colour"
      />
  </FormField>



























  <FormField
      label="Category"
  >
      <Field
          name="category"
          placeholder="Category"
      />
  </FormField>





































  <FormField
      label="PurchaseDate"
  >
      <Field
          type="datetime-local"
          name="purchase_date"
          placeholder="PurchaseDate"
      />
  </FormField>























    <FormField
        label="PurchaseCost"
    >
        <Field
            type="number"
            name="purchase_cost"
            placeholder="PurchaseCost"
        />
    </FormField>



































  <FormField label="OwnershipType" labelFor="ownership_type">
      <Field name="ownership_type" id="ownership_type" component="select">
      
        <option value="owned">owned</option>
      
        <option value="leased">leased</option>
      
        <option value="financed">financed</option>
      
        <option value="rented">rented</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="available">available</option>
      
        <option value="assigned">assigned</option>
      
        <option value="maintenance">maintenance</option>
      
        <option value="inactive">inactive</option>
      
        <option value="sold">sold</option>
      
      </Field>
  </FormField>































  <FormField label="CurrentDriver" labelFor="current_driver">
      <Field name="current_driver" id="current_driver" component={SelectField} options={[]} itemRef={'drivers'}></Field>
  </FormField>









  <FormField
      label="Branch"
  >
      <Field
          name="branch"
          placeholder="Branch"
      />
  </FormField>

































    <FormField
        label="Odometer"
    >
        <Field
            type="number"
            name="odometer"
            placeholder="Odometer"
        />
    </FormField>





















  <FormField
      label="InsurancePolicyNo"
  >
      <Field
          name="insurance_policy_no"
          placeholder="InsurancePolicyNo"
      />
  </FormField>





























    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </FormField>



































  <FormField
      label="CreatedOn"
  >
      <Field
          type="datetime-local"
          name="created_on"
          placeholder="CreatedOn"
      />
  </FormField>



























  <FormField
      label="ModifiedOn"
  >
      <Field
          type="datetime-local"
          name="modified_on"
          placeholder="ModifiedOn"
      />
  </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('/vehicles/vehicles-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default VehiclesNew
