import { mdiChartTimelineVariant } from '@mdi/js' import Head from 'next/head' import React, { ReactElement } from 'react' import { Field, Form, Formik } from 'formik' import { useRouter } from 'next/router' import BaseButton from '../../components/BaseButton' import BaseButtons from '../../components/BaseButtons' import BaseDivider from '../../components/BaseDivider' import CardBox from '../../components/CardBox' import FormField from '../../components/FormField' import SectionMain from '../../components/SectionMain' import SectionTitleLineWithButton from '../../components/SectionTitleLineWithButton' import { SelectField } from '../../components/SelectField' import { getPageTitle } from '../../config' import LayoutAuthenticated from '../../layouts/Authenticated' import { create } from '../../stores/booking_requests/booking_requestsSlice' import { useAppDispatch, useAppSelector } from '../../stores/hooks' const initialValues = { tenant: '', organization: '', requested_by: '', request_code: '', status: 'submitted', 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: 'USD', } const Booking_requestsNew = () => { const dispatch = useAppDispatch() const router = useRouter() const { currentUser } = useAppSelector((state) => state.auth) const canManageInternalFields = Boolean(currentUser?.app_role?.globalAccess) const pageTitle = canManageInternalFields ? 'New Booking Request' : 'Request a Stay' const introCopy = canManageInternalFields ? 'Create a booking request and optionally manage internal routing fields directly.' : 'Tell us when you need accommodation and what kind of stay you need. Your organization, requester, and reference code will be attached automatically.' const handleSubmit = async (values) => { const payload = { ...values, ...(canManageInternalFields ? {} : { status: 'submitted' }), } if (!canManageInternalFields) { delete payload.tenant delete payload.organization delete payload.requested_by delete payload.request_code } await dispatch(create(payload)) await router.push('/booking_requests/booking_requests-list') } return ( <> {getPageTitle(pageTitle)} {''}
{introCopy}
{canManageInternalFields && ( <> )}
router.push('/booking_requests/booking_requests-list')} />
) } Booking_requestsNew.getLayout = function getLayout(page: ReactElement) { return ( {page} ) } export default Booking_requestsNew