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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    document_type: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    data_type: 'string',
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_required_minimum: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_desired: false,
    
    
    
    
    
    
    
    
    
    
    help_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="Variablename"
  >
      <Field
          name="name"
          placeholder="Variablename"
      />
  </FormField>



























  <FormField
      label="Key"
  >
      <Field
          name="key"
          placeholder="Key"
      />
  </FormField>









































  <FormField label="Datatype" labelFor="data_type">
      <Field name="data_type" id="data_type" component="select">
      
        <option value="string">string</option>
      
        <option value="number">number</option>
      
        <option value="date">date</option>
      
        <option value="datetime">datetime</option>
      
        <option value="boolean">boolean</option>
      
        <option value="currency">currency</option>
      
        <option value="person">person</option>
      
        <option value="address">address</option>
      
      </Field>
  </FormField>





























  <FormField label='Isrequired(minimum)' labelFor='is_required_minimum'>
      <Field
          name='is_required_minimum'
          id='is_required_minimum'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='Isdesired' labelFor='is_desired'>
      <Field
          name='is_desired'
          id='is_desired'
          component={SwitchField}
      ></Field>
  </FormField>













    <FormField label="Helptext" hasTextareaHeight>
        <Field name="help_text" as="textarea" placeholder="Helptext" />
    </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_template_variables/document_template_variables-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Document_template_variablesNew
