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

const initialValues = {
    
    
    camp_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    camp_type: 'base_camp',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizer_organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    camp_lead_doctor: '',
    
    
    
    
    
    
    
    
    
    start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    end_at: '',
    
    
    
    
    
    
    
    
    
    
    location_label: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address_line: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    latitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    longitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    camp_status: 'planned',
    
    
    
    
    
    
    
    
    
    notes: '',
    
    
    
    
    
    
    
    
    
    
    
    
}


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



  <FormField
      label="CampName"
  >
      <Field
          name="camp_name"
          placeholder="CampName"
      />
  </FormField>









































  <FormField label="CampType" labelFor="camp_type">
      <Field name="camp_type" id="camp_type" component="select">
      
        <option value="base_camp">base_camp</option>
      
        <option value="outreach_camp">outreach_camp</option>
      
        <option value="vaccination_camp">vaccination_camp</option>
      
      </Field>
  </FormField>































  <FormField label="OrganizerOrganization" labelFor="organizer_organization">
      <Field name="organizer_organization" id="organizer_organization" component={SelectField} options={[]} itemRef={'organizations'}></Field>
  </FormField>



























  <FormField label="CampLeadDoctor" labelFor="camp_lead_doctor">
      <Field name="camp_lead_doctor" id="camp_lead_doctor" component={SelectField} options={[]} itemRef={'doctor_profiles'}></Field>
  </FormField>



















  <FormField
      label="StartAt"
  >
      <Field
          type="datetime-local"
          name="start_at"
          placeholder="StartAt"
      />
  </FormField>



























  <FormField
      label="EndAt"
  >
      <Field
          type="datetime-local"
          name="end_at"
          placeholder="EndAt"
      />
  </FormField>

















  <FormField
      label="LocationLabel"
  >
      <Field
          name="location_label"
          placeholder="LocationLabel"
      />
  </FormField>





























    <FormField label="Address" hasTextareaHeight>
        <Field name="address_line" as="textarea" placeholder="Address" />
    </FormField>































    <FormField
        label="Latitude"
    >
        <Field
            type="number"
            name="latitude"
            placeholder="Latitude"
        />
    </FormField>



























    <FormField
        label="Longitude"
    >
        <Field
            type="number"
            name="longitude"
            placeholder="Longitude"
        />
    </FormField>



































  <FormField label="CampStatus" labelFor="camp_status">
      <Field name="camp_status" id="camp_status" component="select">
      
        <option value="planned">planned</option>
      
        <option value="ongoing">ongoing</option>
      
        <option value="completed">completed</option>
      
        <option value="cancelled">cancelled</option>
      
      </Field>
  </FormField>

















      <FormField label='Notes' hasTextareaHeight>
          <Field
              name='notes'
              id='notes'
              component={RichTextField}
          ></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('/medical_camps/medical_camps-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Medical_campsNew
