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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    category: 'FUEL',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    trip: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vehicle: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    trailer: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    employee: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    load: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vendor_rel: '',
    
    
    
    
    
    
    
    
    
    occurred_at: '',
    
    
    
    
    
    
    
    
    
    
    amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: 'EUR',
    
    
    
    
    
    
    
    vendor: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    receipt: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    fuel_entry: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    toll_entry: '',
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/cost_items/cost_items-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="Category" labelFor="category">
      <Field name="category" id="category" component="select">
      
        <option value="FUEL">FUEL</option>
      
        <option value="TOLL">TOLL</option>
      
        <option value="PARKING">PARKING</option>
      
        <option value="WASH">WASH</option>
      
        <option value="MAINTENANCE">MAINTENANCE</option>
      
        <option value="TIRES">TIRES</option>
      
        <option value="DRIVER_EXPENSE">DRIVER_EXPENSE</option>
      
        <option value="PER_DIEM">PER_DIEM</option>
      
        <option value="FERRY">FERRY</option>
      
        <option value="TRAIN">TRAIN</option>
      
        <option value="FINES">FINES</option>
      
        <option value="OTHER">OTHER</option>
      
      </Field>
  </FormField>































  <FormField label="Trip" labelFor="trip">
      <Field name="trip" id="trip" component={SelectField} options={[]} itemRef={'trips'}></Field>
  </FormField>



























  <FormField label="Vehicle" labelFor="vehicle">
      <Field name="vehicle" id="vehicle" component={SelectField} options={[]} itemRef={'vehicles'}></Field>
  </FormField>



























  <FormField label="Trailer" labelFor="trailer">
      <Field name="trailer" id="trailer" component={SelectField} options={[]} itemRef={'trailers'}></Field>
  </FormField>



























  <FormField label="Employee" labelFor="employee">
      <Field name="employee" id="employee" component={SelectField} options={[]} itemRef={'employees'}></Field>
  </FormField>



























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



























  <FormField label="Vendor" labelFor="vendor_rel">
      <Field name="vendor_rel" id="vendor_rel" component={SelectField} options={[]} itemRef={'vendors'}></Field>
  </FormField>



















  <FormField
      label="OccurredAt"
  >
      <Field
          type="datetime-local"
          name="occurred_at"
          placeholder="OccurredAt"
      />
  </FormField>























    <FormField
        label="Amount"
    >
        <Field
            type="number"
            name="amount"
            placeholder="Amount"
        />
    </FormField>



































  <FormField label="Currency" labelFor="currency">
      <Field name="currency" id="currency" component="select">
      
        <option value="EUR">EUR</option>
      
        <option value="USD">USD</option>
      
        <option value="GBP">GBP</option>
      
        <option value="PLN">PLN</option>
      
        <option value="CZK">CZK</option>
      
        <option value="RON">RON</option>
      
        <option value="BGN">BGN</option>
      
        <option value="OTHER">OTHER</option>
      
      </Field>
  </FormField>













  <FormField
      label="Vendor(FreeText)"
  >
      <Field
          name="vendor"
          placeholder="Vendor(FreeText)"
      />
  </FormField>



























  <FormField
      label="Reference"
  >
      <Field
          name="reference"
          placeholder="Reference"
      />
  </FormField>





























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
















































  <FormField>
      <Field
          label='Receipt'
          color='info'
          icon={mdiUpload}
          path={'cost_items/receipt'}
          name='receipt'
          id='receipt'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>






















  <FormField label="FuelEntry" labelFor="fuel_entry">
      <Field name="fuel_entry" id="fuel_entry" component={SelectField} options={[]} itemRef={'fuel_entries'}></Field>
  </FormField>



























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

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

export default Cost_itemsNew
