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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    course_section: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    teacher: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    category: 'homework',
    
    
    
    
    
    
    
    weight: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    max_points: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    assigned_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    due_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    published: false,
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Teacher" labelFor="teacher">
      <Field name="teacher" id="teacher" component={SelectField} options={[]} itemRef={'teachers'}></Field>
  </FormField>









  <FormField
      label="GradeItemName"
  >
      <Field
          name="name"
          placeholder="GradeItemName"
      />
  </FormField>









































  <FormField label="Category" labelFor="category">
      <Field name="category" id="category" component="select">
      
        <option value="homework">homework</option>
      
        <option value="quiz">quiz</option>
      
        <option value="test">test</option>
      
        <option value="project">project</option>
      
        <option value="participation">participation</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Weight"
    >
        <Field
            type="number"
            name="weight"
            placeholder="Weight"
        />
    </FormField>



























    <FormField
        label="MaxPoints"
    >
        <Field
            type="number"
            name="max_points"
            placeholder="MaxPoints"
        />
    </FormField>































  <FormField
      label="AssignedAt"
  >
      <Field
          type="datetime-local"
          name="assigned_at"
          placeholder="AssignedAt"
      />
  </FormField>



























  <FormField
      label="DueAt"
  >
      <Field
          type="datetime-local"
          name="due_at"
          placeholder="DueAt"
      />
  </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_items/grade_items-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Grade_itemsNew
