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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    bucket: '',
    
    
    
    
    object_key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    content_type: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    size_bytes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    etag: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sha256: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    thumbnail_image: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    preview_file: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    original_file: [],
    
    
    
    
    
    
    compression_ratio: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'uploading',
    
    
    
    
    
    
    
    
    
    
    
    
    trashed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    purge_after: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="ObjectKey"
  >
      <Field
          name="object_key"
          placeholder="ObjectKey"
      />
  </FormField>



























  <FormField
      label="ContentType"
  >
      <Field
          name="content_type"
          placeholder="ContentType"
      />
  </FormField>

































    <FormField
        label="SizeBytes"
    >
        <Field
            type="number"
            name="size_bytes"
            placeholder="SizeBytes"
        />
    </FormField>





















  <FormField
      label="ETag"
  >
      <Field
          name="etag"
          placeholder="ETag"
      />
  </FormField>



























  <FormField
      label="SHA256"
  >
      <Field
          name="sha256"
          placeholder="SHA256"
      />
  </FormField>

















































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




























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



























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










    <FormField
        label="CompressionRatio"
    >
        <Field
            type="number"
            name="compression_ratio"
            placeholder="CompressionRatio"
        />
    </FormField>



































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="uploading">uploading</option>
      
        <option value="ready">ready</option>
      
        <option value="processing">processing</option>
      
        <option value="failed">failed</option>
      
        <option value="deleted">deleted</option>
      
        <option value="trashed">trashed</option>
      
      </Field>
  </FormField>























  <FormField
      label="TrashedAt"
  >
      <Field
          type="datetime-local"
          name="trashed_at"
          placeholder="TrashedAt"
      />
  </FormField>



























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

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

export default Storage_objectsNew
