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

const initialValues = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    short_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    logo: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'ACTIVE',
    
    
    
    
    
    
    
    legal_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    legal_form: 'EINZELUNTERNEHMEN',
    
    
    
    
    
    
    
    handelsregister_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    register_court: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    managing_directors: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    founding_date: '',
    
    
    
    
    
    
    
    
    
    
    vat_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tax_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    vat_status: 'VAT_REGISTERED',
    
    
    
    
    
    
    
    eori_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    gln_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    scac: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address_line1: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address_line2: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    postal_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    city: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    state: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    country_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    phone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    website: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    dispatch_email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    accounting_email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    hr_email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    default_currency: 'EUR',
    
    
    
    
    
    
    
    invoice_prefix: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    invoice_numbering_mode: 'SEQUENTIAL',
    
    
    
    
    
    
    
    
    
    
    invoice_next_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    invoice_rounding: 'NONE',
    
    
    
    
    
    
    
    
    
    
    payment_terms_days: '',
    
    
    
    
    
    
    
    
    
    
    
    
    payroll_provider: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payroll_contact_email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField
      label="ShortName"
  >
      <Field
          name="short_name"
          placeholder="ShortName"
      />
  </FormField>

















































  <FormField>
      <Field
          label='Logo'
          color='info'
          icon={mdiUpload}
          path={'companies/logo'}
          name='logo'
          id='logo'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></Field>
  </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>
      
      </Field>
  </FormField>













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









































  <FormField label="LegalForm" labelFor="legal_form">
      <Field name="legal_form" id="legal_form" component="select">
      
        <option value="EINZELUNTERNEHMEN">EINZELUNTERNEHMEN</option>
      
        <option value="GBR">GBR</option>
      
        <option value="UG">UG</option>
      
        <option value="GMBH">GMBH</option>
      
        <option value="AG">AG</option>
      
        <option value="KG">KG</option>
      
        <option value="OHG">OHG</option>
      
        <option value="GMBH_CO_KG">GMBH_CO_KG</option>
      
        <option value="OTHER">OTHER</option>
      
      </Field>
  </FormField>













  <FormField
      label="HandelsregisterNumber"
  >
      <Field
          name="handelsregister_number"
          placeholder="HandelsregisterNumber"
      />
  </FormField>



























  <FormField
      label="RegisterCourt"
  >
      <Field
          name="register_court"
          placeholder="RegisterCourt"
      />
  </FormField>





























    <FormField label="ManagingDirectors" hasTextareaHeight>
        <Field name="managing_directors" as="textarea" placeholder="ManagingDirectors" />
    </FormField>



































  <FormField
      label="FoundingDate"
  >
      <Field
          type="datetime-local"
          name="founding_date"
          placeholder="FoundingDate"
      />
  </FormField>

















  <FormField
      label="VATNumber"
  >
      <Field
          name="vat_number"
          placeholder="VATNumber"
      />
  </FormField>



























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









































  <FormField label="VATStatus" labelFor="vat_status">
      <Field name="vat_status" id="vat_status" component="select">
      
        <option value="VAT_REGISTERED">VAT_REGISTERED</option>
      
        <option value="NOT_VAT_REGISTERED">NOT_VAT_REGISTERED</option>
      
        <option value="SMALL_BUSINESS_19_USTG">SMALL_BUSINESS_19_USTG</option>
      
      </Field>
  </FormField>













  <FormField
      label="EORINumber"
  >
      <Field
          name="eori_number"
          placeholder="EORINumber"
      />
  </FormField>



























  <FormField
      label="GLNNumber"
  >
      <Field
          name="gln_number"
          placeholder="GLNNumber"
      />
  </FormField>



























  <FormField
      label="SCAC"
  >
      <Field
          name="scac"
          placeholder="SCAC"
      />
  </FormField>



























  <FormField
      label="AddressLine1"
  >
      <Field
          name="address_line1"
          placeholder="AddressLine1"
      />
  </FormField>



























  <FormField
      label="AddressLine2"
  >
      <Field
          name="address_line2"
          placeholder="AddressLine2"
      />
  </FormField>



























  <FormField
      label="PostalCode"
  >
      <Field
          name="postal_code"
          placeholder="PostalCode"
      />
  </FormField>



























  <FormField
      label="City"
  >
      <Field
          name="city"
          placeholder="City"
      />
  </FormField>



























  <FormField
      label="State"
  >
      <Field
          name="state"
          placeholder="State"
      />
  </FormField>



























  <FormField
      label="CountryCode"
  >
      <Field
          name="country_code"
          placeholder="CountryCode"
      />
  </FormField>



























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



























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



























  <FormField
      label="Website"
  >
      <Field
          name="website"
          placeholder="Website"
      />
  </FormField>



























  <FormField
      label="DispatchEmail"
  >
      <Field
          name="dispatch_email"
          placeholder="DispatchEmail"
      />
  </FormField>



























  <FormField
      label="AccountingEmail"
  >
      <Field
          name="accounting_email"
          placeholder="AccountingEmail"
      />
  </FormField>



























  <FormField
      label="HREmail"
  >
      <Field
          name="hr_email"
          placeholder="HREmail"
      />
  </FormField>









































  <FormField label="DefaultCurrency" labelFor="default_currency">
      <Field name="default_currency" id="default_currency" component="select">
      
        <option value="EUR">EUR</option>
      
        <option value="USD">USD</option>
      
        <option value="GBP">GBP</option>
      
        <option value="PLN">PLN</option>
      
        <option value="CZK">CZK</option>
      
        <option value="RON">RON</option>
      
        <option value="BGN">BGN</option>
      
        <option value="OTHER">OTHER</option>
      
      </Field>
  </FormField>













  <FormField
      label="InvoicePrefix"
  >
      <Field
          name="invoice_prefix"
          placeholder="InvoicePrefix"
      />
  </FormField>









































  <FormField label="InvoiceNumberingMode" labelFor="invoice_numbering_mode">
      <Field name="invoice_numbering_mode" id="invoice_numbering_mode" component="select">
      
        <option value="SEQUENTIAL">SEQUENTIAL</option>
      
        <option value="YEARLY_RESET">YEARLY_RESET</option>
      
        <option value="MONTHLY_RESET">MONTHLY_RESET</option>
      
      </Field>
  </FormField>



















    <FormField
        label="InvoiceNextNumber"
    >
        <Field
            type="number"
            name="invoice_next_number"
            placeholder="InvoiceNextNumber"
        />
    </FormField>



































  <FormField label="InvoiceRounding" labelFor="invoice_rounding">
      <Field name="invoice_rounding" id="invoice_rounding" component="select">
      
        <option value="NONE">NONE</option>
      
        <option value="ROUND_2_DECIMALS">ROUND_2_DECIMALS</option>
      
        <option value="ROUND_0_DECIMALS">ROUND_0_DECIMALS</option>
      
      </Field>
  </FormField>



















    <FormField
        label="PaymentTerms(Days)"
    >
        <Field
            type="number"
            name="payment_terms_days"
            placeholder="PaymentTerms(Days)"
        />
    </FormField>





















  <FormField
      label="PayrollProvider"
  >
      <Field
          name="payroll_provider"
          placeholder="PayrollProvider"
      />
  </FormField>



























  <FormField
      label="PayrollContactEmail"
  >
      <Field
          name="payroll_contact_email"
          placeholder="PayrollContactEmail"
      />
  </FormField>





























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

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

export default CompaniesNew
