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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    patient: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    device_type: 'gps_bracelet',
    
    
    
    
    
    
    
    device_label: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    serial_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'active',
    
    
    
    
    
    
    
    
    
    
    
    
    paired_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_seen_at: '',
    
    
    
    
    
    
    
    
    
    
    battery_level: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    firmware_version: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    accounts: '',
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/iot_devices/iot_devices-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="Devicetype" labelFor="device_type">
      <Field name="device_type" id="device_type" component="select">
      
        <option value="gps_bracelet">gps_bracelet</option>
      
        <option value="phone">phone</option>
      
        <option value="beacon">beacon</option>
      
        <option value="other">other</option>
      
      </Field>
  </FormField>













  <FormField
      label="Devicelabel"
  >
      <Field
          name="device_label"
          placeholder="Devicelabel"
      />
  </FormField>



























  <FormField
      label="Serialnumber"
  >
      <Field
          name="serial_number"
          placeholder="Serialnumber"
      />
  </FormField>









































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="active">active</option>
      
        <option value="inactive">inactive</option>
      
        <option value="lost">lost</option>
      
        <option value="maintenance">maintenance</option>
      
      </Field>
  </FormField>























  <FormField
      label="Pairedat"
  >
      <Field
          type="datetime-local"
          name="paired_at"
          placeholder="Pairedat"
      />
  </FormField>



























  <FormField
      label="Lastseenat"
  >
      <Field
          type="datetime-local"
          name="last_seen_at"
          placeholder="Lastseenat"
      />
  </FormField>























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





















  <FormField
      label="Firmwareversion"
  >
      <Field
          name="firmware_version"
          placeholder="Firmwareversion"
      />
  </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_devices/iot_devices-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Iot_devicesNew
