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.
*