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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requisition: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    classification: 'direct_purchase',
    
    
    
    
    
    
    
    
    classification_justification: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    pipeline_stage: 'a_classifier',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    owner: '',
    
    
    
    
    
    
    
    
    
    started_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sla_due_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    awarded_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    closed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    admin_override_single_source: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























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























  <FormField label="Classification" labelFor="classification">
      <Field name="classification" id="classification" component="select">
      
        <option value="direct_purchase">direct_purchase</option>
      
        <option value="pre_qualified">pre_qualified</option>
      
        <option value="multiple_quotations">multiple_quotations</option>
      
        <option value="public_tender">public_tender</option>
      
        <option value="single_source">single_source</option>
      
      </Field>
  </FormField>















    <FormField label="Justification" hasTextareaHeight>
        <Field name="classification_justification" as="textarea" placeholder="Justification" />
    </FormField>







































  <FormField label="Etapepipeline" labelFor="pipeline_stage">
      <Field name="pipeline_stage" id="pipeline_stage" component="select">
      
        <option value="a_classifier">a_classifier</option>
      
        <option value="sourcing">sourcing</option>
      
        <option value="analyse_offres">analyse_offres</option>
      
        <option value="attribuee">attribuee</option>
      
        <option value="cloturee">cloturee</option>
      
      </Field>
  </FormField>































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



















  <FormField
      label="Datedemarrage"
  >
      <Field
          type="datetime-local"
          name="started_at"
          placeholder="Datedemarrage"
      />
  </FormField>



























  <FormField
      label="EcheanceSLA"
  >
      <Field
          type="datetime-local"
          name="sla_due_at"
          placeholder="EcheanceSLA"
      />
  </FormField>



























  <FormField
      label="Dateattribution"
  >
      <Field
          type="datetime-local"
          name="awarded_at"
          placeholder="Dateattribution"
      />
  </FormField>



























  <FormField
      label="Datecloture"
  >
      <Field
          type="datetime-local"
          name="closed_at"
          placeholder="Datecloture"
      />
  </FormField>

































  <FormField label='Overridesinglesource' labelFor='admin_override_single_source'>
      <Field
          name='admin_override_single_source'
          id='admin_override_single_source'
          component={SwitchField}
      ></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('/procurement_cases/procurement_cases-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Procurement_casesNew
