diff --git a/hooks/team-splitter/helpers.ts b/hooks/team-splitter/helpers.ts index eaed4fb07..f1ba6207a 100644 --- a/hooks/team-splitter/helpers.ts +++ b/hooks/team-splitter/helpers.ts @@ -1,4 +1,5 @@ import { shuffleArray } from "utils/arrays"; +import { Player, Match } from "./types"; const choosePlayersToSitOut = ( players: Player[] diff --git a/hooks/team-splitter/index.ts b/hooks/team-splitter/index.ts index 27c025452..6a723dd13 100644 --- a/hooks/team-splitter/index.ts +++ b/hooks/team-splitter/index.ts @@ -1,5 +1,6 @@ import { useEffect, useReducer } from "react"; import { createNewMatch, teamsShouldChange, errorWithPlayers } from "./helpers"; +import { State, Action } from "./types"; const DEFAULT_AMOUNT_OF_ROUNDS_WITH_SAME_TEAMS = 2; diff --git a/hooks/team-splitter/types.ts b/hooks/team-splitter/types.ts index 7058a39c3..0ab2360e2 100644 --- a/hooks/team-splitter/types.ts +++ b/hooks/team-splitter/types.ts @@ -1,4 +1,4 @@ -interface Player { +export interface Player { id: number; name: string; winCount: number; @@ -6,14 +6,14 @@ interface Player { sittingOutCount: number; } -type Match = { +export type Match = { alpha: string[]; bravo: string[]; spectators: string[]; winner?: "alpha" | "bravo"; }; -interface State { +export interface State { players: Player[]; matches: Match[]; amountOfRoundsWithSameTeams: number; @@ -21,9 +21,7 @@ interface State { noPlacingToSameTeam: [playerOneId?: number, playerTwoId?: number]; } -// TODO: names must be unique - -type Action = +export type Action = | { type: "SET_PLAYER"; name: string;