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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    investor_tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    farm_tenant: '',
    
    
    
    
    investment_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    instrument_type: 'equity',
    
    
    
    
    
    
    
    amount_committed: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    amount_funded: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    committed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    funded_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    investment_status: 'proposed',
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























  <FormField label="FarmTenant" labelFor="farm_tenant">
      <Field name="farm_tenant" id="farm_tenant" component={SelectField} options={[]} itemRef={'tenants'}></Field>
  </FormField>









  <FormField
      label="InvestmentName"
  >
      <Field
          name="investment_name"
          placeholder="InvestmentName"
      />
  </FormField>









































  <FormField label="InstrumentType" labelFor="instrument_type">
      <Field name="instrument_type" id="instrument_type" component="select">
      
        <option value="equity">equity</option>
      
        <option value="debt">debt</option>
      
        <option value="revenue_share">revenue_share</option>
      
        <option value="grant">grant</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



















    <FormField
        label="AmountCommitted"
    >
        <Field
            type="number"
            name="amount_committed"
            placeholder="AmountCommitted"
        />
    </FormField>



























    <FormField
        label="AmountFunded"
    >
        <Field
            type="number"
            name="amount_funded"
            placeholder="AmountFunded"
        />
    </FormField>





















  <FormField
      label="Currency"
  >
      <Field
          name="currency"
          placeholder="Currency"
      />
  </FormField>





































  <FormField
      label="CommittedAt"
  >
      <Field
          type="datetime-local"
          name="committed_at"
          placeholder="CommittedAt"
      />
  </FormField>



























  <FormField
      label="FundedAt"
  >
      <Field
          type="datetime-local"
          name="funded_at"
          placeholder="FundedAt"
      />
  </FormField>































  <FormField label="InvestmentStatus" labelFor="investment_status">
      <Field name="investment_status" id="investment_status" component="select">
      
        <option value="proposed">proposed</option>
      
        <option value="active">active</option>
      
        <option value="completed">completed</option>
      
        <option value="canceled">canceled</option>
      
      </Field>
  </FormField>















    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </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('/investments/investments-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default InvestmentsNew
