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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    logged_at: '',
    
    
    
    
    
    
    
    
    
    
    symptom_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    severity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    body_area: 'head_neck',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'ongoing',
    
    
    
    
    
    
    
    
    
    
    duration_minutes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    triggers: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/symptom_logs/symptom_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="SymptomName"
  >
      <Field
          name="symptom_name"
          placeholder="SymptomName"
      />
  </FormField>

































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



































  <FormField label="BodyArea" labelFor="body_area">
      <Field name="body_area" id="body_area" 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_arm">left_arm</option>
      
        <option value="right_arm">right_arm</option>
      
        <option value="left_leg">left_leg</option>
      
        <option value="right_leg">right_leg</option>
      
        <option value="pelvis_genital">pelvis_genital</option>
      
        <option value="skin">skin</option>
      
        <option value="general">general</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="ongoing">ongoing</option>
      
        <option value="resolved">resolved</option>
      
      </Field>
  </FormField>



















    <FormField
        label="Duration(minutes)"
    >
        <Field
            type="number"
            name="duration_minutes"
            placeholder="Duration(minutes)"
        />
    </FormField>























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

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

export default Symptom_logsNew
