fix: 加固后台日常配置体验
This commit is contained in:
1 parent
34b872a84c
commit
d7e5b64d84
6 files changed
+84
-10
No files matched your search
@@ -1,10 +1,12 @@
|
||||
import { Card, Col, List, Row, Space, Statistic, Tag, Typography } from "antd";
|
||||
import { Button, Card, Col, List, Row, Space, Statistic, Tag, Typography } from "antd";
|
||||
import { useQueries } from "@tanstack/react-query";
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { createApiClient } from "../../lib/api.js";
|
||||
import { AdminPageHeader } from "../../components/AdminPageHeader.js";
|
||||
import { QueryState } from "../../components/QueryState.js";
|
||||
|
||||
export function OverviewPage() {
|
||||
const navigate = useNavigate();
|
||||
const client = createApiClient();
|
||||
const results = useQueries({
|
||||
queries: [
|
||||
@@ -22,15 +24,32 @@ export function OverviewPage() {
|
||||
const error = results.find((result) => result.isError)?.error;
|
||||
const retry = () => results.forEach((result) => void result.refetch());
|
||||
const brand = results[0].data;
|
||||
const workspace = results[1].data as { inquiryForm?: { isEnabled?: boolean } } | undefined;
|
||||
const workspace = results[1].data as
|
||||
| {
|
||||
inquiryForm?: { isEnabled?: boolean };
|
||||
templateContent?: { displayName?: string } | null;
|
||||
}
|
||||
| undefined;
|
||||
const trust = results[2].data;
|
||||
const offerings = results[3].data as Array<{ isEnabled?: boolean }> | undefined;
|
||||
const submissions = results[4].data;
|
||||
const checklist = [
|
||||
{ label: "品牌定位已填写", done: Boolean(brand?.name && brand.tagline) },
|
||||
{ label: "信任内容已发布", done: Boolean(trust?.some((item) => item.isPublished)) },
|
||||
{ label: "至少有一个公开业务提供项", done: Boolean(offerings?.some((item) => item.isEnabled)) },
|
||||
{ label: "咨询入口已配置", done: Boolean(workspace?.inquiryForm?.isEnabled) },
|
||||
{ label: "品牌定位已填写", done: Boolean(brand?.name && brand.tagline), path: "/admin/brand" },
|
||||
{
|
||||
label: "信任内容已发布",
|
||||
done: Boolean(trust?.some((item) => item.isPublished)),
|
||||
path: "/admin/trust",
|
||||
},
|
||||
{
|
||||
label: "至少有一个公开业务提供项",
|
||||
done: Boolean(offerings?.some((item) => item.isEnabled)),
|
||||
path: "/admin/services",
|
||||
},
|
||||
{
|
||||
label: "咨询入口已配置",
|
||||
done: Boolean(workspace?.inquiryForm?.isEnabled),
|
||||
path: "/admin/workspace",
|
||||
},
|
||||
];
|
||||
return (
|
||||
<QueryState loading={loading} error={error} onRetry={retry}>
|
||||
@@ -47,7 +66,7 @@ export function OverviewPage() {
|
||||
{brand?.tagline || "还没有设置一句话定位"}
|
||||
</Typography.Paragraph>
|
||||
<Tag color="blue">
|
||||
当前模板:{brand?.templateKey === "food" ? "餐饮模板" : "个人品牌"}
|
||||
当前模板:{workspace?.templateContent?.displayName ?? "尚未安装模板"}
|
||||
</Tag>
|
||||
</Card>
|
||||
<Row gutter={[16, 16]}>
|
||||
@@ -87,6 +106,11 @@ export function OverviewPage() {
|
||||
{item.done ? "已完成" : "待完善"}
|
||||
</Tag>
|
||||
<span>{item.label}</span>
|
||||
{!item.done && (
|
||||
<Button type="link" size="small" onClick={() => navigate(item.path)}>
|
||||
去处理
|
||||
</Button>
|
||||
)}
|
||||
</Space>
|
||||
</List.Item>
|
||||
)}
|
||||
|
||||
@@ -53,7 +53,10 @@ export function ServicesPage() {
|
||||
const toggleOffering = useMutation({
|
||||
mutationFn: ({ id, isEnabled }: { id: string; isEnabled: boolean }) =>
|
||||
client.updateAdminOffering(id, { isEnabled }),
|
||||
onSuccess: () => void queryClient.invalidateQueries({ queryKey: ["admin-offerings"] }),
|
||||
onSuccess: () => {
|
||||
message.success("业务提供项状态已更新");
|
||||
void queryClient.invalidateQueries({ queryKey: ["admin-offerings"] });
|
||||
},
|
||||
});
|
||||
const beginOffering = (item?: Offering) => {
|
||||
setEditingOffering(item ?? null);
|
||||
@@ -92,6 +95,7 @@ export function ServicesPage() {
|
||||
/>
|
||||
<Card title="公开业务提供项" extra={<Tag color="blue">小程序优先展示</Tag>}>
|
||||
<Table
|
||||
scroll={{ x: 760 }}
|
||||
rowKey="id"
|
||||
loading={offerings.isLoading}
|
||||
dataSource={offerings.data ?? []}
|
||||
@@ -128,6 +132,7 @@ export function ServicesPage() {
|
||||
</Button>
|
||||
<Button
|
||||
size="small"
|
||||
loading={toggleOffering.isPending && toggleOffering.variables?.id === item.id}
|
||||
onClick={() =>
|
||||
toggleOffering.mutate({ id: item.id, isEnabled: !item.isEnabled })
|
||||
}
|
||||
@@ -141,7 +146,11 @@ export function ServicesPage() {
|
||||
okText="删除"
|
||||
cancelText="取消"
|
||||
>
|
||||
<Button danger size="small" loading={deleteOffering.isPending}>
|
||||
<Button
|
||||
danger
|
||||
size="small"
|
||||
loading={deleteOffering.isPending && deleteOffering.variables === item.id}
|
||||
>
|
||||
删除
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
@@ -156,6 +165,8 @@ export function ServicesPage() {
|
||||
</Typography.Paragraph>
|
||||
)}
|
||||
<MutationError error={saveOffering.error} />
|
||||
<MutationError error={toggleOffering.error} />
|
||||
<MutationError error={deleteOffering.error} />
|
||||
</Card>
|
||||
<Modal
|
||||
open={offeringOpen}
|
||||
|
||||
@@ -143,7 +143,7 @@ export function TrustContentPage() {
|
||||
title: "证据类型",
|
||||
dataIndex: "type",
|
||||
render: (value) => (
|
||||
<Tag>{types.find((item) => item.value === value)?.label ?? value}</Tag>
|
||||
<Tag>{availableTypes.find((item) => item.type === value)?.label ?? value}</Tag>
|
||||
),
|
||||
},
|
||||
{ title: "标题", dataIndex: "title" },
|
||||
|
||||
Reference in new issue
Block a user