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

+3 -1
View File
@@ -637,9 +637,11 @@ function App() {
} else { } else {
content = <div className="restaurant-error">Chyba načtení dat</div> content = <div className="restaurant-error">Chyba načtení dat</div>
} }
// Zavřený podnik nelze vybrat kliknutím na záhlaví
const canSelectLocation = canChangeChoice && !menu?.closed;
return <Col md={6} lg className='mt-3'> return <Col md={6} lg className='mt-3'>
<div className="restaurant-card"> <div className="restaurant-card">
<div className="restaurant-header" style={{ cursor: canChangeChoice ? 'pointer' : 'default' }} onClick={() => doAddClickFoodChoice(location)}> <div className="restaurant-header" style={{ cursor: canSelectLocation ? 'pointer' : 'default' }} onClick={() => canSelectLocation && doAddClickFoodChoice(location)}>
<div className="restaurant-header-content"> <div className="restaurant-header-content">
<h3> <h3>
{getLunchChoiceName(location)} {getLunchChoiceName(location)}
+16
View File
@@ -489,6 +489,7 @@ export async function addChoice(login: string, trusted: boolean, locationKey: Lu
if (isRestaurantDisabled(locationKey)) { if (isRestaurantDisabled(locationKey)) {
throw new Error(`Podnik ${locationKey} je dočasně uzavřen`); throw new Error(`Podnik ${locationKey} je dočasně uzavřen`);
} }
await validateRestaurantOpen(locationKey, usedDate);
await validateFoodIndex(locationKey, foodIndex, date); await validateFoodIndex(locationKey, foodIndex, date);
if (!slot || slot === MealSlot.OBED) { if (!slot || slot === MealSlot.OBED) {
@@ -540,6 +541,21 @@ export async function addChoice(login: string, trusted: boolean, locationKey: Lu
return data; 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. * Zvaliduje platnost indexu jídla pro vybranou lokalitu a datum.
* *