init
This commit is contained in:
57
src/features/matches/types.ts
Normal file
57
src/features/matches/types.ts
Normal file
@@ -0,0 +1,57 @@
|
||||
import { z } from "zod";
|
||||
|
||||
export interface Match {
|
||||
id: string;
|
||||
order: number;
|
||||
lid: number;
|
||||
reset: boolean;
|
||||
round: number;
|
||||
home_cups: number;
|
||||
away_cups: number;
|
||||
ot_count: number;
|
||||
start_time: string;
|
||||
end_time: string;
|
||||
bye: boolean;
|
||||
home_from_lid: number;
|
||||
away_from_lid: number;
|
||||
home_from_loser: boolean;
|
||||
away_from_loser: boolean;
|
||||
bracket_type: 'winners' | 'losers';
|
||||
tournament_id: string;
|
||||
home_id: string;
|
||||
away_id: string;
|
||||
created: string;
|
||||
updated: string;
|
||||
}
|
||||
|
||||
export const matchInputSchema = z.object({
|
||||
order: z.number().int().min(1).optional(),
|
||||
lid: z.number().int().min(1),
|
||||
reset: z.boolean().optional().default(false),
|
||||
round: z.number().int().min(1),
|
||||
home_cups: z.number().int().min(0).optional().default(0),
|
||||
away_cups: z.number().int().min(0).optional().default(0),
|
||||
ot_count: z.number().int().min(0).optional().default(0),
|
||||
start_time: z.iso.datetime("Invalid start time format").optional(),
|
||||
end_time: z.iso.datetime("Invalid end time format").optional(),
|
||||
bye: z.boolean().optional().default(false),
|
||||
home_from_lid: z.number().int().min(1).optional(),
|
||||
away_from_lid: z.number().int().min(1).optional(),
|
||||
home_from_loser: z.boolean().optional().default(false),
|
||||
away_from_loser: z.boolean().optional().default(false),
|
||||
losers_bracket: z.boolean().optional().default(false),
|
||||
tournament_id: z.string().min(1),
|
||||
home_id: z.string().min(1).optional(),
|
||||
away_id: z.string().min(1).optional(),
|
||||
}).refine(
|
||||
(data) => {
|
||||
if (data.start_time && data.end_time) {
|
||||
return new Date(data.start_time) < new Date(data.end_time);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
{ message: "End time must be after start time", path: ["end_time"] }
|
||||
);
|
||||
|
||||
export type MatchInput = z.infer<typeof matchInputSchema>;
|
||||
export type MatchUpdateInput = Partial<MatchInput>;
|
||||
Reference in New Issue
Block a user