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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    artist_profile: '',
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    release_type: 'single',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    primary_genre: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    secondary_genre: '',
    
    
    
    
    language: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    cover_art: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    booklet_files: [],
    
    
    
    
    
    
    label_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    copyright_notice: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    production_notice: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    upc_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    upc_source: 'auto',
    
    
    
    
    
    
    
    
    
    
    
    
    release_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    original_release_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    moderation_status: 'draft',
    
    
    
    
    
    
    
    
    moderation_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    explicit_content: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    license_accepted: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    content_id_enabled: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    content_match_enabled: false,
    
    
    
    
    
    
    
    
    
    internal_catalog_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    selected_platforms: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









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









































  <FormField label="Releasetype" labelFor="release_type">
      <Field name="release_type" id="release_type" component="select">
      
        <option value="single">single</option>
      
        <option value="ep">ep</option>
      
        <option value="album">album</option>
      
        <option value="compilation">compilation</option>
      
        <option value="podcast">podcast</option>
      
      </Field>
  </FormField>































  <FormField label="Primarygenre" labelFor="primary_genre">
      <Field name="primary_genre" id="primary_genre" component={SelectField} options={[]} itemRef={'genres'}></Field>
  </FormField>



























  <FormField label="Secondarygenre" labelFor="secondary_genre">
      <Field name="secondary_genre" id="secondary_genre" component={SelectField} options={[]} itemRef={'genres'}></Field>
  </FormField>









  <FormField
      label="Language"
  >
      <Field
          name="language"
          placeholder="Language"
      />
  </FormField>

















































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




























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




  <FormField
      label="Labelname"
  >
      <Field
          name="label_name"
          placeholder="Labelname"
      />
  </FormField>



























  <FormField
      label="Copyrightnotice"
  >
      <Field
          name="copyright_notice"
          placeholder="Copyrightnotice"
      />
  </FormField>



























  <FormField
      label="Productionnotice"
  >
      <Field
          name="production_notice"
          placeholder="Productionnotice"
      />
  </FormField>



























  <FormField
      label="UPC/EANcode"
  >
      <Field
          name="upc_code"
          placeholder="UPC/EANcode"
      />
  </FormField>









































  <FormField label="UPCsource" labelFor="upc_source">
      <Field name="upc_source" id="upc_source" component="select">
      
        <option value="auto">auto</option>
      
        <option value="manual">manual</option>
      
      </Field>
  </FormField>























  <FormField
      label="Releasedate"
  >
      <Field
          type="datetime-local"
          name="release_date"
          placeholder="Releasedate"
      />
  </FormField>



























  <FormField
      label="Originalreleasedate"
  >
      <Field
          type="datetime-local"
          name="original_release_date"
          placeholder="Originalreleasedate"
      />
  </FormField>































  <FormField label="Moderationstatus" labelFor="moderation_status">
      <Field name="moderation_status" id="moderation_status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="submitted">submitted</option>
      
        <option value="in_review">in_review</option>
      
        <option value="changes_requested">changes_requested</option>
      
        <option value="approved">approved</option>
      
        <option value="published">published</option>
      
        <option value="rejected">rejected</option>
      
        <option value="takedown_requested">takedown_requested</option>
      
        <option value="takedown_completed">takedown_completed</option>
      
      </Field>
  </FormField>















    <FormField label="Moderationnotes" hasTextareaHeight>
        <Field name="moderation_notes" as="textarea" placeholder="Moderationnotes" />
    </FormField>









































  <FormField label='Explicitcontent' labelFor='explicit_content'>
      <Field
          name='explicit_content'
          id='explicit_content'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='Licenseaccepted' labelFor='license_accepted'>
      <Field
          name='license_accepted'
          id='license_accepted'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='ContentIDenabled' labelFor='content_id_enabled'>
      <Field
          name='content_id_enabled'
          id='content_id_enabled'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='Contentmatchenabled' labelFor='content_match_enabled'>
      <Field
          name='content_match_enabled'
          id='content_match_enabled'
          component={SwitchField}
      ></Field>
  </FormField>











  <FormField
      label="Internalcatalogcode"
  >
      <Field
          name="internal_catalog_code"
          placeholder="Internalcatalogcode"
      />
  </FormField>















































    <FormField label='Selectedplatforms' labelFor='selected_platforms'>
        <Field
            name='selected_platforms'
            id='selected_platforms'
            itemRef={'distribution_platforms'}
            options={[]}
            component={SelectFieldMany}>
        </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('/releases/releases-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default ReleasesNew
