feat: External Review 列表、搜索
parent
4778b58eeb
commit
8f3586ffb3
@ -0,0 +1,54 @@
|
||||
import { create } from 'zustand'
|
||||
import { devtools } from 'zustand/middleware'
|
||||
import { fetchJSON, postForm } from '@/utils/request'
|
||||
import { HT_HOST, TGA_HOST } from "@/config"
|
||||
import { isEmpty } from '@/utils/commons'
|
||||
import { usingStorage } from '@/hooks/usingStorage'
|
||||
|
||||
|
||||
export const fetchAllItinerary = async (reservationId) => {
|
||||
const { errcode, result } = await fetchJSON(
|
||||
`${TGA_HOST}/api/index.php/oversea/all_itinerary/`,
|
||||
{ group_id: reservationId })
|
||||
|
||||
return errcode !== 0 ? {} : result
|
||||
}
|
||||
|
||||
export const fetchTransport = async (reservationId) => {
|
||||
const { errcode, result } = await fetchJSON(
|
||||
`${TGA_HOST}/api/index.php/oversea/transport/`,
|
||||
{ group_id: reservationId })
|
||||
|
||||
return errcode !== 0 ? {} : result
|
||||
}
|
||||
|
||||
|
||||
const useExternalReviewStore = create(devtools((set, get) => ({
|
||||
|
||||
reviewList: [],
|
||||
|
||||
fetchReviewList: async (formValues) => {
|
||||
|
||||
console.info('formValues: ', formValues)
|
||||
|
||||
const { errcode, errmsg, result } = await fetchJSON(`${TGA_HOST}/api/index.php/customer_review/search/`,
|
||||
{ agent_id: formValues.agency, group_number: formValues?.referenceNo??'',
|
||||
from_date: formValues?.startdate??'', thru_date: formValues?.enddate??'',
|
||||
approval_status: formValues?.approvalStatus??''
|
||||
})
|
||||
|
||||
if (errcode !== 0) {
|
||||
return Promise.reject(new Error(errmsg + ': ' + errcode))
|
||||
} else {
|
||||
console.info('reviewList: ', result)
|
||||
set(() => ({
|
||||
reviewList: result
|
||||
}))
|
||||
|
||||
return Promise.resolve(result)
|
||||
}
|
||||
},
|
||||
|
||||
}), { name: 'externalReviewStore' }))
|
||||
|
||||
export default useExternalReviewStore
|
||||
@ -0,0 +1,148 @@
|
||||
import { NavLink } from 'react-router-dom'
|
||||
import { useState, useEffect } from 'react'
|
||||
import { Row, Col, Space, Button, Table, Typography, Modal, App } from 'antd'
|
||||
import dayjs from 'dayjs'
|
||||
import { groupBy, isEmpty } from '@/utils/commons'
|
||||
import { useTranslation } from 'react-i18next'
|
||||
import useFormStore from '@/stores/Form'
|
||||
import useExternalReviewStore from '@/stores/ExternalReview'
|
||||
import SearchForm from '@/components/SearchForm'
|
||||
|
||||
const { Title } = Typography
|
||||
|
||||
function ReviewList() {
|
||||
const { t } = useTranslation()
|
||||
const reviewListColumns = [
|
||||
{
|
||||
title: t('review.ReviewLink'),
|
||||
dataIndex: 'reviewLink',
|
||||
width: '300px', ellipsis: true,
|
||||
render: (_, record) => (
|
||||
<Typography.Link href={record.reviewLink} target="_blank">
|
||||
{record.reviewLink}
|
||||
</Typography.Link>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: t('review.DatePosted'),
|
||||
dataIndex: 'datePosted',
|
||||
width: '120px', ellipsis: true,
|
||||
render: (text) => (isEmpty(text) ? '' : dayjs(text).format('YYYY-MM-DD')),
|
||||
},
|
||||
{
|
||||
title: t('review.ReferenceNumber'),
|
||||
dataIndex: 'referenceNumber',
|
||||
width: '300px', ellipsis: true,
|
||||
},
|
||||
{
|
||||
title: t('review.AdminNotes'),
|
||||
dataIndex: 'adminNotes',
|
||||
},
|
||||
{
|
||||
title: t('review.CustomerID'),
|
||||
dataIndex: 'customerId',
|
||||
},
|
||||
{
|
||||
title: t('review.Guide'),
|
||||
dataIndex: 'guide',
|
||||
},
|
||||
{
|
||||
title: t('review.Bonus'),
|
||||
dataIndex: 'bonus',
|
||||
width: '120px', ellipsis: true, align: 'right',
|
||||
},
|
||||
{
|
||||
title: t('review.ApprovalStatus'),
|
||||
dataIndex: 'approvalStatus',
|
||||
width: '150px', ellipsis: true, align: 'center',
|
||||
render: (text) => {
|
||||
if (text === 136002) return 'Approved'
|
||||
else if (text === 136003) return 'Rejected'
|
||||
else if (text === 136001) return 'Pending Review'
|
||||
else return '-'
|
||||
},
|
||||
},
|
||||
{
|
||||
title: t('review.ApprovalDate'),
|
||||
dataIndex: 'approvalDate',
|
||||
width: '150px', ellipsis: true,
|
||||
render: (text) => (isEmpty(text) ? '' : dayjs(text).format('YYYY-MM-DD HH:mm')),
|
||||
},
|
||||
{
|
||||
title: t('review.Action'),
|
||||
width: '120px', ellipsis: true,
|
||||
render: () => {
|
||||
return (
|
||||
<Button type="link">Edit</Button>
|
||||
)
|
||||
},
|
||||
},
|
||||
];
|
||||
|
||||
const [isModalOpen, setIsModalOpen] = useState(false)
|
||||
const [dataLoading, setDataLoading] = useState(false)
|
||||
|
||||
const formValuesToSub = useFormStore((state) => state.formValuesToSub)
|
||||
const [fetchReviewList, reviewList] = useExternalReviewStore(s => [s.fetchReviewList, s.reviewList])
|
||||
|
||||
const { notification } = App.useApp()
|
||||
|
||||
const handleOk = () => {
|
||||
}
|
||||
|
||||
const handleCancel = () => {
|
||||
}
|
||||
const searchReview = (submitValues, current=1) => {
|
||||
setDataLoading(true)
|
||||
fetchReviewList(submitValues, current)
|
||||
.catch(ex => {
|
||||
notification.error({
|
||||
message: `Notification`,
|
||||
description: ex.message,
|
||||
placement: 'top',
|
||||
duration: 4,
|
||||
});
|
||||
})
|
||||
.finally(() => {
|
||||
setDataLoading(false)
|
||||
})
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<Space direction='vertical' className='w-full'>
|
||||
<Row>
|
||||
<Col flex="auto"><SearchForm
|
||||
fieldsConfig={{
|
||||
shows: ['referenceNo', 'dates', 'approvalStatus'],
|
||||
fieldProps: {
|
||||
dates: { label: t('review:ApprovalDate') },
|
||||
},
|
||||
}}
|
||||
onSubmit={() => {
|
||||
searchReview(formValuesToSub)
|
||||
}}
|
||||
/></Col>
|
||||
<Col flex="200px" className='flex justify-center items-center'><Button color="cyan" variant="solid">Add Review</Button></Col>
|
||||
</Row>
|
||||
|
||||
|
||||
<Row>
|
||||
<Col span={24}>
|
||||
<Table
|
||||
bordered
|
||||
loading={dataLoading}
|
||||
pagination={{
|
||||
position: ['bottomCenter'],
|
||||
simple: true
|
||||
}}
|
||||
columns={reviewListColumns} dataSource={reviewList}
|
||||
/>
|
||||
</Col>
|
||||
</Row>
|
||||
</Space>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default ReviewList
|
||||
Loading…
Reference in New Issue