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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    grade_item: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    student: '',
    
    
    
    
    score: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    letter_grade: 'A',
    
    
    
    
    
    
    
    
    
    
    
    
    graded_at: '',
    
    
    
    
    
    
    
    
    
    
    
    comment: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    published: false,
    
    
    
    
    
    
    
    
}


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

    
    

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



























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















    <FormField
        label="Score"
    >
        <Field
            type="number"
            name="score"
            placeholder="Score"
        />
    </FormField>



































  <FormField label="LetterGrade" labelFor="letter_grade">
      <Field name="letter_grade" id="letter_grade" component="select">
      
        <option value="A">A</option>
      
        <option value="B">B</option>
      
        <option value="C">C</option>
      
        <option value="D">D</option>
      
        <option value="F">F</option>
      
        <option value="I">I</option>
      
      </Field>
  </FormField>























  <FormField
      label="GradedAt"
  >
      <Field
          type="datetime-local"
          name="graded_at"
          placeholder="GradedAt"
      />
  </FormField>



















    <FormField label="Comment" hasTextareaHeight>
        <Field name="comment" as="textarea" placeholder="Comment" />
    </FormField>









































  <FormField label='Published' labelFor='published'>
      <Field
          name='published'
          id='published'
          component={SwitchField}
      ></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('/grade_records/grade_records-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Grade_recordsNew
