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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    creator: '',
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    visibility: 'public',
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_adult: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    thumbnail_images: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    video_files: [],
    
    
    
    
    
    
    
    
    
    
    
    published_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    duration_seconds: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    view_count: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    like_count: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    comment_count: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









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































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





































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





























  <FormField label='IsAdult' labelFor='is_adult'>
      <Field
          name='is_adult'
          id='is_adult'
          component={SwitchField}
      ></Field>
  </FormField>

































  <FormField>
      <Field
          label='ThumbnailImages'
          color='info'
          icon={mdiUpload}
          path={'videos/thumbnail_images'}
          name='thumbnail_images'
          id='thumbnail_images'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></Field>
  </FormField>




























  <FormField>
      <Field
          label='VideoFiles'
          color='info'
          icon={mdiUpload}
          path={'videos/video_files'}
          name='video_files'
          id='video_files'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>














  <FormField
      label="PublishedAt"
  >
      <Field
          type="datetime-local"
          name="published_at"
          placeholder="PublishedAt"
      />
  </FormField>























    <FormField
        label="DurationSeconds"
    >
        <Field
            type="number"
            name="duration_seconds"
            placeholder="DurationSeconds"
        />
    </FormField>



























    <FormField
        label="ViewCount"
    >
        <Field
            type="number"
            name="view_count"
            placeholder="ViewCount"
        />
    </FormField>



























    <FormField
        label="LikeCount"
    >
        <Field
            type="number"
            name="like_count"
            placeholder="LikeCount"
        />
    </FormField>



























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

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

export default VideosNew
