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

const initialValues = {
    
    
    title_om: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    title_am: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    title_en: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    material_type: 'past_exam_paper',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    grade: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    subject: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    stream: '',
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    file: [],
    
    
    
    
    
    
    external_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    visibility: 'public',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    uploaded_by: '',
    
    
    
    
    
    
    
    
    
    published_at: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/study_materials/study_materials-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="TitleAfaanOromoo"
  >
      <Field
          name="title_om"
          placeholder="TitleAfaanOromoo"
      />
  </FormField>



























  <FormField
      label="TitleAmharic"
  >
      <Field
          name="title_am"
          placeholder="TitleAmharic"
      />
  </FormField>



























  <FormField
      label="TitleEnglish"
  >
      <Field
          name="title_en"
          placeholder="TitleEnglish"
      />
  </FormField>









































  <FormField label="MaterialType" labelFor="material_type">
      <Field name="material_type" id="material_type" component="select">
      
        <option value="past_exam_paper">past_exam_paper</option>
      
        <option value="revision_notes">revision_notes</option>
      
        <option value="practice_questions">practice_questions</option>
      
        <option value="reference_list">reference_list</option>
      
        <option value="video_link">video_link</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>































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



























  <FormField label="Subject" labelFor="subject">
      <Field name="subject" id="subject" component={SelectField} options={[]} itemRef={'subjects'}></Field>
  </FormField>



























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













      <FormField label='Description' hasTextareaHeight>
          <Field
              name='description'
              id='description'
              component={RichTextField}
          ></Field>
      </FormField>














































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




  <FormField
      label="ExternalURL"
  >
      <Field
          name="external_url"
          placeholder="ExternalURL"
      />
  </FormField>









































  <FormField label="Visibility" labelFor="visibility">
      <Field name="visibility" id="visibility" component="select">
      
        <option value="public">public</option>
      
        <option value="students_only">students_only</option>
      
      </Field>
  </FormField>































  <FormField label="UploadedBy" labelFor="uploaded_by">
      <Field name="uploaded_by" id="uploaded_by" component={SelectField} options={[]} itemRef={'staff_members'}></Field>
  </FormField>



















  <FormField
      label="PublishedAt"
  >
      <Field
          type="datetime-local"
          name="published_at"
          placeholder="PublishedAt"
      />
  </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('/study_materials/study_materials-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Study_materialsNew
