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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    asset_class: 'stock',
    
    
    
    
    
    
    
    sector: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    market_cap_min: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    market_cap_max: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    pe_min: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    pe_max: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    price_min: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    price_max: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    volume_min: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    performance_52w_min: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    performance_52w_max: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_pinned: false,
    
    
    
    
    
    
    
    
}


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

    
    

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









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









































  <FormField label="AssetClass" labelFor="asset_class">
      <Field name="asset_class" id="asset_class" component="select">
      
        <option value="stock">stock</option>
      
        <option value="etf">etf</option>
      
        <option value="crypto">crypto</option>
      
        <option value="forex">forex</option>
      
      </Field>
  </FormField>













  <FormField
      label="Sector"
  >
      <Field
          name="sector"
          placeholder="Sector"
      />
  </FormField>

































    <FormField
        label="MarketCapMin"
    >
        <Field
            type="number"
            name="market_cap_min"
            placeholder="MarketCapMin"
        />
    </FormField>



























    <FormField
        label="MarketCapMax"
    >
        <Field
            type="number"
            name="market_cap_max"
            placeholder="MarketCapMax"
        />
    </FormField>



























    <FormField
        label="P/EMin"
    >
        <Field
            type="number"
            name="pe_min"
            placeholder="P/EMin"
        />
    </FormField>



























    <FormField
        label="P/EMax"
    >
        <Field
            type="number"
            name="pe_max"
            placeholder="P/EMax"
        />
    </FormField>



























    <FormField
        label="PriceMin"
    >
        <Field
            type="number"
            name="price_min"
            placeholder="PriceMin"
        />
    </FormField>



























    <FormField
        label="PriceMax"
    >
        <Field
            type="number"
            name="price_max"
            placeholder="PriceMax"
        />
    </FormField>



























    <FormField
        label="VolumeMin"
    >
        <Field
            type="number"
            name="volume_min"
            placeholder="VolumeMin"
        />
    </FormField>



























    <FormField
        label="52-WeekPerformanceMin"
    >
        <Field
            type="number"
            name="performance_52w_min"
            placeholder="52-WeekPerformanceMin"
        />
    </FormField>



























    <FormField
        label="52-WeekPerformanceMax"
    >
        <Field
            type="number"
            name="performance_52w_max"
            placeholder="52-WeekPerformanceMax"
        />
    </FormField>





































  <FormField label='IsPinned' labelFor='is_pinned'>
      <Field
          name='is_pinned'
          id='is_pinned'
          component={SwitchField}
      ></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('/screener_filters/screener_filters-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Screener_filtersNew
