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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    purchase_order: '',
    
    
    
    
    grn_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    received_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    received_by: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    quality_check: 'pass',
    
    
    
    
    
    
    
    
    observations: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    photos: [],
    
    
    
    
    
    receiver_signature: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'open',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="NumeroGRN"
  >
      <Field
          name="grn_number"
          placeholder="NumeroGRN"
      />
  </FormField>





































  <FormField
      label="Datereception"
  >
      <Field
          type="datetime-local"
          name="received_at"
          placeholder="Datereception"
      />
  </FormField>



































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























  <FormField label="Controlequalite" labelFor="quality_check">
      <Field name="quality_check" id="quality_check" component="select">
      
        <option value="pass">pass</option>
      
        <option value="partial">partial</option>
      
        <option value="fail">fail</option>
      
      </Field>
  </FormField>















    <FormField label="Observations" hasTextareaHeight>
        <Field name="observations" as="textarea" placeholder="Observations" />
    </FormField>















































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





  <FormField
      label="Signaturerecepteur"
  >
      <Field
          name="receiver_signature"
          placeholder="Signaturerecepteur"
      />
  </FormField>









































  <FormField label="Statut" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="open">open</option>
      
        <option value="submitted">submitted</option>
      
        <option value="discrepancy_reported">discrepancy_reported</option>
      
        <option value="accepted">accepted</option>
      
        <option value="rejected">rejected</option>
      
      </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('/goods_receipt_notes/goods_receipt_notes-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Goods_receipt_notesNew
