From 05d27b66937e690aeaba773e0e6e3d65a01aa052 Mon Sep 17 00:00:00 2001 From: Martin Berka Date: Tue, 27 Oct 2026 22:02:25 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20neumo=C5=BEnit=20vybrat=20zav=C5=99en?= =?UTF-8?q?=C3=BD=20podnik=20kliknut=C3=ADm=20v=20z=C3=A1hlav=C3=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client/src/App.tsx | 4 +++- server/src/service.ts | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/client/src/App.tsx b/client/src/App.tsx index 37b8bc8..68d7d23 100644 --- a/client/src/App.tsx +++ b/client/src/App.tsx @@ -637,9 +637,11 @@ function App() { } else { content =
Chyba načtení dat
} + // Zavřený podnik nelze vybrat kliknutím na záhlaví + const canSelectLocation = canChangeChoice && !menu?.closed; return
-
doAddClickFoodChoice(location)}> +
canSelectLocation && doAddClickFoodChoice(location)}>

{getLunchChoiceName(location)} diff --git a/server/src/service.ts b/server/src/service.ts index abe761b..1d3da17 100644 --- a/server/src/service.ts +++ b/server/src/service.ts @@ -489,6 +489,7 @@ export async function addChoice(login: string, trusted: boolean, locationKey: Lu if (isRestaurantDisabled(locationKey)) { throw new Error(`Podnik ${locationKey} je dočasně uzavřen`); } + await validateRestaurantOpen(locationKey, usedDate); await validateFoodIndex(locationKey, foodIndex, date); if (!slot || slot === MealSlot.OBED) { @@ -540,6 +541,21 @@ export async function addChoice(login: string, trusted: boolean, locationKey: Lu return data; } +/** + * Ověří, že vybraný podnik má v daný den otevřeno. + * + * @param locationKey vybraná lokalita + * @param date datum, pro které je validace prováděna + */ +async function validateRestaurantOpen(locationKey: LunchChoice, date: Date) { + if (Object.keys(Restaurant).includes(locationKey)) { + const menu = await getRestaurantMenu(locationKey as Restaurant, date); + if (menu.closed) { + throw new Error(`Podnik ${locationKey} má v tento den zavřeno`); + } + } +} + /** * Zvaliduje platnost indexu jídla pro vybranou lokalitu a datum. *