refactor(community): extract comment store and post/comment API adapters
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
"use client"
|
||||
|
||||
import { MessageCircle } from "lucide-react"
|
||||
import { useCommentStore } from "@/store/comments"
|
||||
|
||||
interface PostCommentCountProps {
|
||||
postId: string
|
||||
}
|
||||
|
||||
export function PostCommentCount({ postId }: PostCommentCountProps) {
|
||||
const count = useCommentStore(
|
||||
(state) => state.comments.filter((comment) => comment.postId === postId).length,
|
||||
)
|
||||
|
||||
return (
|
||||
<span className="flex items-center gap-1">
|
||||
<MessageCircle className="h-4 w-4" />
|
||||
{count}
|
||||
</span>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user