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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    production_order: '',
    
    
    
    
    
    
    
    operation_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    work_center: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    machine: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'not_started',
    
    
    
    
    
    
    
    
    
    
    
    
    planned_start: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    planned_end: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    actual_start: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    actual_end: '',
    
    
    
    
    
    
    
    
    
    
    good_quantity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    scrap_quantity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    operator: '',
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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















    <FormField
        label="OperationNumber"
    >
        <Field
            type="number"
            name="operation_number"
            placeholder="OperationNumber"
        />
    </FormField>





















  <FormField
      label="OperationName"
  >
      <Field
          name="name"
          placeholder="OperationName"
      />
  </FormField>













































  <FormField label="WorkCenter" labelFor="work_center">
      <Field name="work_center" id="work_center" component={SelectField} options={[]} itemRef={'work_centers'}></Field>
  </FormField>



























  <FormField label="Machine" labelFor="machine">
      <Field name="machine" id="machine" component={SelectField} options={[]} itemRef={'machines'}></Field>
  </FormField>























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="not_started">not_started</option>
      
        <option value="ready">ready</option>
      
        <option value="in_progress">in_progress</option>
      
        <option value="paused">paused</option>
      
        <option value="completed">completed</option>
      
        <option value="skipped">skipped</option>
      
      </Field>
  </FormField>























  <FormField
      label="PlannedStart"
  >
      <Field
          type="datetime-local"
          name="planned_start"
          placeholder="PlannedStart"
      />
  </FormField>



























  <FormField
      label="PlannedEnd"
  >
      <Field
          type="datetime-local"
          name="planned_end"
          placeholder="PlannedEnd"
      />
  </FormField>



























  <FormField
      label="ActualStart"
  >
      <Field
          type="datetime-local"
          name="actual_start"
          placeholder="ActualStart"
      />
  </FormField>



























  <FormField
      label="ActualEnd"
  >
      <Field
          type="datetime-local"
          name="actual_end"
          placeholder="ActualEnd"
      />
  </FormField>























    <FormField
        label="GoodQuantity"
    >
        <Field
            type="number"
            name="good_quantity"
            placeholder="GoodQuantity"
        />
    </FormField>



























    <FormField
        label="ScrapQuantity"
    >
        <Field
            type="number"
            name="scrap_quantity"
            placeholder="ScrapQuantity"
        />
    </FormField>







































  <FormField label="Operator" labelFor="operator">
      <Field name="operator" id="operator" 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('/production_operations/production_operations-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Production_operationsNew
