From 56a222cbf22bab91ac1ef9fde1d0439aee1997a4 Mon Sep 17 00:00:00 2001 From: Kalle <38327916+Sendouc@users.noreply.github.com> Date: Tue, 26 Nov 2024 22:17:03 +0200 Subject: [PATCH] Prevent creation of tournaments without tiebreaker map pool if required by the format selected --- .../calendar/actions/calendar.new.server.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/app/features/calendar/actions/calendar.new.server.ts b/app/features/calendar/actions/calendar.new.server.ts index 4c403cc94..ab6409f00 100644 --- a/app/features/calendar/actions/calendar.new.server.ts +++ b/app/features/calendar/actions/calendar.new.server.ts @@ -324,4 +324,22 @@ export const newCalendarEventActionSchema = z { message: "Tournament must have exactly one date", }, + ) + .refine( + (schema) => { + if (schema.toToolsMode !== "ALL") { + return true; + } + + const maps = schema.pool ? MapPool.toDbList(schema.pool) : []; + + return ( + maps.length === 4 && + rankedModesShort.every((mode) => maps.some((map) => map.mode === mode)) + ); + }, + { + message: + 'Map pool must contain a map for each ranked mode if using "Prepicked by teams - All modes"', + }, );