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 = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sequence: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'pending',
    
    
    
    
    
    
    
    
    
    
    
    
    scheduled_start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    scheduled_end_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    started_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ended_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    production_order: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    machine: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    assigned_to: '',
    
    
    
    
    planned_quantity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    good_quantity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    scrap_quantity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    work_instructions: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    attachments: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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('Yeni Kayıt')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="Yeni Kayıt" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>



  <FormField
      label="Operasyon Adı"
  >
      <Field
          name="name"
          placeholder="Operasyon Adı"
      />
  </FormField>

































    <FormField
        label="Sıra"
    >
        <Field
            type="number"
            name="sequence"
            placeholder="Sıra"
        />
    </FormField>



































  <FormField label="Durum" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="ready">ready</option>
      
        <option value="in_progress">in_progress</option>
      
        <option value="blocked">blocked</option>
      
        <option value="done">done</option>
      
      </Field>
  </FormField>























  <FormField
      label="Planlanan Başlangıç Tarihi"
  >
      <Field
          type="datetime-local"
          name="scheduled_start_at"
          placeholder="Planlanan Başlangıç Tarihi"
      />
  </FormField>



























  <FormField
      label="Planlanan Bitiş Tarihi"
  >
      <Field
          type="datetime-local"
          name="scheduled_end_at"
          placeholder="Planlanan Bitiş Tarihi"
      />
  </FormField>



























  <FormField
      label="Başlangıç Tarihi"
  >
      <Field
          type="datetime-local"
          name="started_at"
          placeholder="Başlangıç Tarihi"
      />
  </FormField>



























  <FormField
      label="Bitiş Tarihi"
  >
      <Field
          type="datetime-local"
          name="ended_at"
          placeholder="Bitiş Tarihi"
      />
  </FormField>



































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



























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



























  <FormField label="Atanan Kişi" labelFor="assigned_to">
      <Field name="assigned_to" id="assigned_to" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>















    <FormField
        label="Planlanan Miktar"
    >
        <Field
            type="number"
            name="planned_quantity"
            placeholder="Planlanan Miktar"
        />
    </FormField>



























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



























    <FormField
        label="Hurda Miktarı"
    >
        <Field
            type="number"
            name="scrap_quantity"
            placeholder="Hurda Miktarı"
        />
    </FormField>

























      <FormField label='İş Talimatları' hasTextareaHeight>
          <Field
              name='work_instructions'
              id='work_instructions'
              component={RichTextField}
          ></Field>
      </FormField>














































  <FormField>
      <Field
          label='Ekler'
          color='info'
          icon={mdiUpload}
          path={'production_operations/attachments'}
          name='attachments'
          id='attachments'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>






















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







              <BaseDivider />
              <BaseButtons>
                <BaseButton type="submit" color="info" label="Kaydet" />
                <BaseButton type="reset" color="info" outline label="Sıfırla" />
                <BaseButton type='reset' color='danger' outline label='İptal' 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
