Oprava validace délky poznámky

This commit is contained in:
Martin Berka 2024-03-24 18:51:38 +01:00
parent 93ba8def03
commit 731fd2eeb9
3 changed files with 23 additions and 26 deletions

View File

@ -214,10 +214,6 @@ function App() {
const saveNote = async (note?: string) => { const saveNote = async (note?: string) => {
if (auth?.login) { if (auth?.login) {
if (note != null && note.length > 70) {
alert("Poznámka může mít maximálně 70 znaků");
return;
}
await errorHandler(() => updateNote(note, dayIndex)); await errorHandler(() => updateNote(note, dayIndex));
setNoteModalOpen(false); setNoteModalOpen(false);
} }
@ -373,8 +369,7 @@ function App() {
<Alert variant={'primary'}> <Alert variant={'primary'}>
Poslední změny: Poslední změny:
<ul> <ul>
<li>Anděloviny</li> <li>Pokus o aktualizaci poznámky s příliš velkou délkou již neshazuje server</li>
<li>Zamezení posunů mezi dny šipkami v inputech</li>
</ul> </ul>
</Alert> </Alert>
{dayIndex != null && {dayIndex != null &&

View File

@ -97,6 +97,7 @@ router.post("/updateNote", async (req, res, next) => {
const login = getLogin(parseToken(req)); const login = getLogin(parseToken(req));
const trusted = getTrusted(parseToken(req)); const trusted = getTrusted(parseToken(req));
const note = req.body.note; const note = req.body.note;
try {
if (note && note.length > 70) { if (note && note.length > 70) {
throw Error("Poznámka může mít maximálně 70 znaků"); throw Error("Poznámka může mít maximálně 70 znaků");
} }
@ -110,7 +111,6 @@ router.post("/updateNote", async (req, res, next) => {
} }
date = getDateForWeekIndex(dayIndex); date = getDateForWeekIndex(dayIndex);
} }
try {
const data = await updateNote(login, trusted, note, date); const data = await updateNote(login, trusted, note, date);
getWebsocket().emit("message", await addVolatileData(data)); getWebsocket().emit("message", await addVolatileData(data));
res.status(200).json(data); res.status(200).json(data);

View File

@ -85,14 +85,16 @@ router.post("/finishDelivery", async (req, res) => {
res.status(200).json({}); res.status(200).json({});
}); });
router.post("/updatePizzaDayNote", async (req, res) => { router.post("/updatePizzaDayNote", async (req, res, next) => {
const login = getLogin(parseToken(req)); const login = getLogin(parseToken(req));
try {
if (req.body.note && req.body.note.length > 70) { if (req.body.note && req.body.note.length > 70) {
throw Error("Poznámka může mít maximálně 70 znaků"); throw Error("Poznámka může mít maximálně 70 znaků");
} }
const data = await updatePizzaDayNote(login, req.body.note); const data = await updatePizzaDayNote(login, req.body.note);
getWebsocket().emit("message", await addVolatileData(data)); getWebsocket().emit("message", await addVolatileData(data));
res.status(200).json(data); res.status(200).json(data);
} catch (e: any) { next(e) }
}); });
router.post("/updatePizzaFee", async (req, res, next) => { router.post("/updatePizzaFee", async (req, res, next) => {