doctor-mail/apps/web/src/components/models/post/detail/PostCommentCard.tsx

77 lines
2.2 KiB
TypeScript
Raw Normal View History

2025-01-24 00:19:02 +08:00
import { PostDto, VisitType } from "@nice/common";
import { motion } from "framer-motion";
import dayjs from "dayjs";
2025-01-24 17:39:41 +08:00
2025-01-24 11:39:51 +08:00
import { Avatar } from "antd";
2025-01-24 00:19:02 +08:00
import { useVisitor } from "@nice/client";
2025-01-24 17:39:41 +08:00
import { useContext, useState } from "react";
2025-01-24 00:19:02 +08:00
import { PostDetailContext } from "./context/PostDetailContext";
2025-01-24 17:39:41 +08:00
import { LikeFilled, LikeOutlined } from "@ant-design/icons";
2025-01-25 00:46:59 +08:00
import PostLikeButton from "./PostHeader/PostLikeButton";
import { CustomAvatar } from "@web/src/components/presentation/CustomAvatar";
2025-01-25 19:51:08 +08:00
import PostResources from "./PostResources";
2025-01-24 00:19:02 +08:00
export default function PostCommentCard({
post,
index,
2025-01-24 17:39:41 +08:00
isReceiverComment,
2025-01-24 00:19:02 +08:00
}: {
post: PostDto;
index: number;
2025-01-24 15:06:57 +08:00
isReceiverComment: boolean;
2025-01-24 00:19:02 +08:00
}) {
return (
<motion.div
className="bg-white rounded-lg shadow-sm border border-slate-200 p-4"
layout>
2025-01-25 00:46:59 +08:00
<div className="flex items-start space-x-3 gap-4">
2025-01-24 00:19:02 +08:00
<div className="flex-shrink-0">
2025-01-25 00:46:59 +08:00
<CustomAvatar
2025-01-24 00:19:02 +08:00
src={post.author?.avatar}
2025-01-25 00:46:59 +08:00
size={40}
name={
!post.author?.avatar && post.author?.showname
}></CustomAvatar>
2025-01-24 00:19:02 +08:00
</div>
<div className="flex-1 min-w-0">
2025-01-25 19:51:08 +08:00
<div className="flex flex-1 justify-between ">
2025-01-25 00:46:59 +08:00
<div className="flex space-x-2" style={{ height: 40 }}>
2025-01-25 19:51:08 +08:00
<span className="flex font-medium text-slate-900">
2025-01-25 00:46:59 +08:00
{post.author?.showname || "匿名用户"}
</span>
2025-01-25 19:51:08 +08:00
<span className="flex text-sm text-slate-500">
2025-01-25 00:46:59 +08:00
{dayjs(post?.createdAt).format(
"YYYY-MM-DD HH:mm"
)}
2025-01-24 17:39:41 +08:00
</span>
2025-01-25 00:46:59 +08:00
{isReceiverComment && (
2025-01-25 19:51:08 +08:00
<div className=" ">
<span className=" px-2 text-sm rounded-full bg-blue-100 text-blue-800">
2025-01-25 21:20:54 +08:00
2025-01-25 19:51:08 +08:00
</span>
</div>
2025-01-25 00:46:59 +08:00
)}
</div>
{/* 添加有帮助按钮 */}
2025-01-25 19:51:08 +08:00
<div>
<div className="flex justify-center items-center gap-2">
<span className=" text-sm text-slate-500">{`#${index + 1}`}</span>
<PostLikeButton post={post}></PostLikeButton>
</div>
</div>
2025-01-24 00:19:02 +08:00
</div>
2025-01-25 00:46:59 +08:00
2025-01-24 00:19:02 +08:00
<div
className="ql-editor text-slate-800"
style={{
padding: 0,
}}
dangerouslySetInnerHTML={{ __html: post.content || "" }}
/>
2025-01-25 19:51:08 +08:00
<PostResources post={post}></PostResources>
2025-01-24 00:19:02 +08:00
</div>
</div>
</motion.div>
);
}