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

const initialValues = {
    
    
    
    
    
    
    
    movement_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    product: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    movement_type: 'in',
    
    
    
    
    
    
    
    quantity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    unit_cost: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reason: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    supplier: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    client: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/stock_movements/stock_movements-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="Datemouvement"
  >
      <Field
          type="datetime-local"
          name="movement_at"
          placeholder="Datemouvement"
      />
  </FormField>



































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























  <FormField label="Typemouvement" labelFor="movement_type">
      <Field name="movement_type" id="movement_type" component="select">
      
        <option value="in">in</option>
      
        <option value="out">out</option>
      
        <option value="adjustment">adjustment</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Quantité"
    >
        <Field
            type="number"
            name="quantity"
            placeholder="Quantité"
        />
    </FormField>



























    <FormField
        label="Coûtunitaire"
    >
        <Field
            type="number"
            name="unit_cost"
            placeholder="Coûtunitaire"
        />
    </FormField>





















  <FormField
      label="Référence"
  >
      <Field
          name="reference"
          placeholder="Référence"
      />
  </FormField>





























    <FormField label="Motif" hasTextareaHeight>
        <Field name="reason" as="textarea" placeholder="Motif" />
    </FormField>











































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



























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



























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

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

export default Stock_movementsNew
