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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    device: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    patient: '',
    
    
    
    
    
    
    
    
    
    recorded_at: '',
    
    
    
    
    
    
    
    
    
    
    latitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    longitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    speed: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    accuracy_meters: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    battery_level: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    event_kind: 'location_update',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    accounts: '',
    
    
    
}


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

    
    

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



























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



















  <FormField
      label="Recordedat"
  >
      <Field
          type="datetime-local"
          name="recorded_at"
          placeholder="Recordedat"
      />
  </FormField>























    <FormField
        label="Latitude"
    >
        <Field
            type="number"
            name="latitude"
            placeholder="Latitude"
        />
    </FormField>



























    <FormField
        label="Longitude"
    >
        <Field
            type="number"
            name="longitude"
            placeholder="Longitude"
        />
    </FormField>



























    <FormField
        label="Speed"
    >
        <Field
            type="number"
            name="speed"
            placeholder="Speed"
        />
    </FormField>



























    <FormField
        label="Accuracymeters"
    >
        <Field
            type="number"
            name="accuracy_meters"
            placeholder="Accuracymeters"
        />
    </FormField>



























    <FormField
        label="Batterylevel"
    >
        <Field
            type="number"
            name="battery_level"
            placeholder="Batterylevel"
        />
    </FormField>



































  <FormField label="Eventkind" labelFor="event_kind">
      <Field name="event_kind" id="event_kind" component="select">
      
        <option value="location_update">location_update</option>
      
        <option value="geofence_enter">geofence_enter</option>
      
        <option value="geofence_exit">geofence_exit</option>
      
        <option value="panic">panic</option>
      
        <option value="fall_suspected">fall_suspected</option>
      
        <option value="device_offline">device_offline</option>
      
      </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('/iot_telemetry_events/iot_telemetry_events-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Iot_telemetry_eventsNew
