mirror of
https://github.com/StepanovPlaton/torrent_frontend.git
synced 2026-04-03 20:30:48 +04:00
Init game page
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user