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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    driver_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    driver_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    phone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    license_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    license_expiry_date: '',
    
    
    
    
    
    
    
    
    
    
    national_id: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    trn_tax_id: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    security_deposit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    credit_limit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'active',
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    created_on: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    modified_on: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField
      label="DriverName"
  >
      <Field
          name="driver_name"
          placeholder="DriverName"
      />
  </FormField>



























  <FormField
      label="Phone"
  >
      <Field
          name="phone"
          placeholder="Phone"
      />
  </FormField>



























  <FormField
      label="Email"
  >
      <Field
          name="email"
          placeholder="Email"
      />
  </FormField>





























    <FormField label="Address" hasTextareaHeight>
        <Field name="address" as="textarea" placeholder="Address" />
    </FormField>

























  <FormField
      label="LicenseNumber"
  >
      <Field
          name="license_number"
          placeholder="LicenseNumber"
      />
  </FormField>





































  <FormField
      label="LicenseExpiryDate"
  >
      <Field
          type="datetime-local"
          name="license_expiry_date"
          placeholder="LicenseExpiryDate"
      />
  </FormField>

















  <FormField
      label="NationalID"
  >
      <Field
          name="national_id"
          placeholder="NationalID"
      />
  </FormField>



























  <FormField
      label="TRN/TaxID"
  >
      <Field
          name="trn_tax_id"
          placeholder="TRN/TaxID"
      />
  </FormField>

































    <FormField
        label="SecurityDeposit"
    >
        <Field
            type="number"
            name="security_deposit"
            placeholder="SecurityDeposit"
        />
    </FormField>



























    <FormField
        label="CreditLimit"
    >
        <Field
            type="number"
            name="credit_limit"
            placeholder="CreditLimit"
        />
    </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="suspended">suspended</option>
      
        <option value="blacklisted">blacklisted</option>
      
      </Field>
  </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('/drivers/drivers-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default DriversNew
