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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    authorization_case: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    submission_channel: 'payer_portal',
    
    
    
    
    
    
    
    reference_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    submitted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    due_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    decision_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    decision_type: 'unknown',
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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























  <FormField label="SubmissionChannel" labelFor="submission_channel">
      <Field name="submission_channel" id="submission_channel" component="select">
      
        <option value="payer_portal">payer_portal</option>
      
        <option value="phone">phone</option>
      
        <option value="fax">fax</option>
      
        <option value="email">email</option>
      
        <option value="clearinghouse">clearinghouse</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>













  <FormField
      label="ReferenceNumber"
  >
      <Field
          name="reference_number"
          placeholder="ReferenceNumber"
      />
  </FormField>









































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="submitted">submitted</option>
      
        <option value="pending">pending</option>
      
        <option value="additional_info_requested">additional_info_requested</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="SubmittedAt"
  >
      <Field
          type="datetime-local"
          name="submitted_at"
          placeholder="SubmittedAt"
      />
  </FormField>



























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



























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































  <FormField label="DecisionType" labelFor="decision_type">
      <Field name="decision_type" id="decision_type" component="select">
      
        <option value="unknown">unknown</option>
      
        <option value="approved">approved</option>
      
        <option value="denied">denied</option>
      
        <option value="partial">partial</option>
      
        <option value="pended">pended</option>
      
      </Field>
  </FormField>















    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </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('/submissions/submissions-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default SubmissionsNew
