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

const initialValues = {
    
    
    
    
    
    round_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    round_mode: 'beatmap',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    state: 'pending',
    
    
    
    
    
    
    
    
    
    
    time_limit_ms: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    presented_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    answered_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    player_choice: 'a',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    correct_choice: 'a',
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_correct: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    lose_reason: 'wrong',
    
    
    
    
    
    
    
    
    
    
    value_a: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    value_b: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    session: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    option_a_beatmap: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    option_b_beatmap: '',
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/game_rounds/game_rounds-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="RoundNumber"
    >
        <Field
            type="number"
            name="round_number"
            placeholder="RoundNumber"
        />
    </FormField>



































  <FormField label="RoundMode" labelFor="round_mode">
      <Field name="round_mode" id="round_mode" component="select">
      
        <option value="beatmap">beatmap</option>
      
        <option value="mapper">mapper</option>
      
        <option value="artist">artist</option>
      
      </Field>
  </FormField>



























  <FormField label="State" labelFor="state">
      <Field name="state" id="state" component="select">
      
        <option value="pending">pending</option>
      
        <option value="answered">answered</option>
      
        <option value="timed_out">timed_out</option>
      
        <option value="resolved">resolved</option>
      
      </Field>
  </FormField>



















    <FormField
        label="TimeLimitMs"
    >
        <Field
            type="number"
            name="time_limit_ms"
            placeholder="TimeLimitMs"
        />
    </FormField>































  <FormField
      label="PresentedAt"
  >
      <Field
          type="datetime-local"
          name="presented_at"
          placeholder="PresentedAt"
      />
  </FormField>



























  <FormField
      label="AnsweredAt"
  >
      <Field
          type="datetime-local"
          name="answered_at"
          placeholder="AnsweredAt"
      />
  </FormField>































  <FormField label="PlayerChoice" labelFor="player_choice">
      <Field name="player_choice" id="player_choice" component="select">
      
        <option value="a">a</option>
      
        <option value="b">b</option>
      
        <option value="none">none</option>
      
      </Field>
  </FormField>



























  <FormField label="CorrectChoice" labelFor="correct_choice">
      <Field name="correct_choice" id="correct_choice" component="select">
      
        <option value="a">a</option>
      
        <option value="b">b</option>
      
      </Field>
  </FormField>





























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

























  <FormField label="LoseReason" labelFor="lose_reason">
      <Field name="lose_reason" id="lose_reason" component="select">
      
        <option value="wrong">wrong</option>
      
        <option value="timeout">timeout</option>
      
        <option value="none">none</option>
      
      </Field>
  </FormField>



















    <FormField
        label="ValueA"
    >
        <Field
            type="number"
            name="value_a"
            placeholder="ValueA"
        />
    </FormField>



























    <FormField
        label="ValueB"
    >
        <Field
            type="number"
            name="value_b"
            placeholder="ValueB"
        />
    </FormField>







































  <FormField label="Session" labelFor="session">
      <Field name="session" id="session" component={SelectField} options={[]} itemRef={'game_sessions'}></Field>
  </FormField>



























  <FormField label="OptionABeatmap" labelFor="option_a_beatmap">
      <Field name="option_a_beatmap" id="option_a_beatmap" component={SelectField} options={[]} itemRef={'beatmaps'}></Field>
  </FormField>



























  <FormField label="OptionBBeatmap" labelFor="option_b_beatmap">
      <Field name="option_b_beatmap" id="option_b_beatmap" component={SelectField} options={[]} itemRef={'beatmaps'}></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('/game_rounds/game_rounds-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Game_roundsNew
