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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    injury_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    mechanism: 'fall',
    
    
    
    
    
    
    
    diagnosis: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    affected_structure: 'muscle',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    severity: 'mild',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    recovery_stage: 'acute',
    
    
    
    
    
    
    
    
    initial_treatment: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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



















  <FormField
      label="InjuryDate"
  >
      <Field
          type="datetime-local"
          name="injury_date"
          placeholder="InjuryDate"
      />
  </FormField>































  <FormField label="MechanismofInjury" labelFor="mechanism">
      <Field name="mechanism" id="mechanism" component="select">
      
        <option value="fall">fall</option>
      
        <option value="overuse">overuse</option>
      
        <option value="collision">collision</option>
      
        <option value="sudden_movement">sudden_movement</option>
      
        <option value="lifting">lifting</option>
      
        <option value="sport">sport</option>
      
        <option value="unknown">unknown</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>













  <FormField
      label="Diagnosis"
  >
      <Field
          name="diagnosis"
          placeholder="Diagnosis"
      />
  </FormField>









































  <FormField label="AffectedStructure" labelFor="affected_structure">
      <Field name="affected_structure" id="affected_structure" component="select">
      
        <option value="muscle">muscle</option>
      
        <option value="tendon">tendon</option>
      
        <option value="ligament">ligament</option>
      
        <option value="bone">bone</option>
      
        <option value="nerve">nerve</option>
      
        <option value="joint">joint</option>
      
        <option value="skin">skin</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



























  <FormField label="Severity" labelFor="severity">
      <Field name="severity" id="severity" component="select">
      
        <option value="mild">mild</option>
      
        <option value="moderate">moderate</option>
      
        <option value="severe">severe</option>
      
        <option value="grade_1">grade_1</option>
      
        <option value="grade_2">grade_2</option>
      
        <option value="grade_3">grade_3</option>
      
        <option value="unknown">unknown</option>
      
      </Field>
  </FormField>



























  <FormField label="RecoveryStage" labelFor="recovery_stage">
      <Field name="recovery_stage" id="recovery_stage" component="select">
      
        <option value="acute">acute</option>
      
        <option value="subacute">subacute</option>
      
        <option value="rehab">rehab</option>
      
        <option value="return_to_sport">return_to_sport</option>
      
        <option value="fully_recovered">fully_recovered</option>
      
      </Field>
  </FormField>















    <FormField label="InitialTreatment" hasTextareaHeight>
        <Field name="initial_treatment" as="textarea" placeholder="InitialTreatment" />
    </FormField>



























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

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

export default InjuriesNew
