import { useContext } from "react"; import { PostDetailContext } from "./context/PostDetailContext"; import { motion } from "framer-motion"; import { CalendarIcon, UserCircleIcon, LockClosedIcon, LockOpenIcon, StarIcon, ClockIcon, EyeIcon, ChatBubbleLeftIcon, } from "@heroicons/react/24/outline"; import { useVisitor } from "@nice/client"; import { PostState, VisitType } from "@nice/common"; import { CommentOutlined, EyeOutlined, LikeFilled, LikeOutlined, } from "@ant-design/icons"; import dayjs from "dayjs"; import { TitleSection } from "./PostHeader/TitleSection"; import { AuthorBadge, DateBadge, TermBadge, UpdatedBadge, VisibilityBadge, } from "./PostHeader/InfoBadge"; import { StatsSection } from "./PostHeader/StatsSection"; export default function PostHeader() { const { post, user } = useContext(PostDetailContext); const { like, unLike } = useVisitor(); function likeThisPost() { if (!post?.liked) { post.likes += 1; post.liked = true; like.mutateAsync({ data: { visitorId: user?.id || null, postId: post.id, type: VisitType.LIKE, }, }); } else { post.likes -= 1; post.liked = false; unLike.mutateAsync({ where: { visitorId: user?.id || null, postId: post.id, type: VisitType.LIKE, }, }); } } return ( {/* Corner Decorations */}
{/* Title Section */}
{/* First Row - Basic Info */}
{/* Author Info Badge */} {/* Date Info Badge */} {post?.createdAt && ( )} {/* Last Updated Badge */} {post?.updatedAt && post.updatedAt !== post.createdAt && ( )} {/* Visibility Status Badge */}
{/* Second Row - Term and Tags */}
{/* Term Badge */} {post?.term?.name && ( )} {/* Tags Badges */} {post?.meta?.tags && post.meta.tags.length > 0 && post.meta.tags.map((tag, index) => ( #{tag} ))}
{/* Content Section */}
{/* Stats Section */} ); }