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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    paper_account: '',
    
    
    
    
    
    
    
    
    
    snapshotted_at: '',
    
    
    
    
    
    
    
    
    
    
    total_value: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    cash_value: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    positions_value: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    day_pl: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    all_time_pl: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    day_pl_percent: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



















  <FormField
      label="SnapshottedAt"
  >
      <Field
          type="datetime-local"
          name="snapshotted_at"
          placeholder="SnapshottedAt"
      />
  </FormField>























    <FormField
        label="TotalValue"
    >
        <Field
            type="number"
            name="total_value"
            placeholder="TotalValue"
        />
    </FormField>



























    <FormField
        label="CashValue"
    >
        <Field
            type="number"
            name="cash_value"
            placeholder="CashValue"
        />
    </FormField>



























    <FormField
        label="PositionsValue"
    >
        <Field
            type="number"
            name="positions_value"
            placeholder="PositionsValue"
        />
    </FormField>



























    <FormField
        label="DayP&L"
    >
        <Field
            type="number"
            name="day_pl"
            placeholder="DayP&L"
        />
    </FormField>



























    <FormField
        label="All-timeP&L"
    >
        <Field
            type="number"
            name="all_time_pl"
            placeholder="All-timeP&L"
        />
    </FormField>



























    <FormField
        label="DayP&LPercent"
    >
        <Field
            type="number"
            name="day_pl_percent"
            placeholder="DayP&LPercent"
        />
    </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('/portfolio_snapshots/portfolio_snapshots-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Portfolio_snapshotsNew
