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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    room: '',
    
    
    
    
    conference_key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    conference_type: 'scheduled',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    conference_status: 'created',
    
    
    
    
    
    
    
    
    
    
    
    
    scheduled_start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    scheduled_end_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    actual_start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    actual_end_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    e2ee_enabled: false,
    
    
    
    
    
    
    
    
    
    
    
    
    participant_limit: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    region_preference: 'auto',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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





















  <FormField label="Room" labelFor="room">
      <Field name="room" id="room" component={SelectField} options={[]} itemRef={'rooms'}></Field>
  </FormField>









  <FormField
      label="ConferenceKey"
  >
      <Field
          name="conference_key"
          placeholder="ConferenceKey"
      />
  </FormField>









































  <FormField label="ConferenceType" labelFor="conference_type">
      <Field name="conference_type" id="conference_type" component="select">
      
        <option value="scheduled">scheduled</option>
      
        <option value="ad_hoc">ad_hoc</option>
      
        <option value="always_on">always_on</option>
      
      </Field>
  </FormField>



























  <FormField label="ConferenceStatus" labelFor="conference_status">
      <Field name="conference_status" id="conference_status" component="select">
      
        <option value="created">created</option>
      
        <option value="running">running</option>
      
        <option value="ended">ended</option>
      
        <option value="failed">failed</option>
      
      </Field>
  </FormField>























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



























  <FormField
      label="ScheduledEndAt"
  >
      <Field
          type="datetime-local"
          name="scheduled_end_at"
          placeholder="ScheduledEndAt"
      />
  </FormField>



























  <FormField
      label="ActualStartAt"
  >
      <Field
          type="datetime-local"
          name="actual_start_at"
          placeholder="ActualStartAt"
      />
  </FormField>



























  <FormField
      label="ActualEndAt"
  >
      <Field
          type="datetime-local"
          name="actual_end_at"
          placeholder="ActualEndAt"
      />
  </FormField>

































  <FormField label='E2EEEnabled' labelFor='e2ee_enabled'>
      <Field
          name='e2ee_enabled'
          id='e2ee_enabled'
          component={SwitchField}
      ></Field>
  </FormField>

















    <FormField
        label="ParticipantLimit"
    >
        <Field
            type="number"
            name="participant_limit"
            placeholder="ParticipantLimit"
        />
    </FormField>



































  <FormField label="RegionPreference" labelFor="region_preference">
      <Field name="region_preference" id="region_preference" component="select">
      
        <option value="auto">auto</option>
      
        <option value="us">us</option>
      
        <option value="eu">eu</option>
      
        <option value="apac">apac</option>
      
        <option value="sa">sa</option>
      
        <option value="me">me</option>
      
      </Field>
  </FormField>































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

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

export default ConferencesNew
