import { mdiChartTimelineVariant } from '@mdi/js' import Head from 'next/head' import { uniqueId } from 'lodash'; import React, { ReactElement, useState } 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 TableBooking_requests from '../../components/Booking_requests/TableBooking_requests' import BaseButton from '../../components/BaseButton' import BaseButtons from '../../components/BaseButtons' import axios from "axios"; import {useAppDispatch, useAppSelector} from "../../stores/hooks"; import CardBoxModal from "../../components/CardBoxModal"; import DragDropFilePicker from "../../components/DragDropFilePicker"; import {setRefetch, uploadCsv} from '../../stores/booking_requests/booking_requestsSlice'; import {hasPermission} from "../../helpers/userPermissions"; import { humanize } from "../../helpers/humanize"; const Booking_requestsTablesPage = () => { const [filterItems, setFilterItems] = useState([]); const [csvFile, setCsvFile] = useState(null); const [isModalActive, setIsModalActive] = useState(false); const { currentUser } = useAppSelector((state) => state.auth); const dispatch = useAppDispatch(); const [filters] = useState(([{label: 'Requestcode', title: 'request_code'},{label: 'Purposeofstay', title: 'purpose_of_stay'},{label: 'Specialrequirements', title: 'special_requirements'},{label: 'Budgetcode', title: 'budget_code'},{label: 'Currency', title: 'currency'}, {label: 'Preferredbedrooms', title: 'preferred_bedrooms', number: 'true'},{label: 'Guestcount', title: 'guest_count', number: 'true'}, {label: 'Maxbudgetamount', title: 'max_budget_amount', number: 'true'}, {label: 'Check-inat', title: 'check_in_at', date: 'true'},{label: 'Check-outat', title: 'check_out_at', date: 'true'}, {label: 'Tenant', title: 'tenant'}, {label: 'Requestedby', title: 'requested_by'}, {label: 'Preferredproperty', title: 'preferred_property'}, {label: 'Preferredunittype', title: 'preferred_unit_type'}, {label: 'Travelers', title: 'travelers'},{label: 'Approvalsteps', title: 'approval_steps'},{label: 'Documents', title: 'documents'},{label: 'Comments', title: 'comments'}, {label: 'Status', title: 'status', type: 'enum', options: ['draft','submitted','in_review','changes_requested','approved','rejected','expired','converted_to_reservation','canceled']}, ]).map((filter) => ({ ...filter, label: humanize(filter.title) }))); const hasCreatePermission = currentUser && hasPermission(currentUser, 'CREATE_BOOKING_REQUESTS'); const addFilter = () => { const newItem = { id: uniqueId(), fields: { filterValue: '', filterValueFrom: '', filterValueTo: '', selectedField: '', }, }; newItem.fields.selectedField = filters[0].title; setFilterItems([...filterItems, newItem]); }; const getBooking_requestsCSV = async () => { const response = await axios({url: '/booking_requests?filetype=csv', method: 'GET',responseType: 'blob'}); const type = response.headers['content-type'] const blob = new Blob([response.data], { type: type }) const link = document.createElement('a') link.href = window.URL.createObjectURL(blob) link.download = 'booking_requestsCSV.csv' link.click() }; const onModalConfirm = async () => { if (!csvFile) return; await dispatch(uploadCsv(csvFile)); dispatch(setRefetch(true)); setCsvFile(null); setIsModalActive(false); }; const onModalCancel = () => { setCsvFile(null); setIsModalActive(false); }; return ( <> {getPageTitle('Booking Requests')}

Working view

Keep demand moving

Create, filter, export, or switch to table view from one calm action strip.

{hasCreatePermission ? ( ) : null} {hasCreatePermission ? ( setIsModalActive(true)} /> ) : null}
) } Booking_requestsTablesPage.getLayout = function getLayout(page: ReactElement) { return ( {page} ) } export default Booking_requestsTablesPage