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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    employee: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    leaveType: '',
    
    
    
    
    
    
    
    
    
    dateFrom: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    dateTo: '',
    
    
    
    
    
    
    
    
    
    
    totalDays: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reason: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'APPLIED',
    
    
    
    
    
    
    
    
    managerNote: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    hrNote: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approvedByUser: '',
    
    
    
    
    
    
    
    
    
    approvedAt: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























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



















  <FormField
      label="DateFrom"
  >
      <Field
          type="datetime-local"
          name="dateFrom"
          placeholder="DateFrom"
      />
  </FormField>



























  <FormField
      label="DateTo"
  >
      <Field
          type="datetime-local"
          name="dateTo"
          placeholder="DateTo"
      />
  </FormField>























    <FormField
        label="TotalDays"
    >
        <Field
            type="number"
            name="totalDays"
            placeholder="TotalDays"
        />
    </FormField>























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







































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="APPLIED">APPLIED</option>
      
        <option value="PENDING_MANAGER">PENDING_MANAGER</option>
      
        <option value="PENDING_HR">PENDING_HR</option>
      
        <option value="APPROVED">APPROVED</option>
      
        <option value="REJECTED">REJECTED</option>
      
        <option value="CANCELLED">CANCELLED</option>
      
      </Field>
  </FormField>















    <FormField label="ManagerNote" hasTextareaHeight>
        <Field name="managerNote" as="textarea" placeholder="ManagerNote" />
    </FormField>



























    <FormField label="HRNote" hasTextareaHeight>
        <Field name="hrNote" as="textarea" placeholder="HRNote" />
    </FormField>











































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



















  <FormField
      label="ApprovedAt"
  >
      <Field
          type="datetime-local"
          name="approvedAt"
          placeholder="ApprovedAt"
      />
  </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('/leave_applications/leave_applications-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Leave_applicationsNew
