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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    trading_account: '',
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    description: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    goal_type: 'pnl_amount',
    
    
    
    
    
    
    
    target_value: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    current_value: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    period: 'weekly',
    
    
    
    
    
    
    
    
    
    
    
    
    start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    end_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'active',
    
    
    
    
    
    
}


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

    
    

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









  <FormField
      label="Title"
  >
      <Field
          name="title"
          placeholder="Title"
      />
  </FormField>





























    <FormField label="Description" hasTextareaHeight>
        <Field name="description" as="textarea" placeholder="Description" />
    </FormField>







































  <FormField label="GoalType" labelFor="goal_type">
      <Field name="goal_type" id="goal_type" component="select">
      
        <option value="pnl_amount">pnl_amount</option>
      
        <option value="pnl_percent">pnl_percent</option>
      
        <option value="win_rate">win_rate</option>
      
        <option value="profit_factor">profit_factor</option>
      
        <option value="max_drawdown">max_drawdown</option>
      
        <option value="consistency">consistency</option>
      
        <option value="trade_count">trade_count</option>
      
        <option value="rule_compliance">rule_compliance</option>
      
        <option value="sharpe_ratio">sharpe_ratio</option>
      
        <option value="custom">custom</option>
      
      </Field>
  </FormField>



















    <FormField
        label="TargetValue"
    >
        <Field
            type="number"
            name="target_value"
            placeholder="TargetValue"
        />
    </FormField>



























    <FormField
        label="CurrentValue"
    >
        <Field
            type="number"
            name="current_value"
            placeholder="CurrentValue"
        />
    </FormField>



































  <FormField label="Period" labelFor="period">
      <Field name="period" id="period" component="select">
      
        <option value="weekly">weekly</option>
      
        <option value="monthly">monthly</option>
      
        <option value="quarterly">quarterly</option>
      
        <option value="yearly">yearly</option>
      
        <option value="custom">custom</option>
      
      </Field>
  </FormField>























  <FormField
      label="StartAt"
  >
      <Field
          type="datetime-local"
          name="start_at"
          placeholder="StartAt"
      />
  </FormField>



























  <FormField
      label="EndAt"
  >
      <Field
          type="datetime-local"
          name="end_at"
          placeholder="EndAt"
      />
  </FormField>































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="active">active</option>
      
        <option value="achieved">achieved</option>
      
        <option value="failed">failed</option>
      
        <option value="paused">paused</option>
      
        <option value="canceled">canceled</option>
      
      </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('/goals/goals-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default GoalsNew
