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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    location: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    denial: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    appeal_level: 'first_level',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    due_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    submitted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    decision_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    template: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reviewed_by_user: '',
    
    
    
    
    
    
    
    
    
    reviewed_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    appeal_summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    export_artifact_key: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



























  <FormField label="Location" labelFor="location">
      <Field name="location" id="location" component={SelectField} options={[]} itemRef={'locations'}></Field>
  </FormField>



























  <FormField label="Denial" labelFor="denial">
      <Field name="denial" id="denial" component={SelectField} options={[]} itemRef={'denials'}></Field>
  </FormField>























  <FormField label="AppealLevel" labelFor="appeal_level">
      <Field name="appeal_level" id="appeal_level" component="select">
      
        <option value="first_level">first_level</option>
      
        <option value="second_level">second_level</option>
      
        <option value="peer_to_peer">peer_to_peer</option>
      
        <option value="external_review">external_review</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="in_review">in_review</option>
      
        <option value="submitted">submitted</option>
      
        <option value="pending">pending</option>
      
        <option value="approved">approved</option>
      
        <option value="denied">denied</option>
      
        <option value="withdrawn">withdrawn</option>
      
        <option value="closed">closed</option>
      
      </Field>
  </FormField>























  <FormField
      label="DueAt"
  >
      <Field
          type="datetime-local"
          name="due_at"
          placeholder="DueAt"
      />
  </FormField>



























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



























  <FormField
      label="DecisionAt"
  >
      <Field
          type="datetime-local"
          name="decision_at"
          placeholder="DecisionAt"
      />
  </FormField>



































  <FormField label="Template" labelFor="template">
      <Field name="template" id="template" component={SelectField} options={[]} itemRef={'templates'}></Field>
  </FormField>



























  <FormField label="ReviewedByUser" labelFor="reviewed_by_user">
      <Field name="reviewed_by_user" id="reviewed_by_user" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>



















  <FormField
      label="ReviewedAt"
  >
      <Field
          type="datetime-local"
          name="reviewed_at"
          placeholder="ReviewedAt"
      />
  </FormField>





















      <FormField label='AppealSummary' hasTextareaHeight>
          <Field
              name='appeal_summary'
              id='appeal_summary'
              component={RichTextField}
          ></Field>
      </FormField>























  <FormField
      label="ExportArtifactKey"
  >
      <Field
          name="export_artifact_key"
          placeholder="ExportArtifactKey"
      />
  </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('/appeals/appeals-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default AppealsNew
