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

const TermInfo = ({ terms = [] }: { terms?: TermDto[] }) => {
	return (
		<div>
			{terms && terms?.length > 0 ? (
				<div className="flex gap-2 mb-4">
					{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;
