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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    type: 'SEMI_TRAILER',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'ACTIVE',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ownership: 'OWNED',
    
    
    
    
    
    
    
    plate_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vin: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    brand: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    model: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    year: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    first_registration_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    gross_weight_kg: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    curb_weight_kg: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payload_kg: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    axle_count: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    has_liftgate: false,
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    photo: [],
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/trailers/trailers-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="TrailerType" labelFor="type">
      <Field name="type" id="type" component="select">
      
        <option value="SEMI_TRAILER">SEMI_TRAILER</option>
      
        <option value="FULL_TRAILER">FULL_TRAILER</option>
      
        <option value="DOLLY">DOLLY</option>
      
        <option value="OTHER">OTHER</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="ACTIVE">ACTIVE</option>
      
        <option value="INACTIVE">INACTIVE</option>
      
        <option value="SOLD">SOLD</option>
      
        <option value="SCRAPPED">SCRAPPED</option>
      
        <option value="SUSPENDED">SUSPENDED</option>
      
      </Field>
  </FormField>



























  <FormField label="Ownership" labelFor="ownership">
      <Field name="ownership" id="ownership" component="select">
      
        <option value="OWNED">OWNED</option>
      
        <option value="LEASED">LEASED</option>
      
        <option value="RENTED">RENTED</option>
      
      </Field>
  </FormField>













  <FormField
      label="PlateNumber"
  >
      <Field
          name="plate_number"
          placeholder="PlateNumber"
      />
  </FormField>



























  <FormField
      label="VIN"
  >
      <Field
          name="vin"
          placeholder="VIN"
      />
  </FormField>



























  <FormField
      label="Brand"
  >
      <Field
          name="brand"
          placeholder="Brand"
      />
  </FormField>



























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

































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































  <FormField
      label="FirstRegistrationAt"
  >
      <Field
          type="datetime-local"
          name="first_registration_at"
          placeholder="FirstRegistrationAt"
      />
  </FormField>























    <FormField
        label="GrossWeight(kg)"
    >
        <Field
            type="number"
            name="gross_weight_kg"
            placeholder="GrossWeight(kg)"
        />
    </FormField>



























    <FormField
        label="CurbWeight(kg)"
    >
        <Field
            type="number"
            name="curb_weight_kg"
            placeholder="CurbWeight(kg)"
        />
    </FormField>



























    <FormField
        label="Payload(kg)"
    >
        <Field
            type="number"
            name="payload_kg"
            placeholder="Payload(kg)"
        />
    </FormField>



























    <FormField
        label="AxleCount"
    >
        <Field
            type="number"
            name="axle_count"
            placeholder="AxleCount"
        />
    </FormField>





































  <FormField label='HasLiftgate' labelFor='has_liftgate'>
      <Field
          name='has_liftgate'
          id='has_liftgate'
          component={SwitchField}
      ></Field>
  </FormField>













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















































  <FormField>
      <Field
          label='Photo'
          color='info'
          icon={mdiUpload}
          path={'trailers/photo'}
          name='photo'
          id='photo'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></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('/trailers/trailers-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default TrailersNew
