feat(catalog): fetch players, services, shops

This commit is contained in:
zetaloop
2026-02-28 16:37:15 +08:00
parent f4365668ab
commit f1ae3e04bb
11 changed files with 234 additions and 57 deletions
+7 -5
View File
@@ -6,16 +6,16 @@ import { Button } from "@/components/ui/button"
import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card"
import { listGames, listOrders, listPlayers, listPosts } from "@/lib/api"
import { roleLabels } from "@/lib/constants"
import type { Game } from "@/lib/types"
import type { Game, Player } from "@/lib/types"
import { ClipboardList, Heart, MessageCircle, PenSquare, Pin } from "lucide-react"
import Link from "next/link"
import { useEffect, useState } from "react"
export default function CommunityPage() {
const [games, setGames] = useState<Game[]>([])
const [players, setPlayers] = useState<Player[]>([])
const posts = listPosts()
const orders = listOrders()
const players = listPlayers()
const [sortMode, setSortMode] = useState<"latest" | "hot">("latest")
const [selectedGame, setSelectedGame] = useState<string | null>(null)
@@ -23,14 +23,16 @@ export default function CommunityPage() {
useEffect(() => {
let cancelled = false
listGames()
.then((items) => {
Promise.all([listGames(), listPlayers()])
.then(([gamesItems, playersItems]) => {
if (cancelled) return
setGames(items)
setGames(gamesItems)
setPlayers(playersItems)
})
.catch(() => {
if (cancelled) return
setGames([])
setPlayers([])
})
return () => {