refactor(shop): aggregate services from embedded player profiles
This commit is contained in:
@@ -5,7 +5,7 @@ import { Button } from "@/components/ui/button"
|
|||||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
||||||
import { EmptyState } from "@/components/ui/empty-state"
|
import { EmptyState } from "@/components/ui/empty-state"
|
||||||
import { Separator } from "@/components/ui/separator"
|
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 { getShopSections } from "@/lib/domain/shop-template"
|
||||||
import { Gamepad2, Megaphone, ShoppingBag, Star, Users } from "lucide-react"
|
import { Gamepad2, Megaphone, ShoppingBag, Star, Users } from "lucide-react"
|
||||||
import Image from "next/image"
|
import Image from "next/image"
|
||||||
@@ -24,9 +24,8 @@ export default async function ShopPage({ params }: PageProps) {
|
|||||||
notFound()
|
notFound()
|
||||||
}
|
}
|
||||||
|
|
||||||
const [shopPlayers, allServices] = await Promise.all([listPlayersByShop(shop.id), listServices()])
|
const shopPlayers = await listPlayersByShop(shop.id)
|
||||||
const playerIds = new Set(shopPlayers.map((player) => String(player.id)))
|
const shopServices = shopPlayers.flatMap((player) => player.services)
|
||||||
const shopServices = allServices.filter((service) => playerIds.has(String(service.playerId)))
|
|
||||||
const shopReviews = await listReviews()
|
const shopReviews = await listReviews()
|
||||||
const sortedSections = getShopSections(shop).filter((s) => s.enabled)
|
const sortedSections = getShopSections(shop).filter((s) => s.enabled)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user