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 = {
    
    
    employee_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    first_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    preferred_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    phone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    national_id: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    date_of_birth: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    gender: 'male',
    
    
    
    
    
    
    
    
    address: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    hire_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    termination_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    employment_status: 'active',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    company: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    department: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    job_title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    work_location: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    manager: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    user_account: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    profile_photo: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    employment_type: 'full_time',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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="EmployeeNumber"
  >
      <Field
          name="employee_number"
          placeholder="EmployeeNumber"
      />
  </FormField>



























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



























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



























  <FormField
      label="PreferredName"
  >
      <Field
          name="preferred_name"
          placeholder="PreferredName"
      />
  </FormField>



























  <FormField
      label="WorkEmail"
  >
      <Field
          name="email"
          placeholder="WorkEmail"
      />
  </FormField>



























  <FormField
      label="Phone"
  >
      <Field
          name="phone"
          placeholder="Phone"
      />
  </FormField>



























  <FormField
      label="NationalID"
  >
      <Field
          name="national_id"
          placeholder="NationalID"
      />
  </FormField>





































  <FormField
      label="DateofBirth"
  >
      <Field
          type="datetime-local"
          name="date_of_birth"
          placeholder="DateofBirth"
      />
  </FormField>































  <FormField label="Gender" labelFor="gender">
      <Field name="gender" id="gender" component="select">
      
        <option value="male">male</option>
      
        <option value="female">female</option>
      
        <option value="non_binary">non_binary</option>
      
        <option value="prefer_not_to_say">prefer_not_to_say</option>
      
      </Field>
  </FormField>















    <FormField label="Address" hasTextareaHeight>
        <Field name="address" as="textarea" placeholder="Address" />
    </FormField>



































  <FormField
      label="HireDate"
  >
      <Field
          type="datetime-local"
          name="hire_date"
          placeholder="HireDate"
      />
  </FormField>



























  <FormField
      label="TerminationDate"
  >
      <Field
          type="datetime-local"
          name="termination_date"
          placeholder="TerminationDate"
      />
  </FormField>































  <FormField label="EmploymentStatus" labelFor="employment_status">
      <Field name="employment_status" id="employment_status" component="select">
      
        <option value="active">active</option>
      
        <option value="probation">probation</option>
      
        <option value="on_leave">on_leave</option>
      
        <option value="terminated">terminated</option>
      
      </Field>
  </FormField>































  <FormField label="Company" labelFor="company">
      <Field name="company" id="company" component={SelectField} options={[]} itemRef={'companies'}></Field>
  </FormField>



























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



























  <FormField label="JobTitle" labelFor="job_title">
      <Field name="job_title" id="job_title" component={SelectField} options={[]} itemRef={'job_titles'}></Field>
  </FormField>



























  <FormField label="WorkLocation" labelFor="work_location">
      <Field name="work_location" id="work_location" component={SelectField} options={[]} itemRef={'work_locations'}></Field>
  </FormField>



























  <FormField label="Manager" labelFor="manager">
      <Field name="manager" id="manager" component={SelectField} options={[]} itemRef={'employees'}></Field>
  </FormField>



























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































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



















  <FormField label="EmploymentType" labelFor="employment_type">
      <Field name="employment_type" id="employment_type" component="select">
      
        <option value="full_time">full_time</option>
      
        <option value="part_time">part_time</option>
      
        <option value="contractor">contractor</option>
      
        <option value="intern">intern</option>
      
      </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('/employees/employees-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default EmployeesNew
