refactor(shop): aggregate services from embedded player profiles

This commit is contained in:
zetaloop
2026-05-03 05:49:36 +08:00
parent 7acde68d45
commit 88eb9727b5
+3 -4
View File
@@ -5,7 +5,7 @@ import { Button } from "@/components/ui/button"
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
import { EmptyState } from "@/components/ui/empty-state"
import { Separator } from "@/components/ui/separator"
import { getShopById, listPlayersByShop, listReviews, listServices } from "@/lib/api"
import { getShopById, listPlayersByShop, listReviews } from "@/lib/api"
import { getShopSections } from "@/lib/domain/shop-template"
import { Gamepad2, Megaphone, ShoppingBag, Star, Users } from "lucide-react"
import Image from "next/image"
@@ -24,9 +24,8 @@ export default async function ShopPage({ params }: PageProps) {
notFound()
}
const [shopPlayers, allServices] = await Promise.all([listPlayersByShop(shop.id), listServices()])
const playerIds = new Set(shopPlayers.map((player) => String(player.id)))
const shopServices = allServices.filter((service) => playerIds.has(String(service.playerId)))
const shopPlayers = await listPlayersByShop(shop.id)
const shopServices = shopPlayers.flatMap((player) => player.services)
const shopReviews = await listReviews()
const sortedSections = getShopSections(shop).filter((s) => s.enabled)