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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    market_symbol: '',
    
    
    
    
    
    
    
    
    
    period_end_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reported_at: '',
    
    
    
    
    
    
    
    
    
    
    reported_eps: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    estimated_eps: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    surprise: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    surprise_percent: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reported_revenue: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    estimated_revenue: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    
    // get from url params
    const { dateRangeStart, dateRangeEnd } = router.query
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/earnings_reports/earnings_reports-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    reported_at: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    period_end_at: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>





















  <FormField label="MarketSymbol" labelFor="market_symbol">
      <Field name="market_symbol" id="market_symbol" component={SelectField} options={[]} itemRef={'market_symbols'}></Field>
  </FormField>



















  <FormField
      label="PeriodEndAt"
  >
      <Field
          type="datetime-local"
          name="period_end_at"
          placeholder="PeriodEndAt"
      />
  </FormField>



























  <FormField
      label="ReportedAt"
  >
      <Field
          type="datetime-local"
          name="reported_at"
          placeholder="ReportedAt"
      />
  </FormField>























    <FormField
        label="ReportedEPS"
    >
        <Field
            type="number"
            name="reported_eps"
            placeholder="ReportedEPS"
        />
    </FormField>



























    <FormField
        label="EstimatedEPS"
    >
        <Field
            type="number"
            name="estimated_eps"
            placeholder="EstimatedEPS"
        />
    </FormField>



























    <FormField
        label="Surprise"
    >
        <Field
            type="number"
            name="surprise"
            placeholder="Surprise"
        />
    </FormField>



























    <FormField
        label="SurprisePercent"
    >
        <Field
            type="number"
            name="surprise_percent"
            placeholder="SurprisePercent"
        />
    </FormField>



























    <FormField
        label="ReportedRevenue"
    >
        <Field
            type="number"
            name="reported_revenue"
            placeholder="ReportedRevenue"
        />
    </FormField>



























    <FormField
        label="EstimatedRevenue"
    >
        <Field
            type="number"
            name="estimated_revenue"
            placeholder="EstimatedRevenue"
        />
    </FormField>























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

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

export default Earnings_reportsNew
