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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    contract_folder: '',
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    document_source: 'from_template',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    original_file: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    working_file: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    final_signed_file: [],
    
    
    
    
    
    
    content_hash: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    current_revision_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_locked: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









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









































  <FormField label="Documentsource" labelFor="document_source">
      <Field name="document_source" id="document_source" component="select">
      
        <option value="from_template">from_template</option>
      
        <option value="uploaded">uploaded</option>
      
        <option value="generated">generated</option>
      
      </Field>
  </FormField>




































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



























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



























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




  <FormField
      label="Contenthash"
  >
      <Field
          name="content_hash"
          placeholder="Contenthash"
      />
  </FormField>

































    <FormField
        label="Currentrevisionnumber"
    >
        <Field
            type="number"
            name="current_revision_number"
            placeholder="Currentrevisionnumber"
        />
    </FormField>





































  <FormField label='Islocked' labelFor='is_locked'>
      <Field
          name='is_locked'
          id='is_locked'
          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('/contract_documents/contract_documents-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Contract_documentsNew
