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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    patient: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    access_level: 'view',
    
    
    
    
    
    
    
    
    
    
    
    
    
    can_view_iot_location: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    can_manage_medications: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    can_manage_calendar: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    can_view_health_data: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    granted_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    revoked_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    accounts: '',
    
    
    
}


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

    
    

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



























  <FormField label="User" labelFor="user">
      <Field name="user" id="user" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>























  <FormField label="Accesslevel" labelFor="access_level">
      <Field name="access_level" id="access_level" component="select">
      
        <option value="view">view</option>
      
        <option value="edit">edit</option>
      
        <option value="clinician">clinician</option>
      
        <option value="owner">owner</option>
      
      </Field>
  </FormField>





























  <FormField label='CanviewIoTlocation' labelFor='can_view_iot_location'>
      <Field
          name='can_view_iot_location'
          id='can_view_iot_location'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='Canmanagemedications' labelFor='can_manage_medications'>
      <Field
          name='can_manage_medications'
          id='can_manage_medications'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='Canmanagecalendar' labelFor='can_manage_calendar'>
      <Field
          name='can_manage_calendar'
          id='can_manage_calendar'
          component={SwitchField}
      ></Field>
  </FormField>



























  <FormField label='Canviewhealthdata' labelFor='can_view_health_data'>
      <Field
          name='can_view_health_data'
          id='can_view_health_data'
          component={SwitchField}
      ></Field>
  </FormField>





















  <FormField
      label="Grantedat"
  >
      <Field
          type="datetime-local"
          name="granted_at"
          placeholder="Grantedat"
      />
  </FormField>



























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

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

export default Patient_access_grantsNew
