feat(orders): migrate orders to backend API

This commit is contained in:
zetaloop
2026-02-28 18:13:42 +08:00
parent e94a7e68ff
commit 9739c94bdc
9 changed files with 263 additions and 130 deletions
+5 -3
View File
@@ -14,9 +14,9 @@ import { useEffect, useState } from "react"
export default function CommunityPage() {
const [games, setGames] = useState<Game[]>([])
const [players, setPlayers] = useState<Player[]>([])
const [orders, setOrders] = useState<Awaited<ReturnType<typeof listOrders>>>([])
const [posts, setPosts] = useState<Post[]>([])
const [postsLoading, setPostsLoading] = useState(true)
const orders = listOrders()
const [sortMode, setSortMode] = useState<"latest" | "hot">("latest")
const [selectedGame, setSelectedGame] = useState<string | null>(null)
@@ -26,11 +26,12 @@ export default function CommunityPage() {
setPostsLoading(true)
Promise.all([listGames(), listPlayers(), listPosts()])
.then(([gamesItems, playersItems, postsItems]) => {
Promise.all([listGames(), listPlayers(), Promise.resolve(listOrders()), listPosts()])
.then(([gamesItems, playersItems, ordersItems, postsItems]) => {
if (cancelled) return
setGames(gamesItems)
setPlayers(playersItems)
setOrders(ordersItems)
setPosts(postsItems)
setPostsLoading(false)
})
@@ -38,6 +39,7 @@ export default function CommunityPage() {
if (cancelled) return
setGames([])
setPlayers([])
setOrders([])
setPosts([])
setPostsLoading(false)
})