import { NavLink } from "react-router-dom";
import { useEffect, useState } from 'react';
import { observer } from "mobx-react";
import { toJS } from "mobx";
import { Row, Col, Space, Button, Table, Input, Typography, DatePicker, Radio, Modal, App } from 'antd';
import { useStore } from '@/stores/StoreContext.js';
const { Title } = Typography;
function Newest() {
const reservationListColumns = [
{
title: 'Reference number',
dataIndex: 'referenceNumber',
key: 'Reference number',
render: (text, record) => {text} ,
},
{
title: 'Arrival date',
dataIndex: 'arrivalDate',
key: 'Arrival date',
},
{
title: 'Pax',
key: 'Pax',
dataIndex: 'pax'
},
{
title: 'Status',
key: 'Status',
dataIndex: 'status'
},
{
title: 'Reservation date',
key: 'Reservation date',
dataIndex: 'reservationDate'
},
{
title: 'Guide',
key: 'Guide',
dataIndex: 'guide',
render: guideRender
},
];
function guideRender(text, record) {
if (record.guide === '') {
return (
showModal()}>Fill in
);
} else {
return (
{record.guide}
showModal()}>Modify
);
}
}
const { reservationStore } = useStore();
const { reservationList } = reservationStore;
const [isModalOpen, setIsModalOpen] = useState(false);
const [selectedDateRange, onDateRangeChange] = useState([]);
const [referenceNo, onNumberChange] = useState('');
const [tableLoading, setTableLoading] = useState(false);
const { notification } = App.useApp();
const showModal = () => {
setIsModalOpen(true);
};
const handleOk = () => {
setIsModalOpen(false);
};
const handleCancel = () => {
setIsModalOpen(false);
};
const onSearchClick = () => {
setTableLoading(true);
reservationStore.fetchReservationList(referenceNo, selectedDateRange[0], selectedDateRange[1])
.catch(ex => {
notification.error({
message: `Notification`,
description: ex.message,
placement: 'top',
duration: 4,
});
})
.finally(() => {
setTableLoading(false);
});
}
return (
<>
Guide
{}}>Search
Newest Reservations
{onNumberChange(e.target.value)}} />
Arrival Date
{ onDateRangeChange(dateRange)}}
/>
onSearchClick()}>Search
'Reservations without the tour guide information will be highlighted in red if the arrival date is within 3 days.'}
bordered
loading={tableLoading}
pagination={{
position: ['bottomCenter'],
current: 1,
pageSize: 10,
total: 200
}}
columns={reservationListColumns} dataSource={toJS(reservationList)}
/>
>
);
}
export default observer(Newest);