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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    loan: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payrollItem: '',
    
    
    
    
    amountDeducted: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    deductionDate: '',
    
    
    
    
    
    
    
    
    
    
    balanceBefore: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    balanceAfter: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    isDeferred: false,
    
    
    
    
    
    
    
    
    
    
    deferredReason: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="PayrollItem" labelFor="payrollItem">
      <Field name="payrollItem" id="payrollItem" component={SelectField} options={[]} itemRef={'payroll_items'}></Field>
  </FormField>















    <FormField
        label="AmountDeducted"
    >
        <Field
            type="number"
            name="amountDeducted"
            placeholder="AmountDeducted"
        />
    </FormField>































  <FormField
      label="DeductionDate"
  >
      <Field
          type="datetime-local"
          name="deductionDate"
          placeholder="DeductionDate"
      />
  </FormField>























    <FormField
        label="BalanceBefore"
    >
        <Field
            type="number"
            name="balanceBefore"
            placeholder="BalanceBefore"
        />
    </FormField>



























    <FormField
        label="BalanceAfter"
    >
        <Field
            type="number"
            name="balanceAfter"
            placeholder="BalanceAfter"
        />
    </FormField>





































  <FormField label='IsDeferred' labelFor='isDeferred'>
      <Field
          name='isDeferred'
          id='isDeferred'
          component={SwitchField}
      ></Field>
  </FormField>













    <FormField label="DeferredReason" hasTextareaHeight>
        <Field name="deferredReason" as="textarea" placeholder="DeferredReason" />
    </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('/loan_deductions/loan_deductions-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Loan_deductionsNew
