import { FavoriteButton } from "@/components/favorite-button" import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Separator } from "@/components/ui/separator" import { getShopById, listPlayersByShop, listReviews, listServices } from "@/lib/api" import { Gamepad2, Megaphone, ShoppingBag, Star, Users } from "lucide-react" import Image from "next/image" import Link from "next/link" import { notFound } from "next/navigation" interface PageProps { params: Promise<{ id: string }> } export default async function ShopPage({ params }: PageProps) { const { id } = await params const shop = await getShopById(id) if (!shop) { notFound() } const [shopPlayers, allServices] = await Promise.all([listPlayersByShop(shop.id), listServices()]) const playerIds = shopPlayers.map((p) => p.id) const shopServices = allServices.filter((s) => playerIds.includes(s.playerId)) const shopReviews = await listReviews() const sortedSections = [...shop.templateConfig.sections] .filter((s) => s.enabled) .sort((a, b) => a.order - b.order) return (
{sortedSections.map((section) => { switch (section.type) { case "banner": return (
{shop.banner ? ( {shop.name} ) : (
)}

{shop.name}

) case "intro": return (

{shop.name}

{shop.description}

{shop.rating} 评分
{shop.totalOrders} 总订单
{shop.playerCount} 打手
{shop.owner.nickname[0]}

店长:{shop.owner.nickname}

{shop.owner.bio || "暂无介绍"}

) case "announcements": if (shop.announcements.length === 0) return null return ( 店铺公告
    {shop.announcements.map((announcement) => (
  • {announcement}
  • ))}
) case "services": if (shopServices.length === 0) return null return (

热门服务

{shopServices.map((service) => (
{service.gameName}
¥{service.price} /{service.unit}
{service.title}

{service.description}

{service.rankRange && (
段位:{service.rankRange}
)}
))}
) case "players": if (shopPlayers.length === 0) return null return (

明星陪玩

{shopPlayers.map((player) => (
{player.user.nickname[0]}

{player.user.nickname}

{player.rating} {player.totalOrders}单
{player.games.slice(0, 3).map((game) => ( {game} ))}
))}
) case "reviews": if (shopReviews.length === 0) return null return (

最新评价

{shopReviews.map((review) => (
{review.fromUserName[0]}

{review.fromUserName}

{[1, 2, 3, 4, 5].map((star) => ( ))}
{new Date(review.createdAt).toLocaleDateString()}

{review.content}

))}
) default: return null } })}
) }