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

const initialValues = {
    
    
    game_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    host: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    mode: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    quiz: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'lobby',
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_locked: false,
    
    
    
    
    
    
    
    
    
    
    
    
    max_players: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    question_count: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    randomize_questions: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    randomize_answers: false,
    
    
    
    
    
    
    
    
    
    
    
    
    wheel_event_every_n_questions: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    cat_interaction_every_n_questions: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    starting_speed_kmh: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    race_map: 'san_francisco_run',
    
    
    
    
    
    
    
    
    
    
    
    
    scheduled_start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    started_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ended_at: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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













































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



























  <FormField label="Mode" labelFor="mode">
      <Field name="mode" id="mode" component={SelectField} options={[]} itemRef={'game_modes'}></Field>
  </FormField>



























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























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="lobby">lobby</option>
      
        <option value="in_progress">in_progress</option>
      
        <option value="ended">ended</option>
      
        <option value="cancelled">cancelled</option>
      
      </Field>
  </FormField>





























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

















    <FormField
        label="MaxPlayers"
    >
        <Field
            type="number"
            name="max_players"
            placeholder="MaxPlayers"
        />
    </FormField>



























    <FormField
        label="QuestionCount"
    >
        <Field
            type="number"
            name="question_count"
            placeholder="QuestionCount"
        />
    </FormField>





































  <FormField label='RandomizeQuestions' labelFor='randomize_questions'>
      <Field
          name='randomize_questions'
          id='randomize_questions'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='RandomizeAnswers' labelFor='randomize_answers'>
      <Field
          name='randomize_answers'
          id='randomize_answers'
          component={SwitchField}
      ></Field>
  </FormField>

















    <FormField
        label="WheelEventEveryNQuestions"
    >
        <Field
            type="number"
            name="wheel_event_every_n_questions"
            placeholder="WheelEventEveryNQuestions"
        />
    </FormField>



























    <FormField
        label="CatInteractionEveryNQuestions"
    >
        <Field
            type="number"
            name="cat_interaction_every_n_questions"
            placeholder="CatInteractionEveryNQuestions"
        />
    </FormField>



























    <FormField
        label="StartingSpeed(km/h)"
    >
        <Field
            type="number"
            name="starting_speed_kmh"
            placeholder="StartingSpeed(km/h)"
        />
    </FormField>



































  <FormField label="RaceMap" labelFor="race_map">
      <Field name="race_map" id="race_map" component="select">
      
        <option value="san_francisco_run">san_francisco_run</option>
      
        <option value="milky_way_highway">milky_way_highway</option>
      
        <option value="ocean_drive">ocean_drive</option>
      
        <option value="theme_park_rush">theme_park_rush</option>
      
        <option value="actually_legal_highway_race">actually_legal_highway_race</option>
      
      </Field>
  </FormField>























  <FormField
      label="ScheduledStartAt"
  >
      <Field
          type="datetime-local"
          name="scheduled_start_at"
          placeholder="ScheduledStartAt"
      />
  </FormField>



























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



























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

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

export default MatchesNew
