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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    workspace: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    uploaded_user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    project: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    song: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    asset_type: 'audio',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    audio_role: 'vocal_raw',
    
    
    
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    file_blobs: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    image_blobs: [],
    
    
    
    
    
    duration_seconds: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sample_rate_hz: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    bit_depth: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_stereo: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="UploadedBy" labelFor="uploaded_user">
      <Field name="uploaded_user" id="uploaded_user" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>



























  <FormField label="Project" labelFor="project">
      <Field name="project" id="project" component={SelectField} options={[]} itemRef={'projects'}></Field>
  </FormField>



























  <FormField label="Song" labelFor="song">
      <Field name="song" id="song" component={SelectField} options={[]} itemRef={'songs'}></Field>
  </FormField>























  <FormField label="AssetType" labelFor="asset_type">
      <Field name="asset_type" id="asset_type" component="select">
      
        <option value="audio">audio</option>
      
        <option value="midi">midi</option>
      
        <option value="image">image</option>
      
        <option value="document">document</option>
      
        <option value="preset">preset</option>
      
      </Field>
  </FormField>



























  <FormField label="AudioRole" labelFor="audio_role">
      <Field name="audio_role" id="audio_role" component="select">
      
        <option value="vocal_raw">vocal_raw</option>
      
        <option value="vocal_processed">vocal_processed</option>
      
        <option value="instrumental">instrumental</option>
      
        <option value="drums">drums</option>
      
        <option value="bass">bass</option>
      
        <option value="instruments">instruments</option>
      
        <option value="mix">mix</option>
      
        <option value="master">master</option>
      
        <option value="stem">stem</option>
      
        <option value="reference">reference</option>
      
      </Field>
  </FormField>













  <FormField
      label="AssetName"
  >
      <Field
          name="name"
          placeholder="AssetName"
      />
  </FormField>


















































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


























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











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



























    <FormField
        label="SampleRateHz"
    >
        <Field
            type="number"
            name="sample_rate_hz"
            placeholder="SampleRateHz"
        />
    </FormField>



























    <FormField
        label="BitDepth"
    >
        <Field
            type="number"
            name="bit_depth"
            placeholder="BitDepth"
        />
    </FormField>





































  <FormField label='IsStereo' labelFor='is_stereo'>
      <Field
          name='is_stereo'
          id='is_stereo'
          component={SwitchField}
      ></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('/assets/assets-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default AssetsNew
