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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    item: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    production_order: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    lot: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    inspected_by: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    inspection_type: 'incoming',
    
    
    
    
    
    
    
    
    
    
    
    
    inspection_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    result: 'pass',
    
    
    
    
    
    
    
    summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    attachments: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="ProductionOrder" labelFor="production_order">
      <Field name="production_order" id="production_order" component={SelectField} options={[]} itemRef={'production_orders'}></Field>
  </FormField>



























  <FormField label="Lot" labelFor="lot">
      <Field name="lot" id="lot" component={SelectField} options={[]} itemRef={'inventory_lots'}></Field>
  </FormField>



























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























  <FormField label="InspectionType" labelFor="inspection_type">
      <Field name="inspection_type" id="inspection_type" component="select">
      
        <option value="incoming">incoming</option>
      
        <option value="in_process">in_process</option>
      
        <option value="final">final</option>
      
        <option value="audit">audit</option>
      
      </Field>
  </FormField>























  <FormField
      label="InspectionAt"
  >
      <Field
          type="datetime-local"
          name="inspection_at"
          placeholder="InspectionAt"
      />
  </FormField>































  <FormField label="Result" labelFor="result">
      <Field name="result" id="result" component="select">
      
        <option value="pass">pass</option>
      
        <option value="fail">fail</option>
      
        <option value="conditional_pass">conditional_pass</option>
      
      </Field>
  </FormField>













  <FormField
      label="Summary"
  >
      <Field
          name="summary"
          placeholder="Summary"
      />
  </FormField>





























    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </FormField>
















































  <FormField>
      <Field
          label='Attachments'
          color='info'
          icon={mdiUpload}
          path={'quality_inspections/attachments'}
          name='attachments'
          id='attachments'
          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('/quality_inspections/quality_inspections-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Quality_inspectionsNew
