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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    location: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    authorization_case: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    submission: '',
    
    
    
    
    
    
    
    
    
    denial_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    denial_type: 'medical_necessity',
    
    
    
    
    
    
    
    
    denial_reason_text: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    denial_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    dollars_denied: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'new',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    owner_user: '',
    
    
    
}


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

    
    

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



























  <FormField label="Submission" labelFor="submission">
      <Field name="submission" id="submission" component={SelectField} options={[]} itemRef={'submissions'}></Field>
  </FormField>



















  <FormField
      label="DenialAt"
  >
      <Field
          type="datetime-local"
          name="denial_at"
          placeholder="DenialAt"
      />
  </FormField>































  <FormField label="DenialType" labelFor="denial_type">
      <Field name="denial_type" id="denial_type" component="select">
      
        <option value="medical_necessity">medical_necessity</option>
      
        <option value="administrative">administrative</option>
      
        <option value="eligibility">eligibility</option>
      
        <option value="coding">coding</option>
      
        <option value="duplicate">duplicate</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>















    <FormField label="DenialReasonText" hasTextareaHeight>
        <Field name="denial_reason_text" as="textarea" placeholder="DenialReasonText" />
    </FormField>

























  <FormField
      label="DenialCode"
  >
      <Field
          name="denial_code"
          placeholder="DenialCode"
      />
  </FormField>

































    <FormField
        label="DollarsDenied"
    >
        <Field
            type="number"
            name="dollars_denied"
            placeholder="DollarsDenied"
        />
    </FormField>



































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="new">new</option>
      
        <option value="triaged">triaged</option>
      
        <option value="appeal_needed">appeal_needed</option>
      
        <option value="appeal_in_progress">appeal_in_progress</option>
      
        <option value="overturned">overturned</option>
      
        <option value="upheld">upheld</option>
      
        <option value="closed">closed</option>
      
      </Field>
  </FormField>































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

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

export default DenialsNew
