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

const initialValues = {
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    host: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    space: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tags: [],
    
    
    
    
    
    
    
    
    
    
    
    
    event_type: 'free_webinar',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    meeting_provider: 'jitsi',
    
    
    
    
    
    
    
    meeting_link: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    recording_link: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    end_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    capacity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    price_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


const Live_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('/live_events/live_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,
                    start_at: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    end_at: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>



  <FormField
      label="EventTitle"
  >
      <Field
          name="title"
          placeholder="EventTitle"
      />
  </FormField>





























    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </FormField>











































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



























  <FormField label="Space" labelFor="space">
      <Field name="space" id="space" component={SelectField} options={[]} itemRef={'spaces'}></Field>
  </FormField>





























    <FormField label='Tags' labelFor='tags'>
        <Field
            name='tags'
            id='tags'
            itemRef={'tags'}
            options={[]}
            component={SelectFieldMany}>
        </Field>
    </FormField>





















  <FormField label="EventType" labelFor="event_type">
      <Field name="event_type" id="event_type" component="select">
      
        <option value="free_webinar">free_webinar</option>
      
        <option value="paid_masterclass">paid_masterclass</option>
      
        <option value="group_study_session">group_study_session</option>
      
        <option value="qa_session">qa_session</option>
      
      </Field>
  </FormField>



























  <FormField label="MeetingProvider" labelFor="meeting_provider">
      <Field name="meeting_provider" id="meeting_provider" component="select">
      
        <option value="jitsi">jitsi</option>
      
        <option value="zoom">zoom</option>
      
        <option value="google_meet">google_meet</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>













  <FormField
      label="MeetingLink"
  >
      <Field
          name="meeting_link"
          placeholder="MeetingLink"
      />
  </FormField>



























  <FormField
      label="RecordingLink"
  >
      <Field
          name="recording_link"
          placeholder="RecordingLink"
      />
  </FormField>





































  <FormField
      label="StartAt"
  >
      <Field
          type="datetime-local"
          name="start_at"
          placeholder="StartAt"
      />
  </FormField>



























  <FormField
      label="EndAt"
  >
      <Field
          type="datetime-local"
          name="end_at"
          placeholder="EndAt"
      />
  </FormField>























    <FormField
        label="Capacity"
    >
        <Field
            type="number"
            name="capacity"
            placeholder="Capacity"
        />
    </FormField>



























    <FormField
        label="PriceAmount"
    >
        <Field
            type="number"
            name="price_amount"
            placeholder="PriceAmount"
        />
    </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('/live_events/live_events-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Live_eventsNew
