import { Tag } from "antd";
import { PostDto, TaxonomySlug } from "@nice/common";

const TermInfo = ({ post }: { post: PostDto }) => {
	return (
		<div>
			{post?.terms && post?.terms?.length > 0 ? (
				<div className="flex gap-2 mb-4">
					{post?.terms?.map((term: any) => {
						return (
							<Tag
								key={term.id}
								color={
									term?.taxonomy?.slug ===
									TaxonomySlug.CATEGORY
										? "green"
										: term?.taxonomy?.slug ===
											  TaxonomySlug.LEVEL
											? "blue"
											: "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>
			)}
		</div>
	);
};

export default TermInfo;
