fix: neumožnit vybrat zavřený podnik kliknutím v záhlaví
CI / Generate TypeScript types (push) Successful in 10s
CI / Server unit tests (push) Successful in 30s
CI / Build server (push) Successful in 29s
CI / Build client (push) Successful in 42s
CI / Playwright E2E tests (push) Successful in 1m57s
CI / Build and push Docker image (push) Successful in 46s
CI / Notify (push) Successful in 2s

This commit is contained in:
mates committed 2026-10-27 22:02:25 +01:00
1 parent 882a2f38a7
commit 05d27b6693
2 files changed
+19 -1

No files matched your search

+16
View File
@@ -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.
*