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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    provider: '',
    
    
    
    
    
    
    
    
    
    appointment_start: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    appointment_end: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    appointment_type: 'gp',
    
    
    
    
    
    
    
    
    clinic_location: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    notes_to_discuss: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    documents_to_bring: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    post_appointment_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    follow_up_instructions: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    follow_up_reminder_at: '',
    
    
    
    
    
    
    
    
    
}


const Medical_appointmentsNew = () => {
  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('/medical_appointments/medical_appointments-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    appointment_start: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    appointment_end: 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="Provider" labelFor="provider">
      <Field name="provider" id="provider" component={SelectField} options={[]} itemRef={'healthcare_providers'}></Field>
  </FormField>



















  <FormField
      label="AppointmentStart"
  >
      <Field
          type="datetime-local"
          name="appointment_start"
          placeholder="AppointmentStart"
      />
  </FormField>



























  <FormField
      label="AppointmentEnd"
  >
      <Field
          type="datetime-local"
          name="appointment_end"
          placeholder="AppointmentEnd"
      />
  </FormField>































  <FormField label="AppointmentType" labelFor="appointment_type">
      <Field name="appointment_type" id="appointment_type" component="select">
      
        <option value="gp">gp</option>
      
        <option value="specialist">specialist</option>
      
        <option value="check_up">check_up</option>
      
        <option value="test">test</option>
      
        <option value="procedure">procedure</option>
      
        <option value="therapy">therapy</option>
      
        <option value="dentist">dentist</option>
      
        <option value="optometrist">optometrist</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>















    <FormField label="ClinicLocation" hasTextareaHeight>
        <Field name="clinic_location" as="textarea" placeholder="ClinicLocation" />
    </FormField>



























    <FormField label="NotestoDiscuss" hasTextareaHeight>
        <Field name="notes_to_discuss" as="textarea" placeholder="NotestoDiscuss" />
    </FormField>



























    <FormField label="DocumentstoBring" hasTextareaHeight>
        <Field name="documents_to_bring" as="textarea" placeholder="DocumentstoBring" />
    </FormField>



























    <FormField label="PostAppointmentNotes" hasTextareaHeight>
        <Field name="post_appointment_notes" as="textarea" placeholder="PostAppointmentNotes" />
    </FormField>



























    <FormField label="FollowUpInstructions" hasTextareaHeight>
        <Field name="follow_up_instructions" as="textarea" placeholder="FollowUpInstructions" />
    </FormField>



































  <FormField
      label="FollowUpReminderAt"
  >
      <Field
          type="datetime-local"
          name="follow_up_reminder_at"
          placeholder="FollowUpReminderAt"
      />
  </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('/medical_appointments/medical_appointments-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Medical_appointmentsNew
