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

const initialValues = {
    
    
    name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    program_shift: 'day_camp',
    
    
    
    
    
    
    
    
    
    
    
    
    block_start_datetime: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    block_end_datetime: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    age_group: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    camp_session: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    block_type: 'meal',
    
    
    
    
    
    
    
    
    details: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
}


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



  <FormField
      label="BlockName"
  >
      <Field
          name="name"
          placeholder="BlockName"
      />
  </FormField>









































  <FormField label="ProgramShift" labelFor="program_shift">
      <Field name="program_shift" id="program_shift" component="select">
      
        <option value="day_camp">day_camp</option>
      
        <option value="third_shift">third_shift</option>
      
      </Field>
  </FormField>























  <FormField
      label="BlockStart"
  >
      <Field
          type="datetime-local"
          name="block_start_datetime"
          placeholder="BlockStart"
      />
  </FormField>



























  <FormField
      label="BlockEnd"
  >
      <Field
          type="datetime-local"
          name="block_end_datetime"
          placeholder="BlockEnd"
      />
  </FormField>



































  <FormField label="AgeGroup" labelFor="age_group">
      <Field name="age_group" id="age_group" component={SelectField} options={[]} itemRef={'age_groups'}></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="BlockType" labelFor="block_type">
      <Field name="block_type" id="block_type" component="select">
      
        <option value="meal">meal</option>
      
        <option value="devotion">devotion</option>
      
        <option value="academics">academics</option>
      
        <option value="arts_skills_rotation">arts_skills_rotation</option>
      
        <option value="recreation">recreation</option>
      
        <option value="bible_study">bible_study</option>
      
        <option value="leadership_lab">leadership_lab</option>
      
        <option value="quiet_time">quiet_time</option>
      
        <option value="pickup_dropoff">pickup_dropoff</option>
      
      </Field>
  </FormField>















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

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

export default Activity_blocksNew
