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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    camp_session: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    field_trip: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    age_group: '',
    
    
    
    
    
    
    
    
    
    depart_datetime: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    return_datetime: '',
    
    
    
    
    
    
    
    
    
    
    price_per_student: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    capacity: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'planned',
    
    
    
    
    
    
}


const Field_trip_eventsNew = () => {
  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('/field_trip_events/field_trip_events-list')
  }
  return (
    <>
      <Head>
        <title>{getPageTitle('New Item')}</title>
      </Head>
      <SectionMain>
        <SectionTitleLineWithButton icon={mdiChartTimelineVariant} title="New Item" main>
        {''}
        </SectionTitleLineWithButton>
        <CardBox>
          <Formik
            initialValues={
                
                
                
                dateRangeStart && dateRangeEnd ?
                {
                    ...initialValues,
                    depart_datetime: moment(dateRangeStart).format('YYYY-MM-DDTHH:mm'),
                    return_datetime: moment(dateRangeEnd).format('YYYY-MM-DDTHH:mm'),
                } : initialValues
                
            }
            onSubmit={(values) => handleSubmit(values)}
          >
            <Form>





















  <FormField label="CampSession" labelFor="camp_session">
      <Field name="camp_session" id="camp_session" component={SelectField} options={[]} itemRef={'camp_sessions'}></Field>
  </FormField>



























  <FormField label="FieldTrip" labelFor="field_trip">
      <Field name="field_trip" id="field_trip" component={SelectField} options={[]} itemRef={'field_trip_catalog'}></Field>
  </FormField>



























  <FormField label="AgeGroup" labelFor="age_group">
      <Field name="age_group" id="age_group" component={SelectField} options={[]} itemRef={'age_groups'}></Field>
  </FormField>



















  <FormField
      label="DepartTime"
  >
      <Field
          type="datetime-local"
          name="depart_datetime"
          placeholder="DepartTime"
      />
  </FormField>



























  <FormField
      label="ReturnTime"
  >
      <Field
          type="datetime-local"
          name="return_datetime"
          placeholder="ReturnTime"
      />
  </FormField>























    <FormField
        label="PricePerStudent"
    >
        <Field
            type="number"
            name="price_per_student"
            placeholder="PricePerStudent"
        />
    </FormField>



























    <FormField
        label="Capacity"
    >
        <Field
            type="number"
            name="capacity"
            placeholder="Capacity"
        />
    </FormField>



































  <FormField label="EventStatus" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="planned">planned</option>
      
        <option value="open">open</option>
      
        <option value="full">full</option>
      
        <option value="cancelled">cancelled</option>
      
        <option value="completed">completed</option>
      
      </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('/field_trip_events/field_trip_events-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Field_trip_eventsNew
