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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    applicant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    school: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    requested_role: 'student',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    application_status: 'pending',
    
    
    
    
    
    
    
    
    application_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reviewed_by: '',
    
    
    
    
    
    
    
    
    
    reviewed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    supporting_documents: [],
    
    
    
    
    
}


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

    
    

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



























  <FormField label="School" labelFor="school">
      <Field name="school" id="school" component={SelectField} options={[]} itemRef={'schools'}></Field>
  </FormField>























  <FormField label="RequestedRole" labelFor="requested_role">
      <Field name="requested_role" id="requested_role" component="select">
      
        <option value="student">student</option>
      
        <option value="teacher">teacher</option>
      
        <option value="principal">principal</option>
      
      </Field>
  </FormField>



























  <FormField label="ApplicationStatus" labelFor="application_status">
      <Field name="application_status" id="application_status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="approved">approved</option>
      
        <option value="rejected">rejected</option>
      
        <option value="needs_more_info">needs_more_info</option>
      
      </Field>
  </FormField>















    <FormField label="ApplicationNotes" hasTextareaHeight>
        <Field name="application_notes" as="textarea" placeholder="ApplicationNotes" />
    </FormField>











































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



















  <FormField
      label="ReviewedAt"
  >
      <Field
          type="datetime-local"
          name="reviewed_at"
          placeholder="ReviewedAt"
      />
  </FormField>








































  <FormField>
      <Field
          label='SupportingDocuments'
          color='info'
          icon={mdiUpload}
          path={'account_applications/supporting_documents'}
          name='supporting_documents'
          id='supporting_documents'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></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('/account_applications/account_applications-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Account_applicationsNew
