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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    restaurant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    staff_user: '',
    
    
    
    
    distance_meters: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    latitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    longitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    alert_time: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    severity: 'info',
    
    
    
    
    
    
    
    
    
    
    
    
    
    is_acknowledged: false,
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    acknowledged_by_user: '',
    
    
    
}


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

    
    

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



























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















    <FormField
        label="Distance(mètres)"
    >
        <Field
            type="number"
            name="distance_meters"
            placeholder="Distance(mètres)"
        />
    </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="Date/heurealerte"
  >
      <Field
          type="datetime-local"
          name="alert_time"
          placeholder="Date/heurealerte"
      />
  </FormField>































  <FormField label="Sévérité" labelFor="severity">
      <Field name="severity" id="severity" component="select">
      
        <option value="info">info</option>
      
        <option value="warning">warning</option>
      
        <option value="critical">critical</option>
      
      </Field>
  </FormField>





























  <FormField label='Alerteacquittée' labelFor='is_acknowledged'>
      <Field
          name='is_acknowledged'
          id='is_acknowledged'
          component={SwitchField}
      ></Field>
  </FormField>





























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

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

export default Geofence_alertsNew
