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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    flowsheet: '',
    
    
    
    
    node_key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    node_type: 'unit_operation',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    unit_operation: 'crushing',
    
    
    
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    position_x: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    position_y: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    parameters_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    equipment_item: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    test_basis: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









  <FormField
      label="NodeKey"
  >
      <Field
          name="node_key"
          placeholder="NodeKey"
      />
  </FormField>









































  <FormField label="NodeType" labelFor="node_type">
      <Field name="node_type" id="node_type" component="select">
      
        <option value="unit_operation">unit_operation</option>
      
        <option value="source">source</option>
      
        <option value="sink">sink</option>
      
        <option value="junction">junction</option>
      
        <option value="annotation">annotation</option>
      
      </Field>
  </FormField>



























  <FormField label="UnitOperation" labelFor="unit_operation">
      <Field name="unit_operation" id="unit_operation" component="select">
      
        <option value="crushing">crushing</option>
      
        <option value="sag_mill">sag_mill</option>
      
        <option value="ball_mill">ball_mill</option>
      
        <option value="hpgr">hpgr</option>
      
        <option value="cyclone">cyclone</option>
      
        <option value="screen">screen</option>
      
        <option value="gravity_concentrator">gravity_concentrator</option>
      
        <option value="shaking_table">shaking_table</option>
      
        <option value="flotation">flotation</option>
      
        <option value="cil">cil</option>
      
        <option value="cip">cip</option>
      
        <option value="heap_leach">heap_leach</option>
      
        <option value="thickener">thickener</option>
      
        <option value="filter">filter</option>
      
        <option value="adsorption">adsorption</option>
      
        <option value="elution">elution</option>
      
        <option value="electrowinning">electrowinning</option>
      
        <option value="smelting">smelting</option>
      
        <option value="tailings">tailings</option>
      
        <option value="reagent_makeup">reagent_makeup</option>
      
        <option value="water_balance">water_balance</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>













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

































    <FormField
        label="PositionX"
    >
        <Field
            type="number"
            name="position_x"
            placeholder="PositionX"
        />
    </FormField>



























    <FormField
        label="PositionY"
    >
        <Field
            type="number"
            name="position_y"
            placeholder="PositionY"
        />
    </FormField>























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











































  <FormField label="EquipmentItem" labelFor="equipment_item">
      <Field name="equipment_item" id="equipment_item" component={SelectField} options={[]} itemRef={'equipment_items'}></Field>
  </FormField>





























    <FormField label='TestBasis' labelFor='test_basis'>
        <Field
            name='test_basis'
            id='test_basis'
            itemRef={'metallurgical_tests'}
            options={[]}
            component={SelectFieldMany}>
        </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('/flowsheet_nodes/flowsheet_nodes-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Flowsheet_nodesNew
