Give better error message to TO when can't check-in a team

This commit is contained in:
Kalle 2025-03-08 09:59:51 +02:00
parent edf55abb9f
commit 0cb5f09def
3 changed files with 17 additions and 11 deletions

View File

@ -836,18 +836,21 @@ export class Tournament {
invariant(team, "Team not found");
if (!this.regularCheckInIsOpen && !this.regularCheckInHasEnded) {
return false;
return { isFulfilled: false, reason: "Check in has not yet started" };
}
if (team.members.length < this.minMembersPerTeam) {
return false;
return {
isFulfilled: false,
reason: `Team needs at least ${this.minMembersPerTeam} members`,
};
}
if (this.teamsPrePickMaps && (!team.mapPool || team.mapPool.length === 0)) {
return false;
return { isFulfilled: false, reason: "Team has no map pool set" };
}
return true;
return { isFulfilled: true, reason: null };
}
get isInvitational() {
@ -1163,9 +1166,11 @@ export class Tournament {
}
if (team.checkIns.length === 0 && this.regularCheckInIsOpen) {
const canCheckIn = this.checkInConditionsFulfilledByTeamId(team.id);
return { type: "CHECKIN", canCheckIn } as const;
return {
type: "CHECKIN",
canCheckIn: this.checkInConditionsFulfilledByTeamId(team.id)
.isFulfilled,
} as const;
}
for (const [bracketIdx, bracket] of this.brackets.entries()) {

View File

@ -120,8 +120,8 @@ export const action: ActionFunction = async ({ request, params }) => {
errorToastIfFalsy(team, "Invalid team id");
errorToastIfFalsy(
data.bracketIdx !== 0 ||
tournament.checkInConditionsFulfilledByTeamId(team.id),
"Can't check-in",
tournament.checkInConditionsFulfilledByTeamId(team.id).isFulfilled,
`Can't check-in - ${tournament.checkInConditionsFulfilledByTeamId(team.id).reason}`,
);
errorToastIfFalsy(
team.checkIns.length > 0 || data.bracketIdx === 0,

View File

@ -222,8 +222,9 @@ export const action: ActionFunction = async ({ request, params }) => {
"Check in is not open",
);
errorToastIfFalsy(
tournament.checkInConditionsFulfilledByTeamId(teamMemberOf.id),
"Check in conditions not fulfilled",
tournament.checkInConditionsFulfilledByTeamId(teamMemberOf.id)
.isFulfilled,
`Can't check-in - ${tournament.checkInConditionsFulfilledByTeamId(teamMemberOf.id).reason}`,
);
checkIn(teamMemberOf.id);