import { NavLink } from "react-router-dom";
import { 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, reservation) {
if (reservation.guide === '') {
return (
showModal(reservation)}>Fill in
);
} else {
return (
{reservation.guide}
showModal(reservation)}>Modify
);
}
}
const { reservationStore } = useStore();
const { reservationList, reservationPage, cityList } = reservationStore;
const [isModalOpen, setIsModalOpen] = useState(false);
const [arrivalDateRange, onDateRangeChange] = useState([]);
const [referenceNo, onNumberChange] = useState('');
const [dataLoading, setDataLoading] = useState(false);
const { notification } = App.useApp();
const showModal = (reservation) => {
console.info(reservation);
reservationStore.fetchCityList(reservation.referenceId)
.catch(ex => {
notification.error({
message: `Notification`,
description: ex.message,
placement: 'top',
duration: 4,
});
})
.finally(() => {
setDataLoading(false);
});
setIsModalOpen(true);
};
const handleOk = () => {
setIsModalOpen(false);
};
const handleCancel = () => {
setIsModalOpen(false);
};
const onSearchClick = (current=1) => {
setDataLoading(true);
reservationStore.fetchReservationList(current, referenceNo, arrivalDateRange[0], arrivalDateRange[1])
.catch(ex => {
notification.error({
message: `Notification`,
description: ex.message,
placement: 'top',
duration: 4,
});
})
.finally(() => {
setDataLoading(false);
});
}
return (
<>
Guide
{}}>Search
Newest Reservations
{onNumberChange(e.target.value)}} />
Arrival Date
{ onDateRangeChange(dateRange)}}
/>
onSearchClick()} loading={dataLoading}>Search
'Reservations without the tour guide information will be highlighted in red if the arrival date is within 3 days.'}
bordered
loading={dataLoading}
pagination={{
position: ['bottomCenter'],
current: reservationPage.current,
pageSize: reservationPage.size,
total: reservationPage.total,
simple: true
}}
onChange={(pagination, filters, sorter, extra) => {onSearchClick(pagination.current);}}
columns={reservationListColumns} dataSource={toJS(reservationList)}
/>
>
);
}
export default observer(Newest);