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

const initialValues = {
    
    
    employeeCode: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    firstName: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    middleName: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    lastName: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    nameExtension: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    dateOfBirth: '',
    
    
    
    
    
    
    
    
    
    
    placeOfBirth: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sex: 'MALE',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    civilStatus: 'SINGLE',
    
    
    
    
    
    
    
    nationality: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    religion: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bloodType: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    profilePhoto: [],
    
    
    
    
    
    homeStreet: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    homeBarangay: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    homeCity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    homeProvince: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    homeZipCode: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    permanentAddressSame: false,
    
    
    
    
    
    
    
    
    
    permanentStreet: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    permanentBarangay: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    permanentCity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    permanentProvince: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    permanentZipCode: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    personalEmail: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    personalMobile: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    emergencyContactName: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    emergencyContactRel: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    emergencyContactMobile: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sssNumber: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    philhealthNumber: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    pagibigNumber: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tinNumber: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bankName: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bankAccountNumber: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bankAccountName: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    employmentDate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    regularizationDate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    employmentStatus: 'PROBATIONARY',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    employmentType: 'FULL_TIME',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    jobLevel: 'RANK_AND_FILE',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    salaryType: 'MONTHLY',
    
    
    
    
    
    
    
    basicSalary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    taxStatus: 'S',
    
    
    
    
    
    
    
    workLocation: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    separationDate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    separationType: 'RESIGNED',
    
    
    
    
    
    
    
    
    separationReason: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    clearanceStatus: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    finalPayAmount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    finalPayReleasedDate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    isActive: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    department: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    position: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    shift: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reportingTo: '',
    
    
    
}


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

    
    

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



























  <FormField
      label="FirstName"
  >
      <Field
          name="firstName"
          placeholder="FirstName"
      />
  </FormField>



























  <FormField
      label="MiddleName"
  >
      <Field
          name="middleName"
          placeholder="MiddleName"
      />
  </FormField>



























  <FormField
      label="LastName"
  >
      <Field
          name="lastName"
          placeholder="LastName"
      />
  </FormField>



























  <FormField
      label="NameExtension"
  >
      <Field
          name="nameExtension"
          placeholder="NameExtension"
      />
  </FormField>





































  <FormField
      label="DateOfBirth"
  >
      <Field
          type="datetime-local"
          name="dateOfBirth"
          placeholder="DateOfBirth"
      />
  </FormField>

















  <FormField
      label="PlaceOfBirth"
  >
      <Field
          name="placeOfBirth"
          placeholder="PlaceOfBirth"
      />
  </FormField>









































  <FormField label="Sex" labelFor="sex">
      <Field name="sex" id="sex" component="select">
      
        <option value="MALE">MALE</option>
      
        <option value="FEMALE">FEMALE</option>
      
      </Field>
  </FormField>



























  <FormField label="CivilStatus" labelFor="civilStatus">
      <Field name="civilStatus" id="civilStatus" component="select">
      
        <option value="SINGLE">SINGLE</option>
      
        <option value="MARRIED">MARRIED</option>
      
        <option value="WIDOWED">WIDOWED</option>
      
        <option value="SEPARATED">SEPARATED</option>
      
        <option value="LEGALLY_SEPARATED">LEGALLY_SEPARATED</option>
      
      </Field>
  </FormField>













  <FormField
      label="Nationality"
  >
      <Field
          name="nationality"
          placeholder="Nationality"
      />
  </FormField>



























  <FormField
      label="Religion"
  >
      <Field
          name="religion"
          placeholder="Religion"
      />
  </FormField>



























  <FormField
      label="BloodType"
  >
      <Field
          name="bloodType"
          placeholder="BloodType"
      />
  </FormField>

















































  <FormField>
      <Field
          label='ProfilePhoto'
          color='info'
          icon={mdiUpload}
          path={'employees/profilePhoto'}
          name='profilePhoto'
          id='profilePhoto'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></Field>
  </FormField>





  <FormField
      label="HomeStreet"
  >
      <Field
          name="homeStreet"
          placeholder="HomeStreet"
      />
  </FormField>



























  <FormField
      label="HomeBarangay"
  >
      <Field
          name="homeBarangay"
          placeholder="HomeBarangay"
      />
  </FormField>



























  <FormField
      label="HomeCity"
  >
      <Field
          name="homeCity"
          placeholder="HomeCity"
      />
  </FormField>



























  <FormField
      label="HomeProvince"
  >
      <Field
          name="homeProvince"
          placeholder="HomeProvince"
      />
  </FormField>



























  <FormField
      label="HomeZipCode"
  >
      <Field
          name="homeZipCode"
          placeholder="HomeZipCode"
      />
  </FormField>











































  <FormField label='PermanentAddressSame' labelFor='permanentAddressSame'>
      <Field
          name='permanentAddressSame'
          id='permanentAddressSame'
          component={SwitchField}
      ></Field>
  </FormField>











  <FormField
      label="PermanentStreet"
  >
      <Field
          name="permanentStreet"
          placeholder="PermanentStreet"
      />
  </FormField>



























  <FormField
      label="PermanentBarangay"
  >
      <Field
          name="permanentBarangay"
          placeholder="PermanentBarangay"
      />
  </FormField>



























  <FormField
      label="PermanentCity"
  >
      <Field
          name="permanentCity"
          placeholder="PermanentCity"
      />
  </FormField>



























  <FormField
      label="PermanentProvince"
  >
      <Field
          name="permanentProvince"
          placeholder="PermanentProvince"
      />
  </FormField>



























  <FormField
      label="PermanentZipCode"
  >
      <Field
          name="permanentZipCode"
          placeholder="PermanentZipCode"
      />
  </FormField>



























  <FormField
      label="PersonalEmail"
  >
      <Field
          name="personalEmail"
          placeholder="PersonalEmail"
      />
  </FormField>



























  <FormField
      label="PersonalMobile"
  >
      <Field
          name="personalMobile"
          placeholder="PersonalMobile"
      />
  </FormField>



























  <FormField
      label="EmergencyContactName"
  >
      <Field
          name="emergencyContactName"
          placeholder="EmergencyContactName"
      />
  </FormField>



























  <FormField
      label="EmergencyContactRelationship"
  >
      <Field
          name="emergencyContactRel"
          placeholder="EmergencyContactRelationship"
      />
  </FormField>



























  <FormField
      label="EmergencyContactMobile"
  >
      <Field
          name="emergencyContactMobile"
          placeholder="EmergencyContactMobile"
      />
  </FormField>



























  <FormField
      label="SSSNumber"
  >
      <Field
          name="sssNumber"
          placeholder="SSSNumber"
      />
  </FormField>



























  <FormField
      label="PhilHealthNumber"
  >
      <Field
          name="philhealthNumber"
          placeholder="PhilHealthNumber"
      />
  </FormField>



























  <FormField
      label="PagIbigNumber"
  >
      <Field
          name="pagibigNumber"
          placeholder="PagIbigNumber"
      />
  </FormField>



























  <FormField
      label="TINNumber"
  >
      <Field
          name="tinNumber"
          placeholder="TINNumber"
      />
  </FormField>



























  <FormField
      label="BankName"
  >
      <Field
          name="bankName"
          placeholder="BankName"
      />
  </FormField>



























  <FormField
      label="BankAccountNumber"
  >
      <Field
          name="bankAccountNumber"
          placeholder="BankAccountNumber"
      />
  </FormField>



























  <FormField
      label="BankAccountName"
  >
      <Field
          name="bankAccountName"
          placeholder="BankAccountName"
      />
  </FormField>





































  <FormField
      label="EmploymentDate"
  >
      <Field
          type="datetime-local"
          name="employmentDate"
          placeholder="EmploymentDate"
      />
  </FormField>



























  <FormField
      label="RegularizationDate"
  >
      <Field
          type="datetime-local"
          name="regularizationDate"
          placeholder="RegularizationDate"
      />
  </FormField>































  <FormField label="EmploymentStatus" labelFor="employmentStatus">
      <Field name="employmentStatus" id="employmentStatus" component="select">
      
        <option value="PROBATIONARY">PROBATIONARY</option>
      
        <option value="REGULAR">REGULAR</option>
      
        <option value="CONTRACTUAL">CONTRACTUAL</option>
      
        <option value="PROJECT_BASED">PROJECT_BASED</option>
      
      </Field>
  </FormField>



























  <FormField label="EmploymentType" labelFor="employmentType">
      <Field name="employmentType" id="employmentType" component="select">
      
        <option value="FULL_TIME">FULL_TIME</option>
      
        <option value="PART_TIME">PART_TIME</option>
      
      </Field>
  </FormField>



























  <FormField label="JobLevel" labelFor="jobLevel">
      <Field name="jobLevel" id="jobLevel" component="select">
      
        <option value="RANK_AND_FILE">RANK_AND_FILE</option>
      
        <option value="SUPERVISOR">SUPERVISOR</option>
      
        <option value="MANAGER">MANAGER</option>
      
        <option value="OFFICER">OFFICER</option>
      
      </Field>
  </FormField>



























  <FormField label="SalaryType" labelFor="salaryType">
      <Field name="salaryType" id="salaryType" component="select">
      
        <option value="MONTHLY">MONTHLY</option>
      
        <option value="DAILY">DAILY</option>
      
        <option value="HOURLY">HOURLY</option>
      
      </Field>
  </FormField>



















    <FormField
        label="BasicSalary"
    >
        <Field
            type="number"
            name="basicSalary"
            placeholder="BasicSalary"
        />
    </FormField>



































  <FormField label="TaxStatus" labelFor="taxStatus">
      <Field name="taxStatus" id="taxStatus" component="select">
      
        <option value="S">S</option>
      
        <option value="ME">ME</option>
      
        <option value="S1">S1</option>
      
        <option value="S2">S2</option>
      
        <option value="S3">S3</option>
      
        <option value="S4">S4</option>
      
        <option value="ME1">ME1</option>
      
        <option value="ME2">ME2</option>
      
        <option value="ME3">ME3</option>
      
        <option value="ME4">ME4</option>
      
      </Field>
  </FormField>













  <FormField
      label="WorkLocation"
  >
      <Field
          name="workLocation"
          placeholder="WorkLocation"
      />
  </FormField>





































  <FormField
      label="SeparationDate"
  >
      <Field
          type="datetime-local"
          name="separationDate"
          placeholder="SeparationDate"
      />
  </FormField>































  <FormField label="SeparationType" labelFor="separationType">
      <Field name="separationType" id="separationType" component="select">
      
        <option value="RESIGNED">RESIGNED</option>
      
        <option value="TERMINATED">TERMINATED</option>
      
        <option value="RETIRED">RETIRED</option>
      
        <option value="REDUNDANCY">REDUNDANCY</option>
      
        <option value="AWOL">AWOL</option>
      
        <option value="DEATH">DEATH</option>
      
      </Field>
  </FormField>















    <FormField label="SeparationReason" hasTextareaHeight>
        <Field name="separationReason" as="textarea" placeholder="SeparationReason" />
    </FormField>

























  <FormField
      label="ClearanceStatus"
  >
      <Field
          name="clearanceStatus"
          placeholder="ClearanceStatus"
      />
  </FormField>

































    <FormField
        label="FinalPayAmount"
    >
        <Field
            type="number"
            name="finalPayAmount"
            placeholder="FinalPayAmount"
        />
    </FormField>































  <FormField
      label="FinalPayReleasedDate"
  >
      <Field
          type="datetime-local"
          name="finalPayReleasedDate"
          placeholder="FinalPayReleasedDate"
      />
  </FormField>

































  <FormField label='IsActive' labelFor='isActive'>
      <Field
          name='isActive'
          id='isActive'
          component={SwitchField}
      ></Field>
  </FormField>





























  <FormField label="Department" labelFor="department">
      <Field name="department" id="department" component={SelectField} options={[]} itemRef={'departments'}></Field>
  </FormField>



























  <FormField label="Position" labelFor="position">
      <Field name="position" id="position" component={SelectField} options={[]} itemRef={'positions'}></Field>
  </FormField>



























  <FormField label="Shift" labelFor="shift">
      <Field name="shift" id="shift" component={SelectField} options={[]} itemRef={'shifts'}></Field>
  </FormField>



























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

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

export default EmployeesNew
