feat: show pending messages in appbar

This commit is contained in:
canove
2020-08-25 12:24:19 -03:00
parent ea4ff654ff
commit 6e8eba1187
11 changed files with 255 additions and 469 deletions

View File

@@ -13,12 +13,14 @@ exports.index = async (req, res) => {
status = "",
date = "",
searchParam = "",
showAll,
} = req.query;
const userId = req.userId;
const limit = 20;
const offset = limit * (pageNumber - 1);
let whereCondition = {};
let includeCondition = [
{
model: Contact,
@@ -27,16 +29,20 @@ exports.index = async (req, res) => {
},
];
let whereCondition = { userId: userId };
if (showAll === "true") {
whereCondition = {};
}
if (status) {
whereCondition = {
...whereCondition,
status: status,
};
}
// else if (status === "closed") {
// whereCondition = { ...whereCondition, status: "closed" };
// }
else if (searchParam) {
if (searchParam) {
includeCondition = [
...includeCondition,
{
@@ -56,7 +62,6 @@ exports.index = async (req, res) => {
];
whereCondition = {
...whereCondition,
[Sequelize.Op.or]: [
{
"$contact.name$": Sequelize.where(

View File

@@ -15,7 +15,7 @@ module.exports = async (req, res, next) => {
if (error) {
return res.status(401).json({ error: "Invalid token" });
}
req.userId = token.userId;
req.userId = result.userId;
// todo >> find user in DB and store in req.user to use latter, or throw an error if user not exists anymore
next();
});