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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    release: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    platform: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    delivery_status: 'not_sent',
    
    
    
    
    
    
    
    
    
    
    
    
    requested_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sent_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    delivered_at: '',
    
    
    
    
    
    
    
    
    
    
    platform_release_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    external_reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    error_message: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="Platform" labelFor="platform">
      <Field name="platform" id="platform" component={SelectField} options={[]} itemRef={'distribution_platforms'}></Field>
  </FormField>























  <FormField label="Deliverystatus" labelFor="delivery_status">
      <Field name="delivery_status" id="delivery_status" component="select">
      
        <option value="not_sent">not_sent</option>
      
        <option value="queued">queued</option>
      
        <option value="sent">sent</option>
      
        <option value="processing">processing</option>
      
        <option value="delivered">delivered</option>
      
        <option value="failed">failed</option>
      
        <option value="takedown_sent">takedown_sent</option>
      
        <option value="takedown_completed">takedown_completed</option>
      
      </Field>
  </FormField>























  <FormField
      label="Requestedat"
  >
      <Field
          type="datetime-local"
          name="requested_at"
          placeholder="Requestedat"
      />
  </FormField>



























  <FormField
      label="Sentat"
  >
      <Field
          type="datetime-local"
          name="sent_at"
          placeholder="Sentat"
      />
  </FormField>



























  <FormField
      label="Deliveredat"
  >
      <Field
          type="datetime-local"
          name="delivered_at"
          placeholder="Deliveredat"
      />
  </FormField>

















  <FormField
      label="PlatformreleaseURL"
  >
      <Field
          name="platform_release_url"
          placeholder="PlatformreleaseURL"
      />
  </FormField>



























  <FormField
      label="Externalreference"
  >
      <Field
          name="external_reference"
          placeholder="Externalreference"
      />
  </FormField>





























    <FormField label="Errormessage" hasTextareaHeight>
        <Field name="error_message" as="textarea" placeholder="Errormessage" />
    </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('/release_deliveries/release_deliveries-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Release_deliveriesNew
