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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    payroll_item: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    category: 'earning',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    adjustment_type: 'telat_denda',
    
    
    
    
    
    
    
    amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    created_by_user: '',
    
    
    
    
    
    
    
    
    
    effective_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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























  <FormField label="Category" labelFor="category">
      <Field name="category" id="category" component="select">
      
        <option value="earning">earning</option>
      
        <option value="deduction">deduction</option>
      
      </Field>
  </FormField>



























  <FormField label="AdjustmentType" labelFor="adjustment_type">
      <Field name="adjustment_type" id="adjustment_type" component="select">
      
        <option value="telat_denda">telat_denda</option>
      
        <option value="tidak_hadir">tidak_hadir</option>
      
        <option value="pinjaman">pinjaman</option>
      
        <option value="deposit_seragam">deposit_seragam</option>
      
        <option value="refund_seragam">refund_seragam</option>
      
        <option value="waste">waste</option>
      
        <option value="manual_addition">manual_addition</option>
      
        <option value="manual_deduction">manual_deduction</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Amount"
    >
        <Field
            type="number"
            name="amount"
            placeholder="Amount"
        />
    </FormField>























    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </FormField>











































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



















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

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

export default Payroll_adjustmentsNew
