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

const initialValues = {
    
    
    title: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    document_type: 'liability_waiver',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    document_file: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    camp_session: '',
    
    
    
    
    
    
    
    
    
    
    is_required: false,
    
    
    
    
    
    
    
    
}


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

    
    

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









































  <FormField label="DocumentType" labelFor="document_type">
      <Field name="document_type" id="document_type" component="select">
      
        <option value="liability_waiver">liability_waiver</option>
      
        <option value="media_release">media_release</option>
      
        <option value="medical_consent">medical_consent</option>
      
        <option value="behavior_agreement">behavior_agreement</option>
      
        <option value="field_trip_permission">field_trip_permission</option>
      
      </Field>
  </FormField>




































  <FormField>
      <Field
          label='DocumentFile'
          color='info'
          icon={mdiUpload}
          path={'waiver_documents/document_file'}
          name='document_file'
          id='document_file'
          schema={{
            size: undefined,
            formats: undefined,
          }}
          component={FormFilePicker}
      ></Field>
  </FormField>






















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

























  <FormField label='Required' labelFor='is_required'>
      <Field
          name='is_required'
          id='is_required'
          component={SwitchField}
      ></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('/waiver_documents/waiver_documents-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Waiver_documentsNew
