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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    entry_type: 'grade_9_entry',
    
    
    
    
    
    
    
    applicant_full_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    gender: 'female',
    
    
    
    
    
    
    
    
    
    
    
    
    date_of_birth: '',
    
    
    
    
    
    
    
    
    
    
    previous_school: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requested_grade: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requested_stream: '',
    
    
    
    
    guardian_full_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    guardian_phone: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    guardian_email: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    documents: [],
    
    
    
    
    
    
    
    
    
    
    
    submitted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'submitted',
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/admission_applications/admission_applications-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="EntryType" labelFor="entry_type">
      <Field name="entry_type" id="entry_type" component="select">
      
        <option value="grade_9_entry">grade_9_entry</option>
      
        <option value="transfer">transfer</option>
      
      </Field>
  </FormField>













  <FormField
      label="ApplicantFullName"
  >
      <Field
          name="applicant_full_name"
          placeholder="ApplicantFullName"
      />
  </FormField>









































  <FormField label="Gender" labelFor="gender">
      <Field name="gender" id="gender" component="select">
      
        <option value="female">female</option>
      
        <option value="male">male</option>
      
      </Field>
  </FormField>























  <FormField
      label="DateOfBirth"
  >
      <Field
          type="datetime-local"
          name="date_of_birth"
          placeholder="DateOfBirth"
      />
  </FormField>

















  <FormField
      label="PreviousSchool"
  >
      <Field
          name="previous_school"
          placeholder="PreviousSchool"
      />
  </FormField>













































  <FormField label="RequestedGrade" labelFor="requested_grade">
      <Field name="requested_grade" id="requested_grade" component={SelectField} options={[]} itemRef={'grades'}></Field>
  </FormField>



























  <FormField label="RequestedStream" labelFor="requested_stream">
      <Field name="requested_stream" id="requested_stream" component={SelectField} options={[]} itemRef={'streams'}></Field>
  </FormField>









  <FormField
      label="GuardianFullName"
  >
      <Field
          name="guardian_full_name"
          placeholder="GuardianFullName"
      />
  </FormField>



























  <FormField
      label="GuardianPhone"
  >
      <Field
          name="guardian_phone"
          placeholder="GuardianPhone"
      />
  </FormField>



























  <FormField
      label="GuardianEmail"
  >
      <Field
          name="guardian_email"
          placeholder="GuardianEmail"
      />
  </FormField>





























    <FormField label="Address" hasTextareaHeight>
        <Field name="address_text" as="textarea" placeholder="Address" />
    </FormField>
















































  <FormField>
      <Field
          label='Documents'
          color='info'
          icon={mdiUpload}
          path={'admission_applications/documents'}
          name='documents'
          id='documents'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>














  <FormField
      label="SubmittedAt"
  >
      <Field
          type="datetime-local"
          name="submitted_at"
          placeholder="SubmittedAt"
      />
  </FormField>































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="submitted">submitted</option>
      
        <option value="under_review">under_review</option>
      
        <option value="accepted">accepted</option>
      
        <option value="rejected">rejected</option>
      
        <option value="waitlisted">waitlisted</option>
      
      </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('/admission_applications/admission_applications-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Admission_applicationsNew
