feat: zobrazení minulého týdne o víkendu místo "Užívejte víkend" (#30)

Na víkendu se nyní zobrazuje páteční menu s možností procházet celý týden.
Editační ovládací prvky jsou automaticky skryté díky existující logice canChangeChoice.
This commit is contained in:
2026-02-04 14:54:26 +01:00
parent 2b7197eff6
commit fdd42dc46a
2 changed files with 12 additions and 4 deletions

View File

@@ -461,7 +461,12 @@ function App() {
{easterEgg && eggImage && <img ref={eggRef} alt='' src={URL.createObjectURL(eggImage)} style={{ position: 'absolute', ...EASTER_EGG_STYLE, ...style, animationDuration: `${duration ?? EASTER_EGG_DEFAULT_DURATION}s` }} />}
<Header />
<div className='wrapper'>
{data.isWeekend ? <h4>Užívejte víkend :)</h4> : <>
{data.todayDayIndex != null && data.todayDayIndex > 4 &&
<Alert variant="info" className="mb-3">
Zobrazujete uplynulý týden
</Alert>
}
<>
{dayIndex != null &&
<div className='day-navigator'>
<span title='Předchozí den'>
@@ -724,7 +729,7 @@ function App() {
</div>
}
</div>
</> || "Jejda, něco se nám nepovedlo :("}
</>
</div>
{/* <FallingLeaves
numLeaves={LEAF_PRESETS.NORMAL}

View File

@@ -1,12 +1,12 @@
import express from "express";
import bodyParser from "body-parser";
import cors from 'cors';
import { getData, getDateForWeekIndex } from "./service";
import { getData, getDateForWeekIndex, getToday } from "./service";
import dotenv from 'dotenv';
import path from 'path';
import { getQr } from "./qr";
import { generateToken, verify } from "./auth";
import { InsufficientPermissions } from "./utils";
import { getIsWeekend, InsufficientPermissions } from "./utils";
import { initWebsocket } from "./websocket";
import pizzaDayRoutes from "./routes/pizzaDayRoutes";
import foodRoutes, { refreshMetoda } from "./routes/foodRoutes";
@@ -133,6 +133,9 @@ app.get("/api/data", async (req, res) => {
if (!isNaN(index)) {
date = getDateForWeekIndex(parseInt(req.query.dayIndex));
}
} else if (getIsWeekend(getToday())) {
// Na víkendu zobrazíme pátek místo hlášky "Užívejte víkend"
date = getDateForWeekIndex(4);
}
res.status(200).json(await getData(date));
});