Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
Bit-Barron committed Oct 15, 2024
1 parent 59c3870 commit 2a14b0f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
18 changes: 11 additions & 7 deletions src/components/pages/dashboard/tournament-create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@ export const CreateTournament: React.FC<CreateTournamentProps> = ({
game_type: tournamentStore.gameType as GAMETYPE,
max_participants: tournamentStore.maxParticipants,
hosted_by: "admin",
start_date: new Date(),
start_date: tournamentStore.startDate as any,
tournament_name: tournamentStore.tournamentName,
})
.then(() => {
toast.success("Tournament created successfully");
setOpen(false);
})
.catch(() => {
toast.error("Failed to create tournament");
.catch((error) => {
toast.error(`Failed to create tournament: ${error.message}`);
});
};

Expand All @@ -61,19 +61,23 @@ export const CreateTournament: React.FC<CreateTournamentProps> = ({
<Input
placeholder="Tournament Name"
value={tournamentStore.tournamentName}
onChange={(e) => tournamentStore.tournamentName}
onChange={(e) => (TournamentStore.tournamentName = e.target.value)}
type="text"
required
/>
<Input
type="text"
placeholder="Game Type"
value={tournamentStore.gameType}
onChange={(e) => tournamentStore.gameType}
required
/>
<Input
placeholder="Max Participants"
value={tournamentStore.maxParticipants}
onChange={(e) => tournamentStore.maxParticipants}
type="number"
onChange={(e) =>
(TournamentStore.maxParticipants = Number(e.target.value))
}
required
/>
<Input
Expand All @@ -84,7 +88,7 @@ export const CreateTournament: React.FC<CreateTournamentProps> = ({
/>
<Input
placeholder="Hosted By"
value={tournamentStore.startDate as unknown as string}
value={tournamentStore.startDate as any}
disabled
required
/>
Expand Down
3 changes: 1 addition & 2 deletions src/server/tournament/typebox.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ export const changeTournamentStatusSchema = t.Object({
t.Literal("ONGOING"),
t.Literal("CANCELED"),
t.Literal("COMPLETED"),

]),
tournamentId: t.Number({ minLength: 1, maxLength: 128 }),
});
Expand All @@ -29,7 +28,7 @@ export const tournamentCreateSchema = t.Object({
tournament_name: t.String({ minLength: 1, maxLength: 128 }),
game_type: t.Enum(GAMETYPE),
max_participants: t.Number(),
start_date: t.Date(),
start_date: t.String(),
hosted_by: t.String({ minLength: 1, maxLength: 128 }),
});

Expand Down
4 changes: 2 additions & 2 deletions src/store/tournament/TournamentStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,15 @@ export interface TournamentState {
tournamentName: string;
gameType: GameType;
maxParticipants: number;
startDate?: Date;
startDate: string;
hostedBy?: string;
}

export const TournamentStore = proxy<TournamentState>({
tournamentName: "Tournament",
gameType: "SOLO",
maxParticipants: 60,
startDate: new Date(),
startDate: new Date().toISOString(),
hostedBy: "admin",
});

Expand Down

0 comments on commit 2a14b0f

Please sign in to comment.