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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    medication: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    patient: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    frequency_type: 'daily',
    
    
    
    
    
    
    
    time_of_day: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    days_of_week: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    effective_from: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    effective_until: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requires_confirmation: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    accounts: '',
    
    
    
}


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

    
    

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



























  <FormField label="Patient" labelFor="patient">
      <Field name="patient" id="patient" component={SelectField} options={[]} itemRef={'patients'}></Field>
  </FormField>























  <FormField label="Frequencytype" labelFor="frequency_type">
      <Field name="frequency_type" id="frequency_type" component="select">
      
        <option value="daily">daily</option>
      
        <option value="weekly">weekly</option>
      
        <option value="custom">custom</option>
      
      </Field>
  </FormField>













  <FormField
      label="Timeofday"
  >
      <Field
          name="time_of_day"
          placeholder="Timeofday"
      />
  </FormField>



























  <FormField
      label="Daysofweek"
  >
      <Field
          name="days_of_week"
          placeholder="Daysofweek"
      />
  </FormField>





































  <FormField
      label="Effectivefrom"
  >
      <Field
          type="datetime-local"
          name="effective_from"
          placeholder="Effectivefrom"
      />
  </FormField>



























  <FormField
      label="Effectiveuntil"
  >
      <Field
          type="datetime-local"
          name="effective_until"
          placeholder="Effectiveuntil"
      />
  </FormField>

































  <FormField label='Requiresconfirmation' labelFor='requires_confirmation'>
      <Field
          name='requires_confirmation'
          id='requires_confirmation'
          component={SwitchField}
      ></Field>
  </FormField>





























  <FormField label="accounts" labelFor="accounts">
      <Field name="accounts" id="accounts" component={SelectField} options={[]} itemRef={'accounts'}></Field>
  </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('/medication_schedules/medication_schedules-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Medication_schedulesNew
