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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    test: '',
    
    
    
    
    version_label: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    generation_strategy: 'shuffle_questions',
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_locked: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    generated_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    export_pdf: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    export_docx: [],
    
    
    
    
    
}


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

    
    

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









  <FormField
      label="VersionLabel"
  >
      <Field
          name="version_label"
          placeholder="VersionLabel"
      />
  </FormField>









































  <FormField label="GenerationStrategy" labelFor="generation_strategy">
      <Field name="generation_strategy" id="generation_strategy" component="select">
      
        <option value="shuffle_questions">shuffle_questions</option>
      
        <option value="shuffle_answers">shuffle_answers</option>
      
        <option value="both">both</option>
      
        <option value="custom">custom</option>
      
      </Field>
  </FormField>





























  <FormField label='IsLocked' labelFor='is_locked'>
      <Field
          name='is_locked'
          id='is_locked'
          component={SwitchField}
      ></Field>
  </FormField>





















  <FormField
      label="GeneratedAt"
  >
      <Field
          type="datetime-local"
          name="generated_at"
          placeholder="GeneratedAt"
      />
  </FormField>








































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



























  <FormField>
      <Field
          label='ExportDOCX'
          color='info'
          icon={mdiUpload}
          path={'test_versions/export_docx'}
          name='export_docx'
          id='export_docx'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></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('/test_versions/test_versions-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Test_versionsNew
