refactor(pages): migrate app data reads to api adapters
This commit is contained in:
@@ -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" />
|
||||
|
||||
Reference in New Issue
Block a user