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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organization: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requested_by: '',
    
    
    
    
    request_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'draft',
    
    
    
    
    
    
    
    
    
    
    
    
    check_in_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    check_out_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    preferred_property: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    preferred_unit_type: '',
    
    
    
    
    
    
    
    preferred_bedrooms: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    guest_count: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    purpose_of_stay: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    special_requirements: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    budget_code: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    max_budget_amount: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    travelers: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    approval_steps: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    documents: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    comments: [],
    
    
}


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

    
    

  const handleSubmit = async (data) => {
    await dispatch(create(data))
    await router.push('/booking_requests/booking_requests-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="Tenant" labelFor="tenant">
      <Field name="tenant" id="tenant" component={SelectField} options={[]} itemRef={'tenants'}></Field>
  </FormField>



























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



























  <FormField label="Requestedby" labelFor="requested_by">
      <Field name="requested_by" id="requested_by" component={SelectField} options={[]} itemRef={'users'}></Field>
  </FormField>









  <FormField
      label="Requestcode"
  >
      <Field
          name="request_code"
          placeholder="Requestcode"
      />
  </FormField>









































  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="draft">draft</option>
      
        <option value="submitted">submitted</option>
      
        <option value="in_review">in_review</option>
      
        <option value="changes_requested">changes_requested</option>
      
        <option value="approved">approved</option>
      
        <option value="rejected">rejected</option>
      
        <option value="expired">expired</option>
      
        <option value="converted_to_reservation">converted_to_reservation</option>
      
        <option value="canceled">canceled</option>
      
      </Field>
  </FormField>























  <FormField
      label="Check-inat"
  >
      <Field
          type="datetime-local"
          name="check_in_at"
          placeholder="Check-inat"
      />
  </FormField>



























  <FormField
      label="Check-outat"
  >
      <Field
          type="datetime-local"
          name="check_out_at"
          placeholder="Check-outat"
      />
  </FormField>



































  <FormField label="Preferredproperty" labelFor="preferred_property">
      <Field name="preferred_property" id="preferred_property" component={SelectField} options={[]} itemRef={'properties'}></Field>
  </FormField>



























  <FormField label="Preferredunittype" labelFor="preferred_unit_type">
      <Field name="preferred_unit_type" id="preferred_unit_type" component={SelectField} options={[]} itemRef={'unit_types'}></Field>
  </FormField>















    <FormField
        label="Preferredbedrooms"
    >
        <Field
            type="number"
            name="preferred_bedrooms"
            placeholder="Preferredbedrooms"
        />
    </FormField>



























    <FormField
        label="Guestcount"
    >
        <Field
            type="number"
            name="guest_count"
            placeholder="Guestcount"
        />
    </FormField>























    <FormField label="Purposeofstay" hasTextareaHeight>
        <Field name="purpose_of_stay" as="textarea" placeholder="Purposeofstay" />
    </FormField>



























    <FormField label="Specialrequirements" hasTextareaHeight>
        <Field name="special_requirements" as="textarea" placeholder="Specialrequirements" />
    </FormField>

























  <FormField
      label="Budgetcode"
  >
      <Field
          name="budget_code"
          placeholder="Budgetcode"
      />
  </FormField>

































    <FormField
        label="Maxbudgetamount"
    >
        <Field
            type="number"
            name="max_budget_amount"
            placeholder="Maxbudgetamount"
        />
    </FormField>





















  <FormField
      label="Currency"
  >
      <Field
          name="currency"
          placeholder="Currency"
      />
  </FormField>















































    <FormField label='Travelers' labelFor='travelers'>
        <Field
            name='travelers'
            id='travelers'
            itemRef={'booking_request_travelers'}
            options={[]}
            component={SelectFieldMany}>
        </Field>
    </FormField>



























    <FormField label='Approvalsteps' labelFor='approval_steps'>
        <Field
            name='approval_steps'
            id='approval_steps'
            itemRef={'approval_steps'}
            options={[]}
            component={SelectFieldMany}>
        </Field>
    </FormField>



























    <FormField label='Documents' labelFor='documents'>
        <Field
            name='documents'
            id='documents'
            itemRef={'documents'}
            options={[]}
            component={SelectFieldMany}>
        </Field>
    </FormField>



























    <FormField label='Comments' labelFor='comments'>
        <Field
            name='comments'
            id='comments'
            itemRef={'activity_comments'}
            options={[]}
            component={SelectFieldMany}>
        </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('/booking_requests/booking_requests-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Booking_requestsNew
