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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    trade_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vendor_type: 'company',
    
    
    
    
    
    
    
    registration_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tax_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    contact_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    contact_email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    contact_phone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bank_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bank_account_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bank_account_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bank_swift: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    qualification_status: 'unsubmitted',
    
    
    
    
    
    
    
    
    
    
    
    
    qualification_reviewed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    risk_rating: 'low',
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_blacklisted: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    compliance_valid_until: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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









  <FormField
      label="VendorName"
  >
      <Field
          name="name"
          placeholder="VendorName"
      />
  </FormField>



























  <FormField
      label="TradeName"
  >
      <Field
          name="trade_name"
          placeholder="TradeName"
      />
  </FormField>









































  <FormField label="VendorType" labelFor="vendor_type">
      <Field name="vendor_type" id="vendor_type" component="select">
      
        <option value="company">company</option>
      
        <option value="ngo">ngo</option>
      
        <option value="public_entity">public_entity</option>
      
        <option value="individual">individual</option>
      
      </Field>
  </FormField>













  <FormField
      label="RegistrationNumber"
  >
      <Field
          name="registration_number"
          placeholder="RegistrationNumber"
      />
  </FormField>



























  <FormField
      label="TaxNumber"
  >
      <Field
          name="tax_number"
          placeholder="TaxNumber"
      />
  </FormField>



























  <FormField
      label="PrimaryContactName"
  >
      <Field
          name="contact_name"
          placeholder="PrimaryContactName"
      />
  </FormField>



























  <FormField
      label="PrimaryContactEmail"
  >
      <Field
          name="contact_email"
          placeholder="PrimaryContactEmail"
      />
  </FormField>



























  <FormField
      label="PrimaryContactPhone"
  >
      <Field
          name="contact_phone"
          placeholder="PrimaryContactPhone"
      />
  </FormField>





























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

























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



























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



























  <FormField
      label="BankAccountName"
  >
      <Field
          name="bank_account_name"
          placeholder="BankAccountName"
      />
  </FormField>



























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









































  <FormField label="QualificationStatus" labelFor="qualification_status">
      <Field name="qualification_status" id="qualification_status" component="select">
      
        <option value="unsubmitted">unsubmitted</option>
      
        <option value="under_review">under_review</option>
      
        <option value="qualified">qualified</option>
      
        <option value="conditionally_qualified">conditionally_qualified</option>
      
        <option value="suspended">suspended</option>
      
        <option value="disqualified">disqualified</option>
      
      </Field>
  </FormField>























  <FormField
      label="QualificationReviewedAt"
  >
      <Field
          type="datetime-local"
          name="qualification_reviewed_at"
          placeholder="QualificationReviewedAt"
      />
  </FormField>































  <FormField label="RiskRating" labelFor="risk_rating">
      <Field name="risk_rating" id="risk_rating" component="select">
      
        <option value="low">low</option>
      
        <option value="medium">medium</option>
      
        <option value="high">high</option>
      
        <option value="critical">critical</option>
      
      </Field>
  </FormField>





























  <FormField label='Blacklisted' labelFor='is_blacklisted'>
      <Field
          name='is_blacklisted'
          id='is_blacklisted'
          component={SwitchField}
      ></Field>
  </FormField>





















  <FormField
      label="ComplianceValidUntil"
  >
      <Field
          type="datetime-local"
          name="compliance_valid_until"
          placeholder="ComplianceValidUntil"
      />
  </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('/vendors/vendors-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default VendorsNew
