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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    project: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    ore_body: '',
    
    
    
    
    sample_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sample_type: 'drill_core',
    
    
    
    
    
    
    
    drillhole_id: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    depth_from_m: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    depth_to_m: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    collection_date: '',
    
    
    
    
    
    
    
    
    
    
    
    lithology: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    alteration: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    geomet_domain: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    photos: [],
    
    
    
    
    
    
    prep_protocol: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    qaqc_type: 'none',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="SampleCode"
  >
      <Field
          name="sample_code"
          placeholder="SampleCode"
      />
  </FormField>









































  <FormField label="SampleType" labelFor="sample_type">
      <Field name="sample_type" id="sample_type" component="select">
      
        <option value="drill_core">drill_core</option>
      
        <option value="rc_chip">rc_chip</option>
      
        <option value="composite">composite</option>
      
        <option value="bulk">bulk</option>
      
        <option value="variability">variability</option>
      
        <option value="metallurgical">metallurgical</option>
      
        <option value="environmental">environmental</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>













  <FormField
      label="DrillholeID"
  >
      <Field
          name="drillhole_id"
          placeholder="DrillholeID"
      />
  </FormField>

































    <FormField
        label="DepthFrom(m)"
    >
        <Field
            type="number"
            name="depth_from_m"
            placeholder="DepthFrom(m)"
        />
    </FormField>



























    <FormField
        label="DepthTo(m)"
    >
        <Field
            type="number"
            name="depth_to_m"
            placeholder="DepthTo(m)"
        />
    </FormField>































  <FormField
      label="CollectionDate"
  >
      <Field
          type="datetime-local"
          name="collection_date"
          placeholder="CollectionDate"
      />
  </FormField>



















    <FormField label="Lithology" hasTextareaHeight>
        <Field name="lithology" as="textarea" placeholder="Lithology" />
    </FormField>



























    <FormField label="Alteration" hasTextareaHeight>
        <Field name="alteration" as="textarea" placeholder="Alteration" />
    </FormField>

























  <FormField
      label="GeometDomain"
  >
      <Field
          name="geomet_domain"
          placeholder="GeometDomain"
      />
  </FormField>

















































  <FormField>
      <Field
          label='Photos'
          color='info'
          icon={mdiUpload}
          path={'samples/photos'}
          name='photos'
          id='photos'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></Field>
  </FormField>







    <FormField label="PrepProtocol" hasTextareaHeight>
        <Field name="prep_protocol" as="textarea" placeholder="PrepProtocol" />
    </FormField>







































  <FormField label="QAQCType" labelFor="qaqc_type">
      <Field name="qaqc_type" id="qaqc_type" component="select">
      
        <option value="none">none</option>
      
        <option value="blank">blank</option>
      
        <option value="standard">standard</option>
      
        <option value="duplicate">duplicate</option>
      
        <option value="umpire">umpire</option>
      
      </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('/samples/samples-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default SamplesNew
