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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    test_category: 'comminution',
    
    
    
    
    
    
    
    test_type: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    display_name_en: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    display_name_fr: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    parameters_schema_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    results_schema_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    calculation_rules_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_active: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/test_type_schemas/test_type_schemas-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="TestCategory" labelFor="test_category">
      <Field name="test_category" id="test_category" component="select">
      
        <option value="comminution">comminution</option>
      
        <option value="gravity">gravity</option>
      
        <option value="flotation">flotation</option>
      
        <option value="leaching">leaching</option>
      
        <option value="thickening">thickening</option>
      
        <option value="filtration">filtration</option>
      
        <option value="rheology">rheology</option>
      
        <option value="environmental">environmental</option>
      
        <option value="mineralogy">mineralogy</option>
      
        <option value="assay">assay</option>
      
      </Field>
  </FormField>













  <FormField
      label="TestType"
  >
      <Field
          name="test_type"
          placeholder="TestType"
      />
  </FormField>



























  <FormField
      label="DisplayName(EN)"
  >
      <Field
          name="display_name_en"
          placeholder="DisplayName(EN)"
      />
  </FormField>



























  <FormField
      label="DisplayName(FR)"
  >
      <Field
          name="display_name_fr"
          placeholder="DisplayName(FR)"
      />
  </FormField>





























    <FormField label="ParametersSchemaJSON" hasTextareaHeight>
        <Field name="parameters_schema_json" as="textarea" placeholder="ParametersSchemaJSON" />
    </FormField>



























    <FormField label="ResultsSchemaJSON" hasTextareaHeight>
        <Field name="results_schema_json" as="textarea" placeholder="ResultsSchemaJSON" />
    </FormField>



























    <FormField label="CalculationRulesJSON" hasTextareaHeight>
        <Field name="calculation_rules_json" as="textarea" placeholder="CalculationRulesJSON" />
    </FormField>









































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

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

export default Test_type_schemasNew
