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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    contract_folder: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    contract_participant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    contract_document: '',
    
    
    
    
    
    
    
    revision_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    action_type: 'sign',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'pending',
    
    
    
    
    
    
    
    
    
    
    
    
    action_at: '',
    
    
    
    
    
    
    
    
    
    
    signature_hash: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    signature_evidence_file: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <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="Actiontype" labelFor="action_type">
      <Field name="action_type" id="action_type" component="select">
      
        <option value="sign">sign</option>
      
        <option value="accept_change_and_resign">accept_change_and_resign</option>
      
        <option value="revoke">revoke</option>
      
        <option value="decline">decline</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="completed">completed</option>
      
        <option value="rejected">rejected</option>
      
      </Field>
  </FormField>























  <FormField
      label="Actionat"
  >
      <Field
          type="datetime-local"
          name="action_at"
          placeholder="Actionat"
      />
  </FormField>

















  <FormField
      label="Signaturehash"
  >
      <Field
          name="signature_hash"
          placeholder="Signaturehash"
      />
  </FormField>


















































  <FormField>
      <Field
          label='Signatureevidencefile'
          color='info'
          icon={mdiUpload}
          path={'signing_actions/signature_evidence_file'}
          name='signature_evidence_file'
          id='signature_evidence_file'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></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('/signing_actions/signing_actions-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Signing_actionsNew
