refactor(pages): migrate app data reads to api adapters

This commit is contained in:
zetaloop
2026-02-22 08:30:21 +08:00
parent 43a0cf7a73
commit 4beb610f23
13 changed files with 97 additions and 66 deletions
@@ -19,8 +19,8 @@ import {
SelectValue,
} from "@/components/ui/select"
import { Textarea } from "@/components/ui/textarea"
import { getGameById, listGames } from "@/lib/api"
import { GameIcon } from "@/lib/game-icons"
import { mockGames } from "@/lib/mock"
import type { PlayerService } from "@/lib/types"
import { useAuthStore } from "@/store/auth"
import { useServiceStore } from "@/store/services"
@@ -76,9 +76,10 @@ export default function NewServicePage() {
const selectedGameId = watch("gameId")
const selectedUnit = watch("unit")
const games = listGames()
const onSubmit = async (data: z.infer<typeof serviceSchema>) => {
const game = mockGames.find((item) => item.id === data.gameId)
const game = getGameById(data.gameId)
if (!game) return
const payload: Omit<PlayerService, "id"> = {
@@ -128,7 +129,7 @@ export default function NewServicePage() {
<SelectValue placeholder="选择游戏" />
</SelectTrigger>
<SelectContent>
{mockGames.map((game) => (
{games.map((game) => (
<SelectItem key={game.id} value={game.id}>
<div className="flex items-center gap-2">
<GameIcon name={game.icon} className="h-4 w-4" />