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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    logged_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    body_location: 'head_neck',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    pain_type: 'sharp',
    
    
    
    
    
    
    
    
    
    
    severity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    duration_type: 'constant',
    
    
    
    
    
    
    
    
    better_with: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    worse_with: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    impact_level: 'none',
    
    
    
    
    
    
    
    
    medications_taken: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    journal_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/pain_logs/pain_logs-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="LoggedAt"
  >
      <Field
          type="datetime-local"
          name="logged_at"
          placeholder="LoggedAt"
      />
  </FormField>































  <FormField label="BodyLocation" labelFor="body_location">
      <Field name="body_location" id="body_location" component="select">
      
        <option value="head_neck">head_neck</option>
      
        <option value="chest">chest</option>
      
        <option value="abdomen">abdomen</option>
      
        <option value="back">back</option>
      
        <option value="left_shoulder">left_shoulder</option>
      
        <option value="right_shoulder">right_shoulder</option>
      
        <option value="left_arm">left_arm</option>
      
        <option value="right_arm">right_arm</option>
      
        <option value="left_hip">left_hip</option>
      
        <option value="right_hip">right_hip</option>
      
        <option value="left_knee">left_knee</option>
      
        <option value="right_knee">right_knee</option>
      
        <option value="left_ankle">left_ankle</option>
      
        <option value="right_ankle">right_ankle</option>
      
        <option value="left_foot">left_foot</option>
      
        <option value="right_foot">right_foot</option>
      
        <option value="general">general</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



























  <FormField label="PainType" labelFor="pain_type">
      <Field name="pain_type" id="pain_type" component="select">
      
        <option value="sharp">sharp</option>
      
        <option value="dull">dull</option>
      
        <option value="burning">burning</option>
      
        <option value="stabbing">stabbing</option>
      
        <option value="aching">aching</option>
      
        <option value="throbbing">throbbing</option>
      
        <option value="pressure">pressure</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Severity(0-10)"
    >
        <Field
            type="number"
            name="severity"
            placeholder="Severity(0-10)"
        />
    </FormField>



































  <FormField label="DurationType" labelFor="duration_type">
      <Field name="duration_type" id="duration_type" component="select">
      
        <option value="constant">constant</option>
      
        <option value="intermittent">intermittent</option>
      
      </Field>
  </FormField>















    <FormField label="BetterWith" hasTextareaHeight>
        <Field name="better_with" as="textarea" placeholder="BetterWith" />
    </FormField>



























    <FormField label="WorseWith" hasTextareaHeight>
        <Field name="worse_with" as="textarea" placeholder="WorseWith" />
    </FormField>







































  <FormField label="ImpactonActivities" labelFor="impact_level">
      <Field name="impact_level" id="impact_level" component="select">
      
        <option value="none">none</option>
      
        <option value="mild_limitation">mild_limitation</option>
      
        <option value="significant_limitation">significant_limitation</option>
      
        <option value="unable_to_function">unable_to_function</option>
      
      </Field>
  </FormField>















    <FormField label="MedicationsTaken" hasTextareaHeight>
        <Field name="medications_taken" as="textarea" placeholder="MedicationsTaken" />
    </FormField>



























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

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

export default Pain_logsNew
