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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    contract_document: '',
    
    
    
    
    
    
    
    revision_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    proposed_by_participant: '',
    
    
    
    
    
    
    
    
    
    proposed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    change_summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    revision_file: [],
    
    
    
    
    
    
    content_hash: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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















    <FormField
        label="Revisionnumber"
    >
        <Field
            type="number"
            name="revision_number"
            placeholder="Revisionnumber"
        />
    </FormField>



































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="proposed">proposed</option>
      
        <option value="approved">approved</option>
      
        <option value="rejected">rejected</option>
      
        <option value="superseded">superseded</option>
      
      </Field>
  </FormField>































  <FormField label="Proposedby" labelFor="proposed_by_participant">
      <Field name="proposed_by_participant" id="proposed_by_participant" component={SelectField} options={[]} itemRef={'contract_participants'}></Field>
  </FormField>



















  <FormField
      label="Proposedat"
  >
      <Field
          type="datetime-local"
          name="proposed_at"
          placeholder="Proposedat"
      />
  </FormField>



















    <FormField label="Changesummary" hasTextareaHeight>
        <Field name="change_summary" as="textarea" placeholder="Changesummary" />
    </FormField>
















































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




  <FormField
      label="Contenthash"
  >
      <Field
          name="content_hash"
          placeholder="Contenthash"
      />
  </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('/document_revisions/document_revisions-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Document_revisionsNew
