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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    question: '',
    
    
    
    
    answer_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    answer_images: [],
    
    
    
    
    
    
    
    
    
    
    
    is_correct: false,
    
    
    
    
    
    
    
    
    
    
    
    
    order_index: '',
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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









  <FormField
      label="AnswerText"
  >
      <Field
          name="answer_text"
          placeholder="AnswerText"
      />
  </FormField>

















































  <FormField>
      <Field
          label='AnswerImages'
          color='info'
          icon={mdiUpload}
          path={'question_answers/answer_images'}
          name='answer_images'
          id='answer_images'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></Field>
  </FormField>





















  <FormField label='IsCorrect' labelFor='is_correct'>
      <Field
          name='is_correct'
          id='is_correct'
          component={SwitchField}
      ></Field>
  </FormField>

















    <FormField
        label="OrderIndex"
    >
        <Field
            type="number"
            name="order_index"
            placeholder="OrderIndex"
        />
    </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('/question_answers/question_answers-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Question_answersNew
