import { PostDto, VisitType } from "@nice/common"; import { motion } from "framer-motion"; import dayjs from "dayjs"; import { ChatBubbleLeftIcon, HeartIcon } from "@heroicons/react/24/outline"; import { HeartIcon as HeartIconSolid } from "@heroicons/react/24/solid"; import { Avatar } from "antd"; import { useVisitor } from "@nice/client"; import { useContext } from "react"; import { PostDetailContext } from "./context/PostDetailContext"; export default function PostCommentCard({ post, index, isReceiverComment }: { post: PostDto; index: number; isReceiverComment: boolean; }) { const { user } = useContext(PostDetailContext); const { like } = useVisitor(); async function likeThisPost() { if (!post?.liked) { try { await like.mutateAsync({ data: { visitorId: user?.id || null, postId: post.id, type: VisitType.LIKE, }, }); } catch (error) { console.error("Failed to like post:", error); } } } return (
{!post.author?.avatar && (post.author?.showname || "匿名用户")}
{isReceiverComment && ( 反馈解答 )} {post.author?.showname || "匿名用户"} {dayjs(post?.createdAt).format("YYYY-MM-DD HH:mm")}
{/* 添加有帮助按钮 */}
{post?.liked ? ( ) : ( )} {post?.likes || 0} 有帮助
); }