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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    base_year: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'rascunho',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tax_model: 'simplificado',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    declaration_type: 'original',
    
    
    
    
    
    
    
    previous_receipt_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tax_calculated: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    tax_withheld: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    refund_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    payable_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    risk_score: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    risk_details_json: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    dec_file_url: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    submitted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_calculated_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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















    <FormField
        label="Ano-base"
    >
        <Field
            type="number"
            name="base_year"
            placeholder="Ano-base"
        />
    </FormField>



































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="rascunho">rascunho</option>
      
        <option value="em_preenchimento">em_preenchimento</option>
      
        <option value="aguardando_revisao">aguardando_revisao</option>
      
        <option value="concluida">concluida</option>
      
        <option value="gerada">gerada</option>
      
        <option value="enviada">enviada</option>
      
        <option value="retificada">retificada</option>
      
      </Field>
  </FormField>



























  <FormField label="Modelodetributação" labelFor="tax_model">
      <Field name="tax_model" id="tax_model" component="select">
      
        <option value="simplificado">simplificado</option>
      
        <option value="completo">completo</option>
      
      </Field>
  </FormField>



























  <FormField label="Tipodedeclaração" labelFor="declaration_type">
      <Field name="declaration_type" id="declaration_type" component="select">
      
        <option value="original">original</option>
      
        <option value="retificadora">retificadora</option>
      
      </Field>
  </FormField>













  <FormField
      label="Númerodoreciboanterior"
  >
      <Field
          name="previous_receipt_number"
          placeholder="Númerodoreciboanterior"
      />
  </FormField>

































    <FormField
        label="Impostocalculado"
    >
        <Field
            type="number"
            name="tax_calculated"
            placeholder="Impostocalculado"
        />
    </FormField>



























    <FormField
        label="IRretidonafonte"
    >
        <Field
            type="number"
            name="tax_withheld"
            placeholder="IRretidonafonte"
        />
    </FormField>



























    <FormField
        label="Saldoarestituir"
    >
        <Field
            type="number"
            name="refund_amount"
            placeholder="Saldoarestituir"
        />
    </FormField>



























    <FormField
        label="Saldoapagar"
    >
        <Field
            type="number"
            name="payable_amount"
            placeholder="Saldoapagar"
        />
    </FormField>



























    <FormField
        label="Riskscore"
    >
        <Field
            type="number"
            name="risk_score"
            placeholder="Riskscore"
        />
    </FormField>























    <FormField label="Detalhesderisco(JSON)" hasTextareaHeight>
        <Field name="risk_details_json" as="textarea" placeholder="Detalhesderisco(JSON)" />
    </FormField>

























  <FormField
      label="URLdoarquivoDEC"
  >
      <Field
          name="dec_file_url"
          placeholder="URLdoarquivoDEC"
      />
  </FormField>





































  <FormField
      label="Datadeenvio"
  >
      <Field
          type="datetime-local"
          name="submitted_at"
          placeholder="Datadeenvio"
      />
  </FormField>



























  <FormField
      label="Últimocálculo"
  >
      <Field
          type="datetime-local"
          name="last_calculated_at"
          placeholder="Últimocálculo"
      />
  </FormField>



































  <FormField label="organizations" labelFor="organizations">
      <Field name="organizations" id="organizations" component={SelectField} options={[]} itemRef={'organizations'}></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('/declarations/declarations-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default DeclarationsNew
