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

const initialValues = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    applies_to: 'document',
    
    
    
    
    
    
    
    
    
    
    
    
    
    requires_esignature: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requires_two_factor: false,
    
    
    
    
    
    
    
    
    
    
    
    
    min_approvals: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    instructions: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    active: false,
    
    
    
    
    
    
    
    
}


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

    
    

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









































  <FormField label="AppliesTo" labelFor="applies_to">
      <Field name="applies_to" id="applies_to" component="select">
      
        <option value="document">document</option>
      
        <option value="document_version">document_version</option>
      
        <option value="change_request">change_request</option>
      
        <option value="training_assignment">training_assignment</option>
      
        <option value="record_batch">record_batch</option>
      
        <option value="risk_assessment">risk_assessment</option>
      
        <option value="capa">capa</option>
      
        <option value="nonconformance">nonconformance</option>
      
        <option value="audit">audit</option>
      
      </Field>
  </FormField>





























  <FormField label='RequiresE-Signature' labelFor='requires_esignature'>
      <Field
          name='requires_esignature'
          id='requires_esignature'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='RequiresTwoFactor' labelFor='requires_two_factor'>
      <Field
          name='requires_two_factor'
          id='requires_two_factor'
          component={SwitchField}
      ></Field>
  </FormField>

















    <FormField
        label="MinimumApprovals"
    >
        <Field
            type="number"
            name="min_approvals"
            placeholder="MinimumApprovals"
        />
    </FormField>























    <FormField label="Instructions" hasTextareaHeight>
        <Field name="instructions" as="textarea" placeholder="Instructions" />
    </FormField>









































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

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

export default Approval_workflowsNew
