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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    customer: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    document_type: 'driver_license',
    
    
    
    
    
    
    
    document_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    issued_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    expires_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    document_files: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    verification_status: 'pending',
    
    
    
    
    
    
    
    
    verification_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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























  <FormField label="DocumentType" labelFor="document_type">
      <Field name="document_type" id="document_type" component="select">
      
        <option value="driver_license">driver_license</option>
      
        <option value="passport">passport</option>
      
        <option value="id_card">id_card</option>
      
        <option value="insurance">insurance</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>













  <FormField
      label="DocumentNumber"
  >
      <Field
          name="document_number"
          placeholder="DocumentNumber"
      />
  </FormField>





































  <FormField
      label="IssuedAt"
  >
      <Field
          type="datetime-local"
          name="issued_at"
          placeholder="IssuedAt"
      />
  </FormField>



























  <FormField
      label="ExpiresAt"
  >
      <Field
          type="datetime-local"
          name="expires_at"
          placeholder="ExpiresAt"
      />
  </FormField>








































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


















  <FormField label="VerificationStatus" labelFor="verification_status">
      <Field name="verification_status" id="verification_status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="verified">verified</option>
      
        <option value="rejected">rejected</option>
      
      </Field>
  </FormField>















    <FormField label="VerificationNotes" hasTextareaHeight>
        <Field name="verification_notes" as="textarea" placeholder="VerificationNotes" />
    </FormField>











































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

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

export default Customer_documentsNew
