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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    template: '',
    
    
    
    
    field_key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    label: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    value_type: 'text',
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_required: false,
    
    
    
    
    
    
    
    
    
    
    default_value: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sort_order: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    help_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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









  <FormField
      label="FieldKey"
  >
      <Field
          name="field_key"
          placeholder="FieldKey"
      />
  </FormField>



























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









































  <FormField label="ValueType" labelFor="value_type">
      <Field name="value_type" id="value_type" component="select">
      
        <option value="text">text</option>
      
        <option value="number">number</option>
      
        <option value="date">date</option>
      
        <option value="boolean">boolean</option>
      
        <option value="party">party</option>
      
        <option value="citation">citation</option>
      
        <option value="custom">custom</option>
      
      </Field>
  </FormField>





























  <FormField label='IsRequired' labelFor='is_required'>
      <Field
          name='is_required'
          id='is_required'
          component={SwitchField}
      ></Field>
  </FormField>













    <FormField label="DefaultValue" hasTextareaHeight>
        <Field name="default_value" as="textarea" placeholder="DefaultValue" />
    </FormField>































    <FormField
        label="SortOrder"
    >
        <Field
            type="number"
            name="sort_order"
            placeholder="SortOrder"
        />
    </FormField>























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

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

export default Template_fieldsNew
