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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    trading_account: '',
    
    
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    report_type: 'monthly',
    
    
    
    
    
    
    
    
    
    
    
    
    period_start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    period_end_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'queued',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    report_file: [],
    
    
    
    
    
    
    
    error_message: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    generated_at: '',
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/pdf_reports/pdf_reports-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="ReportType" labelFor="report_type">
      <Field name="report_type" id="report_type" component="select">
      
        <option value="monthly">monthly</option>
      
        <option value="weekly">weekly</option>
      
        <option value="custom">custom</option>
      
        <option value="strategy_comparison">strategy_comparison</option>
      
        <option value="account_comparison">account_comparison</option>
      
      </Field>
  </FormField>























  <FormField
      label="PeriodStartAt"
  >
      <Field
          type="datetime-local"
          name="period_start_at"
          placeholder="PeriodStartAt"
      />
  </FormField>



























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































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="queued">queued</option>
      
        <option value="generating">generating</option>
      
        <option value="ready">ready</option>
      
        <option value="failed">failed</option>
      
      </Field>
  </FormField>




































  <FormField>
      <Field
          label='ReportFile'
          color='info'
          icon={mdiUpload}
          path={'pdf_reports/report_file'}
          name='report_file'
          id='report_file'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>






    <FormField label="ErrorMessage" hasTextareaHeight>
        <Field name="error_message" as="textarea" placeholder="ErrorMessage" />
    </FormField>



































  <FormField
      label="GeneratedAt"
  >
      <Field
          type="datetime-local"
          name="generated_at"
          placeholder="GeneratedAt"
      />
  </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('/pdf_reports/pdf_reports-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Pdf_reportsNew
