Oprava validace délky poznámky
This commit is contained in:
parent
93ba8def03
commit
731fd2eeb9
@ -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 &&
|
||||||
|
@ -97,20 +97,20 @@ 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;
|
||||||
if (note && note.length > 70) {
|
|
||||||
throw Error("Poznámka může mít maximálně 70 znaků");
|
|
||||||
}
|
|
||||||
let date = undefined;
|
|
||||||
if (req.body.dayIndex != null) {
|
|
||||||
let dayIndex;
|
|
||||||
try {
|
|
||||||
dayIndex = parseValidateFutureDayIndex(req);
|
|
||||||
} catch (e: any) {
|
|
||||||
return res.status(400).json({ error: e.message });
|
|
||||||
}
|
|
||||||
date = getDateForWeekIndex(dayIndex);
|
|
||||||
}
|
|
||||||
try {
|
try {
|
||||||
|
if (note && note.length > 70) {
|
||||||
|
throw Error("Poznámka může mít maximálně 70 znaků");
|
||||||
|
}
|
||||||
|
let date = undefined;
|
||||||
|
if (req.body.dayIndex != null) {
|
||||||
|
let dayIndex;
|
||||||
|
try {
|
||||||
|
dayIndex = parseValidateFutureDayIndex(req);
|
||||||
|
} catch (e: any) {
|
||||||
|
return res.status(400).json({ error: e.message });
|
||||||
|
}
|
||||||
|
date = getDateForWeekIndex(dayIndex);
|
||||||
|
}
|
||||||
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);
|
||||||
|
@ -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));
|
||||||
if (req.body.note && req.body.note.length > 70) {
|
try {
|
||||||
throw Error("Poznámka může mít maximálně 70 znaků");
|
if (req.body.note && req.body.note.length > 70) {
|
||||||
}
|
throw Error("Poznámka může mít maximálně 70 znaků");
|
||||||
const data = await updatePizzaDayNote(login, req.body.note);
|
}
|
||||||
getWebsocket().emit("message", await addVolatileData(data));
|
const data = await updatePizzaDayNote(login, req.body.note);
|
||||||
res.status(200).json(data);
|
getWebsocket().emit("message", await addVolatileData(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) => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user