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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    employee: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    loanType: 'SSS',
    
    
    
    
    
    
    
    loanSource: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    loanAmount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approvalDate: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    firstDeductionDate: '',
    
    
    
    
    
    
    
    
    
    
    monthlyAmortization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    remainingBalance: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    termsMonths: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'ACTIVE',
    
    
    
    
    
    
    
    loanAccountNumber: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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























  <FormField label="LoanType" labelFor="loanType">
      <Field name="loanType" id="loanType" component="select">
      
        <option value="SSS">SSS</option>
      
        <option value="PAG_IBIG">PAG_IBIG</option>
      
        <option value="COMPANY">COMPANY</option>
      
        <option value="SALARY">SALARY</option>
      
      </Field>
  </FormField>













  <FormField
      label="LoanSource"
  >
      <Field
          name="loanSource"
          placeholder="LoanSource"
      />
  </FormField>

































    <FormField
        label="LoanAmount"
    >
        <Field
            type="number"
            name="loanAmount"
            placeholder="LoanAmount"
        />
    </FormField>































  <FormField
      label="ApprovalDate"
  >
      <Field
          type="datetime-local"
          name="approvalDate"
          placeholder="ApprovalDate"
      />
  </FormField>



























  <FormField
      label="FirstDeductionDate"
  >
      <Field
          type="datetime-local"
          name="firstDeductionDate"
          placeholder="FirstDeductionDate"
      />
  </FormField>























    <FormField
        label="MonthlyAmortization"
    >
        <Field
            type="number"
            name="monthlyAmortization"
            placeholder="MonthlyAmortization"
        />
    </FormField>



























    <FormField
        label="RemainingBalance"
    >
        <Field
            type="number"
            name="remainingBalance"
            placeholder="RemainingBalance"
        />
    </FormField>



























    <FormField
        label="TermsMonths"
    >
        <Field
            type="number"
            name="termsMonths"
            placeholder="TermsMonths"
        />
    </FormField>



































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="ACTIVE">ACTIVE</option>
      
        <option value="FULLY_PAID">FULLY_PAID</option>
      
        <option value="CANCELLED">CANCELLED</option>
      
        <option value="DEFERRED">DEFERRED</option>
      
      </Field>
  </FormField>













  <FormField
      label="LoanAccountNumber"
  >
      <Field
          name="loanAccountNumber"
          placeholder="LoanAccountNumber"
      />
  </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('/employee_loans/employee_loans-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Employee_loansNew
