refactor(pages): migrate app data reads to api adapters
This commit is contained in:
@@ -8,7 +8,13 @@ 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 { mockFavorites, mockPlayers, mockReviews, mockServices, mockShops } from "@/lib/mock"
|
||||
import {
|
||||
isFavorited as checkFavorited,
|
||||
getShopById,
|
||||
listPlayersByShop,
|
||||
listReviews,
|
||||
listServices,
|
||||
} from "@/lib/api"
|
||||
|
||||
interface PageProps {
|
||||
params: Promise<{ id: string }>
|
||||
@@ -16,19 +22,17 @@ interface PageProps {
|
||||
|
||||
export default async function ShopPage({ params }: PageProps) {
|
||||
const { id } = await params
|
||||
const shop = mockShops.find((s) => s.id === id)
|
||||
const shop = getShopById(id)
|
||||
|
||||
if (!shop) {
|
||||
notFound()
|
||||
}
|
||||
|
||||
const shopPlayers = mockPlayers.filter((p) => p.shopId === shop.id)
|
||||
const shopPlayers = listPlayersByShop(shop.id)
|
||||
const playerIds = shopPlayers.map((p) => p.id)
|
||||
const shopServices = mockServices.filter((s) => playerIds.includes(s.playerId))
|
||||
const shopReviews = mockReviews.filter((r) => playerIds.includes(r.toUserId))
|
||||
const isFavorited = mockFavorites.some(
|
||||
(f) => f.userId === "u1" && f.targetType === "shop" && f.targetId === shop.id,
|
||||
)
|
||||
const shopServices = listServices().filter((s) => playerIds.includes(s.playerId))
|
||||
const shopReviews = listReviews().filter((r) => playerIds.includes(r.toUserId))
|
||||
const isFavorited = checkFavorited("u1", "shop", shop.id)
|
||||
|
||||
const sortedSections = [...shop.templateConfig.sections]
|
||||
.filter((s) => s.enabled)
|
||||
|
||||
Reference in New Issue
Block a user