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

const initialValues = {
    
    
    issue_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    production_order: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    item: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    lot: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    from_location: '',
    
    
    
    
    quantity_issued: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    issued_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    issue_type: 'manual',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    issued_by: '',
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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













































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



























  <FormField label="Item" labelFor="item">
      <Field name="item" id="item" component={SelectField} options={[]} itemRef={'items'}></Field>
  </FormField>



























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



























  <FormField label="FromLocation" labelFor="from_location">
      <Field name="from_location" id="from_location" component={SelectField} options={[]} itemRef={'locations'}></Field>
  </FormField>















    <FormField
        label="QuantityIssued"
    >
        <Field
            type="number"
            name="quantity_issued"
            placeholder="QuantityIssued"
        />
    </FormField>































  <FormField
      label="IssuedAt"
  >
      <Field
          type="datetime-local"
          name="issued_at"
          placeholder="IssuedAt"
      />
  </FormField>































  <FormField label="IssueType" labelFor="issue_type">
      <Field name="issue_type" id="issue_type" component="select">
      
        <option value="manual">manual</option>
      
        <option value="backflush">backflush</option>
      
        <option value="return">return</option>
      
      </Field>
  </FormField>































  <FormField label="IssuedBy" labelFor="issued_by">
      <Field name="issued_by" id="issued_by" component={SelectField} options={[]} itemRef={'users'}></Field>
  </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('/material_issues/material_issues-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Material_issuesNew
