refactor: 拆分业务、信任内容与公共工作台模块
This commit is contained in:
1 parent
357f271639
commit
466dc66907
33 files changed
+4950
-4500
No files matched your search
@@ -0,0 +1,77 @@
|
||||
import { Button, Popconfirm, Space, Table, Tag } from "antd";
|
||||
import type { TrustContent } from "@personal-brand/api-client";
|
||||
import type { TrustTypeOption } from "../domain/trust-content-domain.js";
|
||||
import { getTrustContentPreview } from "../domain/trust-content-domain.js";
|
||||
import { MutationError } from "../../../components/QueryState.js";
|
||||
|
||||
export function TrustContentTable({
|
||||
availableTypes,
|
||||
items,
|
||||
removeError,
|
||||
removePending,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}: {
|
||||
availableTypes: TrustTypeOption[];
|
||||
items: TrustContent[];
|
||||
removeError: unknown;
|
||||
removePending: boolean;
|
||||
onEdit: (item: TrustContent) => void;
|
||||
onDelete: (id: string) => void;
|
||||
}) {
|
||||
return (
|
||||
<section aria-label="已配置的品牌内容">
|
||||
<Table
|
||||
rowKey="id"
|
||||
dataSource={items}
|
||||
locale={{ emptyText: "还没有品牌内容,请先按上方模板要求添加。" }}
|
||||
columns={[
|
||||
{
|
||||
title: "内容类型",
|
||||
dataIndex: "type",
|
||||
render: (value) => (
|
||||
<Tag>{availableTypes.find((item) => item.type === value)?.label ?? value}</Tag>
|
||||
),
|
||||
},
|
||||
{ title: "标题", dataIndex: "title" },
|
||||
{
|
||||
title: "内容预览",
|
||||
ellipsis: { showTitle: true },
|
||||
render: (_value: unknown, item: TrustContent) =>
|
||||
getTrustContentPreview(
|
||||
item,
|
||||
availableTypes.find((type) => type.type === item.type),
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "发布状态",
|
||||
dataIndex: "isPublished",
|
||||
render: (value) => (
|
||||
<Tag color={value ? "success" : "default"}>{value ? "随发布展示" : "草稿"}</Tag>
|
||||
),
|
||||
},
|
||||
{
|
||||
title: "操作",
|
||||
render: (_: unknown, item: TrustContent) => (
|
||||
<Space>
|
||||
<Button size="small" onClick={() => onEdit(item)}>
|
||||
编辑
|
||||
</Button>
|
||||
<Popconfirm
|
||||
title="确认删除这条信任内容?"
|
||||
description="删除后需发布品牌,才会更新小程序展示。"
|
||||
onConfirm={() => onDelete(item.id)}
|
||||
>
|
||||
<Button size="small" danger loading={removePending}>
|
||||
删除
|
||||
</Button>
|
||||
</Popconfirm>
|
||||
</Space>
|
||||
),
|
||||
},
|
||||
]}
|
||||
/>
|
||||
<MutationError error={removeError} />
|
||||
</section>
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user