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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    fee_definition: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    student: '',
    
    
    
    
    bill_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    period_type: 'bulanan',
    
    
    
    
    
    
    
    
    
    
    period_year: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    period_month: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    issued_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    due_at: '',
    
    
    
    
    
    
    
    
    
    
    amount_total: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    amount_paid: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'belum_bayar',
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    schools: '',
    
    
    
}


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

    
    

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



























  <FormField label="Student" labelFor="student">
      <Field name="student" id="student" component={SelectField} options={[]} itemRef={'students'}></Field>
  </FormField>









  <FormField
      label="BillNumber"
  >
      <Field
          name="bill_number"
          placeholder="BillNumber"
      />
  </FormField>









































  <FormField label="PeriodType" labelFor="period_type">
      <Field name="period_type" id="period_type" component="select">
      
        <option value="bulanan">bulanan</option>
      
        <option value="sekali">sekali</option>
      
      </Field>
  </FormField>



















    <FormField
        label="PeriodYear"
    >
        <Field
            type="number"
            name="period_year"
            placeholder="PeriodYear"
        />
    </FormField>



























    <FormField
        label="PeriodMonth"
    >
        <Field
            type="number"
            name="period_month"
            placeholder="PeriodMonth"
        />
    </FormField>































  <FormField
      label="IssuedAt"
  >
      <Field
          type="datetime-local"
          name="issued_at"
          placeholder="IssuedAt"
      />
  </FormField>



























  <FormField
      label="DueAt"
  >
      <Field
          type="datetime-local"
          name="due_at"
          placeholder="DueAt"
      />
  </FormField>























    <FormField
        label="TotalAmount"
    >
        <Field
            type="number"
            name="amount_total"
            placeholder="TotalAmount"
        />
    </FormField>



























    <FormField
        label="AmountPaid"
    >
        <Field
            type="number"
            name="amount_paid"
            placeholder="AmountPaid"
        />
    </FormField>



































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="belum_bayar">belum_bayar</option>
      
        <option value="cicilan">cicilan</option>
      
        <option value="lunas">lunas</option>
      
        <option value="jatuh_tempo">jatuh_tempo</option>
      
        <option value="dibatalkan">dibatalkan</option>
      
      </Field>
  </FormField>















    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </FormField>











































  <FormField label="schools" labelFor="schools">
      <Field name="schools" id="schools" component={SelectField} options={[]} itemRef={'schools'}></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('/billing_items/billing_items-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Billing_itemsNew
