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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    match: '',
    
    
    
    
    
    
    
    trigger_question_index: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reward_type: 'bonus_points',
    
    
    
    
    
    
    
    multiplier_value: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bonus_points: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bonus_yux: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    music_track: 'track_a',
    
    
    
    
    
    
    
    
    
    
    
    
    event_started_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    event_ended_at: '',
    
    
    
    
    
    
    
    
    
}


const Wheel_eventsNew = () => {
  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('/wheel_events/wheel_events-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    event_started_at: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    event_ended_at: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>





















  <FormField label="Match" labelFor="match">
      <Field name="match" id="match" component={SelectField} options={[]} itemRef={'matches'}></Field>
  </FormField>















    <FormField
        label="TriggerQuestionIndex"
    >
        <Field
            type="number"
            name="trigger_question_index"
            placeholder="TriggerQuestionIndex"
        />
    </FormField>



































  <FormField label="RewardType" labelFor="reward_type">
      <Field name="reward_type" id="reward_type" component="select">
      
        <option value="bonus_points">bonus_points</option>
      
        <option value="double_points">double_points</option>
      
        <option value="triple_points">triple_points</option>
      
        <option value="bonus_yux">bonus_yux</option>
      
        <option value="mystery_prize">mystery_prize</option>
      
        <option value="lucky_multiplier">lucky_multiplier</option>
      
        <option value="jackpot">jackpot</option>
      
      </Field>
  </FormField>



















    <FormField
        label="MultiplierValue"
    >
        <Field
            type="number"
            name="multiplier_value"
            placeholder="MultiplierValue"
        />
    </FormField>



























    <FormField
        label="BonusPoints"
    >
        <Field
            type="number"
            name="bonus_points"
            placeholder="BonusPoints"
        />
    </FormField>



























    <FormField
        label="BonusYUX"
    >
        <Field
            type="number"
            name="bonus_yux"
            placeholder="BonusYUX"
        />
    </FormField>



































  <FormField label="MusicTrack" labelFor="music_track">
      <Field name="music_track" id="music_track" component="select">
      
        <option value="track_a">track_a</option>
      
        <option value="track_b">track_b</option>
      
      </Field>
  </FormField>























  <FormField
      label="EventStartedAt"
  >
      <Field
          type="datetime-local"
          name="event_started_at"
          placeholder="EventStartedAt"
      />
  </FormField>



























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

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

export default Wheel_eventsNew
