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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    business: '',
    
    
    
    
    lc_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bank: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    counterparty: '',
    
    
    
    
    
    
    
    
    
    issue_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    expiry_date: '',
    
    
    
    
    
    
    
    
    
    
    amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    attachments: [],
    
    
    
    
    
}


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

    
    

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









  <FormField
      label="LCNumber"
  >
      <Field
          name="lc_number"
          placeholder="LCNumber"
      />
  </FormField>













































  <FormField label="IssuingBank" labelFor="bank">
      <Field name="bank" id="bank" component={SelectField} options={[]} itemRef={'banks'}></Field>
  </FormField>



























  <FormField label="Beneficiary" labelFor="counterparty">
      <Field name="counterparty" id="counterparty" component={SelectField} options={[]} itemRef={'counterparties'}></Field>
  </FormField>



















  <FormField
      label="IssueDate"
  >
      <Field
          type="datetime-local"
          name="issue_date"
          placeholder="IssueDate"
      />
  </FormField>



























  <FormField
      label="ExpiryDate"
  >
      <Field
          type="datetime-local"
          name="expiry_date"
          placeholder="ExpiryDate"
      />
  </FormField>























    <FormField
        label="Amount"
    >
        <Field
            type="number"
            name="amount"
            placeholder="Amount"
        />
    </FormField>







































  <FormField label="Currency" labelFor="currency">
      <Field name="currency" id="currency" component={SelectField} options={[]} itemRef={'currencies'}></Field>
  </FormField>























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="opened">opened</option>
      
        <option value="utilized">utilized</option>
      
        <option value="closed">closed</option>
      
        <option value="canceled">canceled</option>
      
      </Field>
  </FormField>




































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

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

export default Letters_of_creditNew
