Serverová validace času odchodu

This commit is contained in:
2023-09-24 08:38:40 +02:00
parent c286bd1778
commit e4451e299a
4 changed files with 38 additions and 24 deletions

View File

@@ -293,7 +293,7 @@ app.post("/api/updatePizzaDayNote", async (req, res) => {
res.status(200).json(data);
});
app.post("/api/changeDepartureTime", async (req, res) => {
app.post("/api/changeDepartureTime", async (req, res, next) => {
const login = getLogin(parseToken(req));
let date = undefined;
if (req.body.dayIndex != null) {
@@ -305,9 +305,11 @@ app.post("/api/changeDepartureTime", async (req, res) => {
}
date = getDateForWeekIndex(dayIndex);
}
const data = await updateDepartureTime(login, req.body?.time, date);
io.emit("message", data);
res.status(200).json(data);
try {
const data = await updateDepartureTime(login, req.body?.time, date);
io.emit("message", data);
res.status(200).json(data);
} catch (e: any) { next(e) }
});
// Middleware pro zpracování chyb