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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    school: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    current_class: '',
    
    
    
    
    nis: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    nisn: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    birth_place: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    birth_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    gender: 'laki_laki',
    
    
    
    
    
    
    
    
    address: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    enrollment_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'aktif',
    
    
    
    
    
    
}


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

    
    

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



























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



























  <FormField label="CurrentClass" labelFor="current_class">
      <Field name="current_class" id="current_class" component={SelectField} options={[]} itemRef={'classes'}></Field>
  </FormField>









  <FormField
      label="NIS"
  >
      <Field
          name="nis"
          placeholder="NIS"
      />
  </FormField>



























  <FormField
      label="NISN"
  >
      <Field
          name="nisn"
          placeholder="NISN"
      />
  </FormField>



























  <FormField
      label="BirthPlace"
  >
      <Field
          name="birth_place"
          placeholder="BirthPlace"
      />
  </FormField>





































  <FormField
      label="BirthDate"
  >
      <Field
          type="datetime-local"
          name="birth_date"
          placeholder="BirthDate"
      />
  </FormField>































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















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



































  <FormField
      label="EnrollmentDate"
  >
      <Field
          type="datetime-local"
          name="enrollment_date"
          placeholder="EnrollmentDate"
      />
  </FormField>































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="aktif">aktif</option>
      
        <option value="nonaktif">nonaktif</option>
      
        <option value="lulus">lulus</option>
      
        <option value="pindah">pindah</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('/students/students-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default StudentsNew
