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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    l1_threshold_usd: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    l2_threshold_usd: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    l3_threshold_usd: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    l4_threshold_usd: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sla_approval_hours: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sla_procurement_hours: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sla_reception_hours: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    rate_limit_profile: 'standard',
    
    
    
    
    
    
    
    
    
    
    
    
    
    require_reject_reason: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    require_return_comment: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/workflow_rules/workflow_rules-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="SeuilL1USD"
    >
        <Field
            type="number"
            name="l1_threshold_usd"
            placeholder="SeuilL1USD"
        />
    </FormField>



























    <FormField
        label="SeuilL2USD"
    >
        <Field
            type="number"
            name="l2_threshold_usd"
            placeholder="SeuilL2USD"
        />
    </FormField>



























    <FormField
        label="SeuilL3USD"
    >
        <Field
            type="number"
            name="l3_threshold_usd"
            placeholder="SeuilL3USD"
        />
    </FormField>



























    <FormField
        label="SeuilL4USD"
    >
        <Field
            type="number"
            name="l4_threshold_usd"
            placeholder="SeuilL4USD"
        />
    </FormField>



























    <FormField
        label="SLAapprobationheures"
    >
        <Field
            type="number"
            name="sla_approval_hours"
            placeholder="SLAapprobationheures"
        />
    </FormField>



























    <FormField
        label="SLAachatsheures"
    >
        <Field
            type="number"
            name="sla_procurement_hours"
            placeholder="SLAachatsheures"
        />
    </FormField>



























    <FormField
        label="SLAreceptionheures"
    >
        <Field
            type="number"
            name="sla_reception_hours"
            placeholder="SLAreceptionheures"
        />
    </FormField>



































  <FormField label="Profillimitation" labelFor="rate_limit_profile">
      <Field name="rate_limit_profile" id="rate_limit_profile" component="select">
      
        <option value="standard">standard</option>
      
        <option value="strict">strict</option>
      
        <option value="custom">custom</option>
      
      </Field>
  </FormField>





























  <FormField label='Motifrejetobligatoire' labelFor='require_reject_reason'>
      <Field
          name='require_reject_reason'
          id='require_reject_reason'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='Commentaireretourobligatoire' labelFor='require_return_comment'>
      <Field
          name='require_return_comment'
          id='require_return_comment'
          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('/workflow_rules/workflow_rules-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Workflow_rulesNew
