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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    legal_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    commercial_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    rccm_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tax_id: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    country: 'CD',
    
    
    
    
    
    
    
    
    address: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    primary_contact_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    primary_contact_email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    primary_contact_phone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bank_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bank_account_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bank_swift: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'pending',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    prequalification_status: 'not_started',
    
    
    
    
    
    
    
    performance_score: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    documents: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="Raisonsociale"
  >
      <Field
          name="legal_name"
          placeholder="Raisonsociale"
      />
  </FormField>



























  <FormField
      label="Nomcommercial"
  >
      <Field
          name="commercial_name"
          placeholder="Nomcommercial"
      />
  </FormField>



























  <FormField
      label="NumeroRCCM"
  >
      <Field
          name="rccm_number"
          placeholder="NumeroRCCM"
      />
  </FormField>



























  <FormField
      label="Numeroimpots"
  >
      <Field
          name="tax_id"
          placeholder="Numeroimpots"
      />
  </FormField>









































  <FormField label="Pays" labelFor="country">
      <Field name="country" id="country" component="select">
      
        <option value="CD">CD</option>
      
        <option value="CM">CM</option>
      
        <option value="GA">GA</option>
      
        <option value="MG">MG</option>
      
        <option value="KE">KE</option>
      
        <option value="TZ">TZ</option>
      
        <option value="FR">FR</option>
      
        <option value="BE">BE</option>
      
        <option value="US">US</option>
      
        <option value="UK">UK</option>
      
        <option value="OTHER">OTHER</option>
      
      </Field>
  </FormField>















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

























  <FormField
      label="Contactprincipal"
  >
      <Field
          name="primary_contact_name"
          placeholder="Contactprincipal"
      />
  </FormField>



























  <FormField
      label="Emailcontact"
  >
      <Field
          name="primary_contact_email"
          placeholder="Emailcontact"
      />
  </FormField>



























  <FormField
      label="Telephonecontact"
  >
      <Field
          name="primary_contact_phone"
          placeholder="Telephonecontact"
      />
  </FormField>



























  <FormField
      label="Banque"
  >
      <Field
          name="bank_name"
          placeholder="Banque"
      />
  </FormField>



























  <FormField
      label="Numerodecompte"
  >
      <Field
          name="bank_account_number"
          placeholder="Numerodecompte"
      />
  </FormField>



























  <FormField
      label="SWIFT"
  >
      <Field
          name="bank_swift"
          placeholder="SWIFT"
      />
  </FormField>









































  <FormField label="Statut" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="active">active</option>
      
        <option value="blocked">blocked</option>
      
      </Field>
  </FormField>



























  <FormField label="Prequalification" labelFor="prequalification_status">
      <Field name="prequalification_status" id="prequalification_status" component="select">
      
        <option value="not_started">not_started</option>
      
        <option value="in_review">in_review</option>
      
        <option value="validated">validated</option>
      
        <option value="rejected">rejected</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Scoreperformance"
    >
        <Field
            type="number"
            name="performance_score"
            placeholder="Scoreperformance"
        />
    </FormField>












































  <FormField>
      <Field
          label='Documentsfournisseur'
          color='info'
          icon={mdiUpload}
          path={'suppliers/documents'}
          name='documents'
          id='documents'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </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('/suppliers/suppliers-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default SuppliersNew
