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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    verification_type: 'ktp',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'submitted',
    
    
    
    
    
    
    
    
    
    
    
    
    submitted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reviewed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    expires_at: '',
    
    
    
    
    
    
    
    
    
    
    document_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    document_files: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    selfie_images: [],
    
    
    
    
    
    match_confidence: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    review_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    
    // get from url params
    const { dateRangeStart, dateRangeEnd } = router.query
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/identity_verifications/identity_verifications-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    submitted_at: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    expires_at: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>





















  <FormField label="User" labelFor="user">
      <Field name="user" id="user" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>























  <FormField label="VerificationType" labelFor="verification_type">
      <Field name="verification_type" id="verification_type" component="select">
      
        <option value="ktp">ktp</option>
      
        <option value="npwp">npwp</option>
      
        <option value="business_legal">business_legal</option>
      
        <option value="face_biometric">face_biometric</option>
      
        <option value="education_credential">education_credential</option>
      
        <option value="employment_credential">employment_credential</option>
      
        <option value="address_proof">address_proof</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="submitted">submitted</option>
      
        <option value="in_review">in_review</option>
      
        <option value="approved">approved</option>
      
        <option value="rejected">rejected</option>
      
        <option value="expired">expired</option>
      
      </Field>
  </FormField>























  <FormField
      label="SubmittedAt"
  >
      <Field
          type="datetime-local"
          name="submitted_at"
          placeholder="SubmittedAt"
      />
  </FormField>



























  <FormField
      label="ReviewedAt"
  >
      <Field
          type="datetime-local"
          name="reviewed_at"
          placeholder="ReviewedAt"
      />
  </FormField>



























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

















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


















































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


























  <FormField>
      <Field
          label='SelfieImages'
          color='info'
          icon={mdiUpload}
          path={'identity_verifications/selfie_images'}
          name='selfie_images'
          id='selfie_images'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></Field>
  </FormField>











    <FormField
        label="MatchConfidence"
    >
        <Field
            type="number"
            name="match_confidence"
            placeholder="MatchConfidence"
        />
    </FormField>























    <FormField label="ReviewNotes" hasTextareaHeight>
        <Field name="review_notes" as="textarea" placeholder="ReviewNotes" />
    </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('/identity_verifications/identity_verifications-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Identity_verificationsNew
