++ aggiunta la prenotazione negli eventi. con la lista degli utenti.

This commit is contained in:
Surya Paolo
2023-04-17 00:11:36 +02:00
parent eea6e63c58
commit 0945f1af08
22 changed files with 636 additions and 157 deletions

View File

@@ -1547,12 +1547,14 @@ router.post('/cmd', authenticate, async (req, res) => {
const cmd = req.body.cmd;
const id = req.body.id;
const tab = req.body.tab;
const num = req.body.num;
const value = req.body.value;
try {
const username = req.user.username;
let ris = null;
let record = null;
if (cmd === shared_consts.CMD_USER.SET_FAVORITE) {
if (tab) {
@@ -1568,16 +1570,29 @@ router.post('/cmd', authenticate, async (req, res) => {
else
ris = await User.removeBookmark(idapp, username, id, tab);
}
} else if (cmd === shared_consts.CMD_USER.SET_SEEN) {
} else if (cmd === shared_consts.CMD_USER.SET_ATTEND) {
if (tab) {
if (value)
ris = await User.addAttend(req, idapp, username, id, tab, num);
else
ris = await User.removeAttend(idapp, username, id, tab);
}
} else if (cmd === shared_consts.CMD_USER.SET_SEEN) {
if (tab) {
if (value) {
ris = await User.addSeen(idapp, username, id, tab);
}
const tabtofind = tools.getNumTabByTable('mybachecas');
if (tab === tabtofind) {
const { MyBacheca } = require('../models/mybacheca');
record = await MyBacheca.getCompleteRecord(idapp, id);
}
}
}
let state = (value && ris && ris.ok === 1) ? 1 : ((!value && ris && ris.ok === 1) ? -1 : 0);
return res.send({ state });
return res.send({ state, record });
} catch (e) {
res.status(400).send();