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

const initialValues = {
    
    
    
    
    
    
    
    
    
    
    
    
    
    tenant: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    reservation: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    requested_by: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    assigned_to: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    request_type: 'airport_pickup',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    status: 'new',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    priority: 'low',
    
    
    
    
    
    
    
    
    
    
    
    
    requested_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    due_at: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    completed_at: '',
    
    
    
    
    
    
    
    
    
    
    summary: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    details: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    estimated_cost: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    actual_cost: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    currency: '',
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    documents: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    comments: [],
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    organizations: '',
    
    
    
}


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

    
    

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



























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



























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























  <FormField label="Requesttype" labelFor="request_type">
      <Field name="request_type" id="request_type" component="select">
      
        <option value="airport_pickup">airport_pickup</option>
      
        <option value="housekeeping">housekeeping</option>
      
        <option value="maintenance">maintenance</option>
      
        <option value="stocked_fridge">stocked_fridge</option>
      
        <option value="chauffeur">chauffeur</option>
      
        <option value="late_checkout">late_checkout</option>
      
        <option value="extension">extension</option>
      
        <option value="custom_service">custom_service</option>
      
      </Field>
  </FormField>



























  <FormField label="Status" labelFor="status">
      <Field name="status" id="status" component="select">
      
        <option value="new">new</option>
      
        <option value="triaged">triaged</option>
      
        <option value="in_progress">in_progress</option>
      
        <option value="scheduled">scheduled</option>
      
        <option value="waiting_on_guest">waiting_on_guest</option>
      
        <option value="completed">completed</option>
      
        <option value="canceled">canceled</option>
      
      </Field>
  </FormField>



























  <FormField label="Priority" labelFor="priority">
      <Field name="priority" id="priority" component="select">
      
        <option value="low">low</option>
      
        <option value="normal">normal</option>
      
        <option value="high">high</option>
      
        <option value="urgent">urgent</option>
      
      </Field>
  </FormField>























  <FormField
      label="Requestedat"
  >
      <Field
          type="datetime-local"
          name="requested_at"
          placeholder="Requestedat"
      />
  </FormField>



























  <FormField
      label="Dueat"
  >
      <Field
          type="datetime-local"
          name="due_at"
          placeholder="Dueat"
      />
  </FormField>



























  <FormField
      label="Completedat"
  >
      <Field
          type="datetime-local"
          name="completed_at"
          placeholder="Completedat"
      />
  </FormField>

















  <FormField
      label="Summary"
  >
      <Field
          name="summary"
          placeholder="Summary"
      />
  </FormField>































      <FormField label='Details' hasTextareaHeight>
          <Field
              name='details'
              id='details'
              component={RichTextField}
          ></Field>
      </FormField>





























    <FormField
        label="Estimatedcost"
    >
        <Field
            type="number"
            name="estimated_cost"
            placeholder="Estimatedcost"
        />
    </FormField>



























    <FormField
        label="Actualcost"
    >
        <Field
            type="number"
            name="actual_cost"
            placeholder="Actualcost"
        />
    </FormField>





















  <FormField
      label="Currency"
  >
      <Field
          name="currency"
          placeholder="Currency"
      />
  </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>

























  <FormField label="organizations" labelFor="organizations">
      <Field name="organizations" id="organizations" component={SelectField} options={[]} itemRef={'organizations'}></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('/service_requests/service_requests-list')}/>
              </BaseButtons>
            </Form>
          </Formik>
        </CardBox>
      </SectionMain>
    </>
  )
}

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

export default Service_requestsNew
