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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'uploaded',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    content_type: 'ebook',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    file_assets: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    preview_images: [],
    
    
    
    
    
    
    rejection_reason: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    uploaded_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reviewed_at: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

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









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









































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="uploaded">uploaded</option>
      
        <option value="under_review">under_review</option>
      
        <option value="approved">approved</option>
      
        <option value="rejected">rejected</option>
      
      </Field>
  </FormField>



























  <FormField label="Contenttype" labelFor="content_type">
      <Field name="content_type" id="content_type" component="select">
      
        <option value="ebook">ebook</option>
      
        <option value="document">document</option>
      
        <option value="audio">audio</option>
      
        <option value="video">video</option>
      
      </Field>
  </FormField>




































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


























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







    <FormField label="Rejectionreason" hasTextareaHeight>
        <Field name="rejection_reason" as="textarea" placeholder="Rejectionreason" />
    </FormField>



































  <FormField
      label="Uploadedat"
  >
      <Field
          type="datetime-local"
          name="uploaded_at"
          placeholder="Uploadedat"
      />
  </FormField>



























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

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

export default User_uploadsNew
