feat: 增加咨询记录详情抽屉
This commit is contained in:
1 parent
5a5a74b084
commit
8ea80f8c80
1 file changed
+50
-2
@@ -1,4 +1,15 @@
|
||||
import { Badge, Button, Card, Select, Space, Table, Tag, message } from "antd";
|
||||
import {
|
||||
Badge,
|
||||
Button,
|
||||
Card,
|
||||
Descriptions,
|
||||
Drawer,
|
||||
Select,
|
||||
Space,
|
||||
Table,
|
||||
Tag,
|
||||
message,
|
||||
} from "antd";
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import type { AdminBooking } from "@personal-brand/api-client";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
@@ -17,6 +28,7 @@ export function InquiriesPage() {
|
||||
const client = createApiClient();
|
||||
const queryClient = useQueryClient();
|
||||
const [status, setStatus] = useState<string>();
|
||||
const [selectedId, setSelectedId] = useState<string>();
|
||||
const query = useQuery({
|
||||
queryKey: ["admin-bookings", status],
|
||||
queryFn: () => client.listAdminBookings(status ? { status: status as never } : {}),
|
||||
@@ -33,6 +45,11 @@ export function InquiriesPage() {
|
||||
mutationFn: (id: string) => client.markAdminBookingRead(id),
|
||||
onSuccess: () => void queryClient.invalidateQueries({ queryKey: ["admin-bookings"] }),
|
||||
});
|
||||
const detail = useQuery({
|
||||
queryKey: ["admin-booking", selectedId],
|
||||
queryFn: () => client.getAdminBooking(selectedId!),
|
||||
enabled: Boolean(selectedId),
|
||||
});
|
||||
return (
|
||||
<Card
|
||||
title="咨询记录"
|
||||
@@ -61,7 +78,15 @@ export function InquiriesPage() {
|
||||
loading={query.isLoading}
|
||||
dataSource={query.data ?? []}
|
||||
columns={[
|
||||
{ title: "编号", dataIndex: "bookingNo" },
|
||||
{
|
||||
title: "编号",
|
||||
dataIndex: "bookingNo",
|
||||
render: (value: string, item: AdminBooking) => (
|
||||
<Button type="link" onClick={() => setSelectedId(item.id)}>
|
||||
{value}
|
||||
</Button>
|
||||
),
|
||||
},
|
||||
{ title: "联系人", dataIndex: "customerName" },
|
||||
{
|
||||
title: "提交时间",
|
||||
@@ -91,6 +116,29 @@ export function InquiriesPage() {
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<Drawer
|
||||
title="咨询详情"
|
||||
open={Boolean(selectedId)}
|
||||
onClose={() => setSelectedId(undefined)}
|
||||
loading={detail.isLoading}
|
||||
width={520}
|
||||
>
|
||||
{detail.data && (
|
||||
<Descriptions column={1} bordered size="small">
|
||||
<Descriptions.Item label="编号">{detail.data.bookingNo}</Descriptions.Item>
|
||||
<Descriptions.Item label="联系人">{detail.data.customerName}</Descriptions.Item>
|
||||
<Descriptions.Item label="状态">
|
||||
{labels[detail.data.status] ?? detail.data.status}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="提交时间">
|
||||
{new Date(detail.data.createdAt).toLocaleString("zh-CN")}
|
||||
</Descriptions.Item>
|
||||
<Descriptions.Item label="管理员备注">
|
||||
{detail.data.adminNote || "暂无"}
|
||||
</Descriptions.Item>
|
||||
</Descriptions>
|
||||
)}
|
||||
</Drawer>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user