refactor(community): extract comment store and post/comment API adapters
This commit is contained in:
@@ -1,14 +1,15 @@
|
||||
import { ArrowLeft, MessageCircle, Pin, Star } from "lucide-react"
|
||||
import { ArrowLeft, Pin, Star } from "lucide-react"
|
||||
import Image from "next/image"
|
||||
import Link from "next/link"
|
||||
import { notFound } from "next/navigation"
|
||||
import { PostCommentCount } from "@/components/post-comment-count"
|
||||
import { PostComments } from "@/components/post-comments"
|
||||
import { PostLikeButton } from "@/components/post-like-button"
|
||||
import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"
|
||||
import { Badge } from "@/components/ui/badge"
|
||||
import { Card, CardContent, CardHeader } from "@/components/ui/card"
|
||||
import { Separator } from "@/components/ui/separator"
|
||||
import { getOrderById, getPlayerById, getPostById, listCommentsByPost } from "@/lib/api"
|
||||
import { getOrderById, getPlayerById, getPostById } from "@/lib/api"
|
||||
import { roleLabels } from "@/lib/constants"
|
||||
|
||||
export default async function PostDetailPage({ params }: { params: Promise<{ id: string }> }) {
|
||||
@@ -16,7 +17,6 @@ export default async function PostDetailPage({ params }: { params: Promise<{ id:
|
||||
const post = getPostById(id)
|
||||
if (!post) notFound()
|
||||
|
||||
const comments = listCommentsByPost(id)
|
||||
const linkedOrder = post.linkedOrderId ? getOrderById(post.linkedOrderId) : null
|
||||
const linkedPlayer = linkedOrder ? getPlayerById(linkedOrder.playerId) : null
|
||||
|
||||
@@ -91,18 +91,15 @@ export default async function PostDetailPage({ params }: { params: Promise<{ id:
|
||||
)}
|
||||
|
||||
<div className="flex items-center gap-4 text-sm text-muted-foreground pt-2">
|
||||
<PostLikeButton initialLiked={post.liked} initialCount={post.likeCount} />
|
||||
<span className="flex items-center gap-1">
|
||||
<MessageCircle className="h-4 w-4" />
|
||||
{post.commentCount}
|
||||
</span>
|
||||
<PostLikeButton postId={post.id} />
|
||||
<PostCommentCount postId={post.id} />
|
||||
</div>
|
||||
</CardContent>
|
||||
</Card>
|
||||
|
||||
<Separator className="my-6" />
|
||||
|
||||
<PostComments initialComments={comments} postId={id} />
|
||||
<PostComments postId={id} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user