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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    host: '',
    
    
    
    
    title_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    visibility: 'public',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'scheduled',
    
    
    
    
    
    
    
    
    
    
    
    
    scheduled_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    started_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ended_at: '',
    
    
    
    
    
    
    
    
    
    
    stream_key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    playback_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    replay_post: '',
    
    
    
    
    
    
    
    peak_viewers: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    total_views: '',
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/live_streams/live_streams-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="Host" labelFor="host">
      <Field name="host" id="host" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>









  <FormField
      label="Title"
  >
      <Field
          name="title_text"
          placeholder="Title"
      />
  </FormField>































      <FormField label='Description' hasTextareaHeight>
          <Field
              name='description_text'
              id='description_text'
              component={RichTextField}
          ></Field>
      </FormField>





































  <FormField label="Visibility" labelFor="visibility">
      <Field name="visibility" id="visibility" component="select">
      
        <option value="public">public</option>
      
        <option value="followers_only">followers_only</option>
      
        <option value="private">private</option>
      
      </Field>
  </FormField>



























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























  <FormField
      label="ScheduledAt"
  >
      <Field
          type="datetime-local"
          name="scheduled_at"
          placeholder="ScheduledAt"
      />
  </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>

















  <FormField
      label="StreamKey"
  >
      <Field
          name="stream_key"
          placeholder="StreamKey"
      />
  </FormField>



























  <FormField
      label="PlaybackURL"
  >
      <Field
          name="playback_url"
          placeholder="PlaybackURL"
      />
  </FormField>













































  <FormField label="ReplayPost" labelFor="replay_post">
      <Field name="replay_post" id="replay_post" component={SelectField} options={[]} itemRef={'posts'}></Field>
  </FormField>















    <FormField
        label="PeakViewers"
    >
        <Field
            type="number"
            name="peak_viewers"
            placeholder="PeakViewers"
        />
    </FormField>



























    <FormField
        label="TotalViews"
    >
        <Field
            type="number"
            name="total_views"
            placeholder="TotalViews"
        />
    </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_streams/live_streams-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Live_streamsNew
