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

const initialValues = {
    
    
    first_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    last_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    date_of_birth: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    grade_level: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    gender: 'female',
    
    
    
    
    
    
    
    
    allergies: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    medical_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    special_needs_notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    primary_guardian: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    profile_photo: [],
    
    
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/campers/campers-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="FirstName"
  >
      <Field
          name="first_name"
          placeholder="FirstName"
      />
  </FormField>



























  <FormField
      label="LastName"
  >
      <Field
          name="last_name"
          placeholder="LastName"
      />
  </FormField>





































  <FormField
      label="DateofBirth"
  >
      <Field
          type="datetime-local"
          name="date_of_birth"
          placeholder="DateofBirth"
      />
  </FormField>























    <FormField
        label="GradeLevel"
    >
        <Field
            type="number"
            name="grade_level"
            placeholder="GradeLevel"
        />
    </FormField>



































  <FormField label="Gender" labelFor="gender">
      <Field name="gender" id="gender" component="select">
      
        <option value="female">female</option>
      
        <option value="male">male</option>
      
        <option value="nonbinary">nonbinary</option>
      
        <option value="prefer_not_to_say">prefer_not_to_say</option>
      
      </Field>
  </FormField>















    <FormField label="Allergies" hasTextareaHeight>
        <Field name="allergies" as="textarea" placeholder="Allergies" />
    </FormField>



























    <FormField label="MedicalNotes" hasTextareaHeight>
        <Field name="medical_notes" as="textarea" placeholder="MedicalNotes" />
    </FormField>



























    <FormField label="SpecialNeedsNotes" hasTextareaHeight>
        <Field name="special_needs_notes" as="textarea" placeholder="SpecialNeedsNotes" />
    </FormField>











































  <FormField label="PrimaryGuardian" labelFor="primary_guardian">
      <Field name="primary_guardian" id="primary_guardian" component={SelectField} options={[]} itemRef={'guardians'}></Field>
  </FormField>































  <FormField>
      <Field
          label='ProfilePhoto'
          color='info'
          icon={mdiUpload}
          path={'campers/profile_photo'}
          name='profile_photo'
          id='profile_photo'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormImagePicker}
      ></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('/campers/campers-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default CampersNew
