staff_data/apps/web/src/app/main/path/components/TermInfo.tsx

42 lines
896 B
TypeScript
Raw Normal View History

2025-02-27 10:23:04 +08:00
import { Tag } from "antd";
2025-02-28 12:55:53 +08:00
import { PostDto, TaxonomySlug, TermDto } from "@nice/common";
2025-02-27 10:23:04 +08:00
2025-02-28 12:55:53 +08:00
const TermInfo = ({ terms = [] }: { terms?: TermDto[] }) => {
2025-02-27 13:32:33 +08:00
return (
2025-02-27 21:45:40 +08:00
<div>
2025-02-28 12:55:53 +08:00
{terms && terms?.length > 0 ? (
2025-02-27 13:32:33 +08:00
<div className="flex gap-2 mb-4">
2025-02-28 12:55:53 +08:00
{terms?.map((term: any) => {
2025-02-27 13:32:33 +08:00
return (
<Tag
key={term.id}
color={
term?.taxonomy?.slug ===
TaxonomySlug.CATEGORY
2025-02-27 21:45:40 +08:00
? "green"
2025-02-27 13:32:33 +08:00
: term?.taxonomy?.slug ===
TaxonomySlug.LEVEL
2025-02-27 21:45:40 +08:00
? "blue"
2025-02-27 13:32:33 +08:00
: "orange"
}
className="px-3 py-1 rounded-full border-0">
{term.name}
</Tag>
);
})}
</div>
) : (
<div className="flex gap-2 mb-4">
<Tag
color={"orange"}
className="px-3 py-1 rounded-full border-0">
{"未设置分类"}
</Tag>
</div>
)}
2025-02-27 21:45:40 +08:00
</div>
2025-02-27 13:32:33 +08:00
);
2025-02-27 10:23:04 +08:00
};
2025-02-27 13:32:33 +08:00
export default TermInfo;