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

const initialValues = {
    
    
    
    
    
    
    
    periodFrom: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    periodTo: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payrollType: 'SEMI_MONTHLY_1',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'DRAFT',
    
    
    
    
    
    
    
    
    
    
    
    
    lockedAt: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    computedAt: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approvedAt: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    postedAt: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approvedByUser: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    postedByUser: '',
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    journalEntry: '',
    
    
    
}


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

    
    

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



























  <FormField
      label="PeriodTo"
  >
      <Field
          type="datetime-local"
          name="periodTo"
          placeholder="PeriodTo"
      />
  </FormField>































  <FormField label="PayrollType" labelFor="payrollType">
      <Field name="payrollType" id="payrollType" component="select">
      
        <option value="SEMI_MONTHLY_1">SEMI_MONTHLY_1</option>
      
        <option value="SEMI_MONTHLY_2">SEMI_MONTHLY_2</option>
      
        <option value="THIRTEENTH_MONTH">THIRTEENTH_MONTH</option>
      
        <option value="FINAL_PAY">FINAL_PAY</option>
      
        <option value="ADJUSTMENT">ADJUSTMENT</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="DRAFT">DRAFT</option>
      
        <option value="COMPUTED">COMPUTED</option>
      
        <option value="APPROVED">APPROVED</option>
      
        <option value="POSTED">POSTED</option>
      
        <option value="VOIDED">VOIDED</option>
      
      </Field>
  </FormField>























  <FormField
      label="LockedAt"
  >
      <Field
          type="datetime-local"
          name="lockedAt"
          placeholder="LockedAt"
      />
  </FormField>



























  <FormField
      label="ComputedAt"
  >
      <Field
          type="datetime-local"
          name="computedAt"
          placeholder="ComputedAt"
      />
  </FormField>



























  <FormField
      label="ApprovedAt"
  >
      <Field
          type="datetime-local"
          name="approvedAt"
          placeholder="ApprovedAt"
      />
  </FormField>



























  <FormField
      label="PostedAt"
  >
      <Field
          type="datetime-local"
          name="postedAt"
          placeholder="PostedAt"
      />
  </FormField>



































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



























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











    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </FormField>











































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

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

export default Payroll_runsNew
