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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    employee: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    driver_profile: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    type: 'FINE',
    
    
    
    
    
    
    
    
    
    
    
    
    occurred_at: '',
    
    
    
    
    
    
    
    
    
    
    amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    location: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    paid: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    paid_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    points: '',
    
    
    
    
    
    
    
    
    
    
    
    
    severity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reported_by: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="DriverProfile" labelFor="driver_profile">
      <Field name="driver_profile" id="driver_profile" component={SelectField} options={[]} itemRef={'driver_profiles'}></Field>
  </FormField>























  <FormField label="IncidentType" labelFor="type">
      <Field name="type" id="type" component="select">
      
        <option value="FINE">FINE</option>
      
        <option value="ACCIDENT">ACCIDENT</option>
      
        <option value="TACHO_VIOLATION">TACHO_VIOLATION</option>
      
        <option value="DISCIPLINARY">DISCIPLINARY</option>
      
        <option value="VEHICLE_DAMAGE">VEHICLE_DAMAGE</option>
      
        <option value="OTHER">OTHER</option>
      
      </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"
  >
      <Field
          name="currency"
          placeholder="Currency"
      />
  </FormField>





























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

























  <FormField
      label="Location"
  >
      <Field
          name="location"
          placeholder="Location"
      />
  </FormField>











































  <FormField label='Paid' labelFor='paid'>
      <Field
          name='paid'
          id='paid'
          component={SwitchField}
      ></Field>
  </FormField>





















  <FormField
      label="PaidAt"
  >
      <Field
          type="datetime-local"
          name="paid_at"
          placeholder="PaidAt"
      />
  </FormField>























    <FormField
        label="Points"
    >
        <Field
            type="number"
            name="points"
            placeholder="Points"
        />
    </FormField>





















  <FormField
      label="Severity"
  >
      <Field
          name="severity"
          placeholder="Severity"
      />
  </FormField>



























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

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

export default IncidentsNew
