Init game page

This commit is contained in:
2024-05-12 13:12:13 +04:00
parent 275d99bd85
commit 15247adfa3
9 changed files with 88 additions and 12 deletions

View File

@@ -1,5 +1,6 @@
import { HTTPService } from "@/shared/http/httpService";
import { gameCardsSchema, GameCardType } from "./schemas/gameCard";
import { gameSchema, GameType } from "./schemas/game";
export abstract class GameService {
public static async getGameCards() {
@@ -8,4 +9,7 @@ export abstract class GameService {
gameCardsSchema
);
}
public static async getGame(id: number) {
return await HTTPService.get<GameType>(`/games/${id}`, gameSchema);
}
}

View File

@@ -1,8 +1,7 @@
import { z } from "zod";
import { gameCardSchema } from "./gameCard";
export const gameSchema = z.union([
gameCardSchema,
export const gameSchema = gameCardSchema.and(
z.object({
torrent_file: z.string().min(1),
language: z.string().optional(),
@@ -17,8 +16,8 @@ export const gameSchema = z.union([
.string()
.min(1)
.transform((d) => new Date(d)),
}),
]);
})
);
export type GameType = z.infer<typeof gameSchema>;
export const isGame = (a: any): a is GameType => {