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

const initialValues = {
    
    
    booking_number: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    patient: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    room: '',
    
    
    
    
    
    
    
    
    
    admission_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    discharge_date: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    days: '',
    
    
    
    
    
    
    
    
    
    
    
    
    price_per_day: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    total_price: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    supervising_nurse: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    supervising_doctor: '',
    
    
    
}


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



  <FormField
      label="رقمالحجز"
  >
      <Field
          name="booking_number"
          placeholder="رقمالحجز"
      />
  </FormField>













































  <FormField label="المريض" labelFor="patient">
      <Field name="patient" id="patient" component={SelectField} options={[]} itemRef={'patients'}></Field>
  </FormField>



























  <FormField label="الغرفة" labelFor="room">
      <Field name="room" id="room" component={SelectField} options={[]} itemRef={'inpatient_rooms'}></Field>
  </FormField>



















  <FormField
      label="تاريخالدخول"
  >
      <Field
          type="datetime-local"
          name="admission_date"
          placeholder="تاريخالدخول"
      />
  </FormField>



























  <FormField
      label="تاريخالخروج"
  >
      <Field
          type="datetime-local"
          name="discharge_date"
          placeholder="تاريخالخروج"
      />
  </FormField>























    <FormField
        label="عددالأيام"
    >
        <Field
            type="number"
            name="days"
            placeholder="عددالأيام"
        />
    </FormField>



























    <FormField
        label="سعراليوم"
    >
        <Field
            type="number"
            name="price_per_day"
            placeholder="سعراليوم"
        />
    </FormField>



























    <FormField
        label="السعرالإجمالي"
    >
        <Field
            type="number"
            name="total_price"
            placeholder="السعرالإجمالي"
        />
    </FormField>







































  <FormField label="الممرضالمشرف" labelFor="supervising_nurse">
      <Field name="supervising_nurse" id="supervising_nurse" component={SelectField} options={[]} itemRef={'nursing_staff'}></Field>
  </FormField>



























  <FormField label="الطبيبالمشرف" labelFor="supervising_doctor">
      <Field name="supervising_doctor" id="supervising_doctor" component={SelectField} options={[]} itemRef={'doctors'}></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('/room_bookings/room_bookings-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Room_bookingsNew
