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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    work_schedule: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    staff_user: '',
    
    
    
    
    
    
    
    
    
    shift_start: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    shift_end: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    shift_role: 'superviseur',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    shift_status: 'planifie',
    
    
    
    
    
    
    
    
    shift_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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

    
    
    // get from url params
    const { dateRangeStart, dateRangeEnd } = router.query
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/work_shifts/work_shifts-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    shift_start: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    shift_end: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>





















  <FormField label="Planning" labelFor="work_schedule">
      <Field name="work_schedule" id="work_schedule" component={SelectField} options={[]} itemRef={'work_schedules'}></Field>
  </FormField>



























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



















  <FormField
      label="Débutservice"
  >
      <Field
          type="datetime-local"
          name="shift_start"
          placeholder="Débutservice"
      />
  </FormField>



























  <FormField
      label="Finservice"
  >
      <Field
          type="datetime-local"
          name="shift_end"
          placeholder="Finservice"
      />
  </FormField>































  <FormField label="Rôledushift" labelFor="shift_role">
      <Field name="shift_role" id="shift_role" component="select">
      
        <option value="superviseur">superviseur</option>
      
        <option value="chef_cuisinier">chef_cuisinier</option>
      
        <option value="cuisinier">cuisinier</option>
      
        <option value="caissier">caissier</option>
      
        <option value="barman">barman</option>
      
        <option value="serveur">serveur</option>
      
        <option value="agent_entretien">agent_entretien</option>
      
      </Field>
  </FormField>



























  <FormField label="Statut" labelFor="shift_status">
      <Field name="shift_status" id="shift_status" component="select">
      
        <option value="planifie">planifie</option>
      
        <option value="confirme">confirme</option>
      
        <option value="annule">annule</option>
      
      </Field>
  </FormField>















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

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

export default Work_shiftsNew
