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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    project: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    phase: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sample: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    laboratory: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    test_type_schema: '',
    
    
    
    
    lab_reference: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    date_submitted: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    date_completed: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    data_source: 'manual',
    
    
    
    
    
    
    
    
    parameters_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    results_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    qaqc_status: 'pending',
    
    
    
    
    
    
    
    
    
    qaqc_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    entered_by: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reviewed_by: '',
    
    
    
    
    
    
    
    
    
    reviewed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approved_by: '',
    
    
    
    
    
    
    
    
    
    approved_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_deleted: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="Phase" labelFor="phase">
      <Field name="phase" id="phase" component={SelectField} options={[]} itemRef={'project_phases'}></Field>
  </FormField>



























  <FormField label="Sample" labelFor="sample">
      <Field name="sample" id="sample" component={SelectField} options={[]} itemRef={'samples'}></Field>
  </FormField>



























  <FormField label="Laboratory" labelFor="laboratory">
      <Field name="laboratory" id="laboratory" component={SelectField} options={[]} itemRef={'laboratories'}></Field>
  </FormField>



























  <FormField label="TestTypeSchema" labelFor="test_type_schema">
      <Field name="test_type_schema" id="test_type_schema" component={SelectField} options={[]} itemRef={'test_type_schemas'}></Field>
  </FormField>









  <FormField
      label="LabReference"
  >
      <Field
          name="lab_reference"
          placeholder="LabReference"
      />
  </FormField>









































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="submitted">submitted</option>
      
        <option value="in_progress">in_progress</option>
      
        <option value="completed">completed</option>
      
        <option value="reviewed">reviewed</option>
      
        <option value="approved">approved</option>
      
        <option value="rejected">rejected</option>
      
      </Field>
  </FormField>























  <FormField
      label="DateSubmitted"
  >
      <Field
          type="datetime-local"
          name="date_submitted"
          placeholder="DateSubmitted"
      />
  </FormField>



























  <FormField
      label="DateCompleted"
  >
      <Field
          type="datetime-local"
          name="date_completed"
          placeholder="DateCompleted"
      />
  </FormField>































  <FormField label="DataSource" labelFor="data_source">
      <Field name="data_source" id="data_source" component="select">
      
        <option value="manual">manual</option>
      
        <option value="csv_import">csv_import</option>
      
        <option value="lims_import">lims_import</option>
      
        <option value="api">api</option>
      
      </Field>
  </FormField>















    <FormField label="ParametersJSON" hasTextareaHeight>
        <Field name="parameters_json" as="textarea" placeholder="ParametersJSON" />
    </FormField>



























    <FormField label="ResultsJSON" hasTextareaHeight>
        <Field name="results_json" as="textarea" placeholder="ResultsJSON" />
    </FormField>







































  <FormField label="QAQCStatus" labelFor="qaqc_status">
      <Field name="qaqc_status" id="qaqc_status" component="select">
      
        <option value="pending">pending</option>
      
        <option value="passed">passed</option>
      
        <option value="failed">failed</option>
      
        <option value="needs_review">needs_review</option>
      
      </Field>
  </FormField>

















      <FormField label='QAQCNotes' hasTextareaHeight>
          <Field
              name='qaqc_notes'
              id='qaqc_notes'
              component={RichTextField}
          ></Field>
      </FormField>









































  <FormField label="EnteredBy" labelFor="entered_by">
      <Field name="entered_by" id="entered_by" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>



























  <FormField label="ReviewedBy" labelFor="reviewed_by">
      <Field name="reviewed_by" id="reviewed_by" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>



















  <FormField
      label="ReviewedAt"
  >
      <Field
          type="datetime-local"
          name="reviewed_at"
          placeholder="ReviewedAt"
      />
  </FormField>



































  <FormField label="ApprovedBy" labelFor="approved_by">
      <Field name="approved_by" id="approved_by" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>



















  <FormField
      label="ApprovedAt"
  >
      <Field
          type="datetime-local"
          name="approved_at"
          placeholder="ApprovedAt"
      />
  </FormField>

































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

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

export default Metallurgical_testsNew
