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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    expense_no: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vehicle: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vendor: '',
    
    
    
    
    expense_category: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tax_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    gross_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    expense_account: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payment_account: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    attachment: [],
    
    
    
    
    
    
    
    
    
    
    
    created_on: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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





































  <FormField
      label="Date"
  >
      <Field
          type="datetime-local"
          name="date"
          placeholder="Date"
      />
  </FormField>



































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



























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









  <FormField
      label="ExpenseCategory"
  >
      <Field
          name="expense_category"
          placeholder="ExpenseCategory"
      />
  </FormField>





























    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </FormField>































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



























    <FormField
        label="TaxAmount"
    >
        <Field
            type="number"
            name="tax_amount"
            placeholder="TaxAmount"
        />
    </FormField>



























    <FormField
        label="GrossAmount"
    >
        <Field
            type="number"
            name="gross_amount"
            placeholder="GrossAmount"
        />
    </FormField>







































  <FormField label="ExpenseAccount" labelFor="expense_account">
      <Field name="expense_account" id="expense_account" component={SelectField} options={[]} itemRef={'chart_of_accounts'}></Field>
  </FormField>



























  <FormField label="PaymentAccount" labelFor="payment_account">
      <Field name="payment_account" id="payment_account" component={SelectField} options={[]} itemRef={'chart_of_accounts'}></Field>
  </FormField>























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="approved">approved</option>
      
        <option value="posted">posted</option>
      
        <option value="voided">voided</option>
      
        <option value="reversed">reversed</option>
      
      </Field>
  </FormField>




































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














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

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

export default Vehicle_expensesNew
