feat: možnost zobrazení objednávek z historie
CI / Generate TypeScript types (push) Successful in 10s
CI / Server unit tests (push) Successful in 20s
CI / Build server (push) Successful in 23s
CI / Build client (push) Successful in 33s
CI / Playwright E2E tests (push) Successful in 1m17s
CI / Build and push Docker image (push) Successful in 41s
CI / Notify (push) Successful in 2s
CI / Generate TypeScript types (push) Successful in 10s
CI / Server unit tests (push) Successful in 20s
CI / Build server (push) Successful in 23s
CI / Build client (push) Successful in 33s
CI / Playwright E2E tests (push) Successful in 1m17s
CI / Build and push Docker image (push) Successful in 41s
CI / Notify (push) Successful in 2s
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
[
|
||||
"Možnost zobrazení objednávek z historie",
|
||||
"Podpora neplatících osob u objednávání",
|
||||
"Zobrazení neuhrazených plateb i na stránce objednávek",
|
||||
"Oprava duplicitního zobrazení QR kódu u Pizza day",
|
||||
|
||||
+9
-1
@@ -161,7 +161,15 @@ app.use("/api/", (req, res, next) => {
|
||||
/** Vrátí data pro aktuální den. */
|
||||
app.get("/api/data", async (req, res) => {
|
||||
let date = undefined;
|
||||
if (req.query.dayIndex != null && typeof req.query.dayIndex === 'string') {
|
||||
if (req.query.date != null && typeof req.query.date === 'string') {
|
||||
// Konkrétní datum (YYYY-MM-DD) – umožňuje načtení historie i mimo aktuální týden
|
||||
const parsed = new Date(`${req.query.date}T00:00:00`);
|
||||
if (isNaN(parsed.getTime())) {
|
||||
return res.status(400).json({ error: 'Neplatné datum' });
|
||||
}
|
||||
// Budoucnost ořízneme na dnešek – do budoucna historii nedává smysl zobrazovat
|
||||
date = parsed.getTime() > getToday().getTime() ? getToday() : parsed;
|
||||
} else if (req.query.dayIndex != null && typeof req.query.dayIndex === 'string') {
|
||||
const index = parseInt(req.query.dayIndex);
|
||||
if (!isNaN(index)) {
|
||||
date = getDateForWeekIndex(parseInt(req.query.dayIndex));
|
||||
|
||||
@@ -40,6 +40,7 @@ export function getEmptyData(date?: Date): ClientData {
|
||||
return {
|
||||
todayDayIndex: getDayOfWeekIndex(getToday()),
|
||||
date: getHumanDate(usedDate),
|
||||
isoDate: formatDate(usedDate),
|
||||
isWeekend: getIsWeekend(usedDate),
|
||||
dayIndex: getDayOfWeekIndex(usedDate),
|
||||
choices: {},
|
||||
@@ -583,6 +584,7 @@ export async function getClientData(date?: Date, slot?: MealSlot): Promise<Clien
|
||||
return {
|
||||
...clientData,
|
||||
todayDayIndex: getDayOfWeekIndex(getToday()),
|
||||
isoDate: formatDate(targetDate),
|
||||
...(slot === MealSlot.EXTRA ? { slot: MealSlot.EXTRA } : {}),
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user