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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    topic: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    target_question_count: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    age_group: 'early',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    difficulty: 'easy',
    
    
    
    
    
    
    
    
    
    
    
    
    
    include_images: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'collecting_requirements',
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    generated_quiz: '',
    
    
    
    
    
    
    
    
    
    started_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    finished_at: '',
    
    
    
    
    
    
    
    
    
}


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

    
    
    // get from url params
    const { dateRangeStart, dateRangeEnd } = router.query
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/orbix_quiz_assistant_sessions/orbix_quiz_assistant_sessions-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    started_at: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    finished_at: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>





















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









  <FormField
      label="Topic"
  >
      <Field
          name="topic"
          placeholder="Topic"
      />
  </FormField>

































    <FormField
        label="TargetQuestionCount"
    >
        <Field
            type="number"
            name="target_question_count"
            placeholder="TargetQuestionCount"
        />
    </FormField>



































  <FormField label="AgeGroup" labelFor="age_group">
      <Field name="age_group" id="age_group" component="select">
      
        <option value="early">early</option>
      
        <option value="kids">kids</option>
      
        <option value="teens">teens</option>
      
        <option value="adult">adult</option>
      
        <option value="mixed">mixed</option>
      
      </Field>
  </FormField>



























  <FormField label="Difficulty" labelFor="difficulty">
      <Field name="difficulty" id="difficulty" component="select">
      
        <option value="easy">easy</option>
      
        <option value="medium">medium</option>
      
        <option value="hard">hard</option>
      
        <option value="mixed">mixed</option>
      
      </Field>
  </FormField>





























  <FormField label='IncludeImages' labelFor='include_images'>
      <Field
          name='include_images'
          id='include_images'
          component={SwitchField}
      ></Field>
  </FormField>

























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="collecting_requirements">collecting_requirements</option>
      
        <option value="draft_ready">draft_ready</option>
      
        <option value="exported_to_quiz">exported_to_quiz</option>
      
        <option value="cancelled">cancelled</option>
      
      </Field>
  </FormField>















    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </FormField>











































  <FormField label="GeneratedQuiz" labelFor="generated_quiz">
      <Field name="generated_quiz" id="generated_quiz" component={SelectField} options={[]} itemRef={'quizzes'}></Field>
  </FormField>



















  <FormField
      label="StartedAt"
  >
      <Field
          type="datetime-local"
          name="started_at"
          placeholder="StartedAt"
      />
  </FormField>



























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

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

export default Orbix_quiz_assistant_sessionsNew
