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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    project: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    phase: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    flowsheet: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: 'USD',
    
    
    
    
    
    
    
    gold_price: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    discount_rate_pct: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    throughput_tpd: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    recovery_pct: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    mine_life_years: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    capex_total: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    opex_per_tonne: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    npv: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    irr_pct: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payback_years: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    assumptions_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    sensitivity_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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









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









































  <FormField label="Currency" labelFor="currency">
      <Field name="currency" id="currency" component="select">
      
        <option value="USD">USD</option>
      
        <option value="CAD">CAD</option>
      
        <option value="EUR">EUR</option>
      
        <option value="AUD">AUD</option>
      
        <option value="ZAR">ZAR</option>
      
        <option value="BRL">BRL</option>
      
      </Field>
  </FormField>



















    <FormField
        label="GoldPrice"
    >
        <Field
            type="number"
            name="gold_price"
            placeholder="GoldPrice"
        />
    </FormField>



























    <FormField
        label="DiscountRate(%)"
    >
        <Field
            type="number"
            name="discount_rate_pct"
            placeholder="DiscountRate(%)"
        />
    </FormField>



























    <FormField
        label="Throughput(tpd)"
    >
        <Field
            type="number"
            name="throughput_tpd"
            placeholder="Throughput(tpd)"
        />
    </FormField>



























    <FormField
        label="Recovery(%)"
    >
        <Field
            type="number"
            name="recovery_pct"
            placeholder="Recovery(%)"
        />
    </FormField>



























    <FormField
        label="MineLife(years)"
    >
        <Field
            type="number"
            name="mine_life_years"
            placeholder="MineLife(years)"
        />
    </FormField>



























    <FormField
        label="TotalCAPEX"
    >
        <Field
            type="number"
            name="capex_total"
            placeholder="TotalCAPEX"
        />
    </FormField>



























    <FormField
        label="OPEXPerTonne"
    >
        <Field
            type="number"
            name="opex_per_tonne"
            placeholder="OPEXPerTonne"
        />
    </FormField>



























    <FormField
        label="NPV"
    >
        <Field
            type="number"
            name="npv"
            placeholder="NPV"
        />
    </FormField>



























    <FormField
        label="IRR(%)"
    >
        <Field
            type="number"
            name="irr_pct"
            placeholder="IRR(%)"
        />
    </FormField>



























    <FormField
        label="Payback(years)"
    >
        <Field
            type="number"
            name="payback_years"
            placeholder="Payback(years)"
        />
    </FormField>























    <FormField label="AssumptionsJSON" hasTextareaHeight>
        <Field name="assumptions_json" as="textarea" placeholder="AssumptionsJSON" />
    </FormField>



























    <FormField label="SensitivityJSON" hasTextareaHeight>
        <Field name="sensitivity_json" as="textarea" placeholder="SensitivityJSON" />
    </FormField>







































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="in_review">in_review</option>
      
        <option value="approved">approved</option>
      
        <option value="archived">archived</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('/economic_models/economic_models-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Economic_modelsNew
