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_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    full_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    phone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    nik: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    npwp: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bank_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bank_account_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bank_account_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    outlet: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    job_position: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    employment_status: 'probation',
    
    
    
    
    
    
    
    
    
    
    
    
    join_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    resign_date: '',
    
    
    
    
    
    
    
    
    
    
    base_salary_monthly: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    position_allowance_fixed: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    meal_allowance_daily: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    transport_allowance_daily: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    prorate_position_allowance_under_20_days: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_active: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    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="EmployeeCode"
  >
      <Field
          name="employee_code"
          placeholder="EmployeeCode"
      />
  </FormField>



























  <FormField
      label="FullName"
  >
      <Field
          name="full_name"
          placeholder="FullName"
      />
  </FormField>



























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



























  <FormField
      label="NIK"
  >
      <Field
          name="nik"
          placeholder="NIK"
      />
  </FormField>



























  <FormField
      label="NPWP"
  >
      <Field
          name="npwp"
          placeholder="NPWP"
      />
  </FormField>



























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



























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



























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













































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



























  <FormField label="Outlet" labelFor="outlet">
      <Field name="outlet" id="outlet" component={SelectField} options={[]} itemRef={'outlets'}></Field>
  </FormField>



























  <FormField label="JobPosition" labelFor="job_position">
      <Field name="job_position" id="job_position" component={SelectField} options={[]} itemRef={'job_positions'}></Field>
  </FormField>























  <FormField label="EmploymentStatus" labelFor="employment_status">
      <Field name="employment_status" id="employment_status" component="select">
      
        <option value="probation">probation</option>
      
        <option value="contract">contract</option>
      
        <option value="permanent">permanent</option>
      
        <option value="resigned">resigned</option>
      
      </Field>
  </FormField>























  <FormField
      label="JoinDate"
  >
      <Field
          type="datetime-local"
          name="join_date"
          placeholder="JoinDate"
      />
  </FormField>



























  <FormField
      label="ResignDate"
  >
      <Field
          type="datetime-local"
          name="resign_date"
          placeholder="ResignDate"
      />
  </FormField>























    <FormField
        label="BaseSalary(Monthly)"
    >
        <Field
            type="number"
            name="base_salary_monthly"
            placeholder="BaseSalary(Monthly)"
        />
    </FormField>



























    <FormField
        label="PositionAllowance(Fixed)"
    >
        <Field
            type="number"
            name="position_allowance_fixed"
            placeholder="PositionAllowance(Fixed)"
        />
    </FormField>



























    <FormField
        label="MealAllowance(Daily)"
    >
        <Field
            type="number"
            name="meal_allowance_daily"
            placeholder="MealAllowance(Daily)"
        />
    </FormField>



























    <FormField
        label="TransportAllowance(Daily)"
    >
        <Field
            type="number"
            name="transport_allowance_daily"
            placeholder="TransportAllowance(Daily)"
        />
    </FormField>





































  <FormField label='ProratePositionAllowanceUnder20Days' labelFor='prorate_position_allowance_under_20_days'>
      <Field
          name='prorate_position_allowance_under_20_days'
          id='prorate_position_allowance_under_20_days'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='IsActive' labelFor='is_active'>
      <Field
          name='is_active'
          id='is_active'
          component={SwitchField}
      ></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
