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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    restaurant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    staff_user: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    work_shift: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    event_type: 'check_in',
    
    
    
    
    
    
    
    
    
    
    
    
    event_time: '',
    
    
    
    
    
    
    
    
    
    
    latitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    longitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    distance_meters: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    out_of_geofence: false,
    
    
    
    
    
    
    
    
    
    
    comment: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    

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























  <FormField label="Typed'évènement" labelFor="event_type">
      <Field name="event_type" id="event_type" component="select">
      
        <option value="check_in">check_in</option>
      
        <option value="check_out">check_out</option>
      
        <option value="absence">absence</option>
      
        <option value="retard">retard</option>
      
      </Field>
  </FormField>























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





































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













    <FormField label="Commentaire" hasTextareaHeight>
        <Field name="comment" as="textarea" placeholder="Commentaire" />
    </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('/attendance_events/attendance_events-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Attendance_eventsNew
