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: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    created_by_admin: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    lead_city_doctor: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    lead_rural_doctor: '',
    
    
    
    
    
    
    
    
    
    start_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    end_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'planned',
    
    
    
    
    
    
    
    location_name: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    address: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    latitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    longitude: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    expected_attendees: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    actual_attendees: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    services_offered: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    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="CreatedByAdmin" labelFor="created_by_admin">
      <Field name="created_by_admin" id="created_by_admin" component={SelectField} options={[]} itemRef={'admins'}></Field>
  </FormField>



























  <FormField label="LeadCityDoctor" labelFor="lead_city_doctor">
      <Field name="lead_city_doctor" id="lead_city_doctor" component={SelectField} options={[]} itemRef={'city_doctors'}></Field>
  </FormField>



























  <FormField label="LeadRuralDoctor" labelFor="lead_rural_doctor">
      <Field name="lead_rural_doctor" id="lead_rural_doctor" component={SelectField} options={[]} itemRef={'rural_doctors'}></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="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="planned">planned</option>
      
        <option value="scheduled">scheduled</option>
      
        <option value="active">active</option>
      
        <option value="completed">completed</option>
      
        <option value="cancelled">cancelled</option>
      
      </Field>
  </FormField>













  <FormField
      label="LocationName"
  >
      <Field
          name="location_name"
          placeholder="LocationName"
      />
  </FormField>



























  <FormField
      label="Address"
  >
      <Field
          name="address"
          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="ExpectedAttendees"
    >
        <Field
            type="number"
            name="expected_attendees"
            placeholder="ExpectedAttendees"
        />
    </FormField>



























    <FormField
        label="ActualAttendees"
    >
        <Field
            type="number"
            name="actual_attendees"
            placeholder="ActualAttendees"
        />
    </FormField>























    <FormField label="ServicesOffered" hasTextareaHeight>
        <Field name="services_offered" as="textarea" placeholder="ServicesOffered" />
    </FormField>



























    <FormField label="Notes" hasTextareaHeight>
        <Field name="notes" as="textarea" placeholder="Notes" />
    </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
