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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    lesion_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    body_location: 'head_neck',
    
    
    
    
    
    
    
    
    
    
    
    
    photo_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    photos: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    monitoring_interval: '3_months',
    
    
    
    
    
    
    
    
    
    
    
    
    next_check_due: '',
    
    
    
    
    
    
    
    
    
    
    
    abcde_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    
    // get from url params
    const { dateRangeStart, dateRangeEnd } = router.query
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/mole_lesion_logs/mole_lesion_logs-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    photo_date: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    next_check_due: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : 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="LesionName"
  >
      <Field
          name="lesion_name"
          placeholder="LesionName"
      />
  </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_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="hands_feet">hands_feet</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>























  <FormField
      label="PhotoDate"
  >
      <Field
          type="datetime-local"
          name="photo_date"
          placeholder="PhotoDate"
      />
  </FormField>







































  <FormField>
      <Field
          label='Photos'
          color='info'
          icon={mdiUpload}
          path={'mole_lesion_logs/photos'}
          name='photos'
          id='photos'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></Field>
  </FormField>



















  <FormField label="MonitoringInterval" labelFor="monitoring_interval">
      <Field name="monitoring_interval" id="monitoring_interval" component="select">
      
        <option value="3_months">3_months</option>
      
        <option value="6_months">6_months</option>
      
        <option value="12_months">12_months</option>
      
      </Field>
  </FormField>























  <FormField
      label="NextCheckDue"
  >
      <Field
          type="datetime-local"
          name="next_check_due"
          placeholder="NextCheckDue"
      />
  </FormField>



















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

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

export default Mole_lesion_logsNew
