Skip to content

Commit

Permalink
Merge pull request #752 from OneCommunityGlobal/development
Browse files Browse the repository at this point in the history
Backend Release to Main [1.44]
  • Loading branch information
one-community authored Feb 17, 2024
2 parents 07ebe2d + 6fd6dfe commit 810f13c
Show file tree
Hide file tree
Showing 14 changed files with 1,153 additions and 794 deletions.
104 changes: 52 additions & 52 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions src/controllers/badgeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,9 @@ const badgeController = function (Badge) {
}
});
} catch (err) {
res.status(500).send(`Internal Error: Badge Collection. ${ err.message}`);
res
.status(500)
.send(`Internal Error: Badge Collection. ${err.message}`);
return;
}
record.badgeCollection = req.body.badgeCollection;
Expand All @@ -111,7 +113,7 @@ const badgeController = function (Badge) {
.catch((err) => {
logger.logException(err);
res.status(500).send('Internal Error: Unable to save the record.');
});
});
});
};

Expand Down
42 changes: 20 additions & 22 deletions src/controllers/dashBoardController.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ const dashboardcontroller = function () {
return User.findOneAndUpdate(
{ _id: req.params.userId },
{ copiedAiPrompt: Date.now() },
{ new: true },
{ new: true }
)
.then((user) => {
if (user) {
res.status(200).send('Copied AI prompt');
res.status(200).send("Copied AI prompt");
} else {
res.status(404).send({ message: 'User not found ' });
res.status(404).send({ message: "User not found " });
}
})
.catch((error) => {
Expand All @@ -51,12 +51,12 @@ const dashboardcontroller = function () {
...req.body,
aIPromptText: req.body.aIPromptText,
modifiedDatetime: Date.now(),
},
}
)
.then(() => {
res.status(200).send("Successfully saved AI prompt.");
})
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
}
};

Expand All @@ -82,15 +82,15 @@ const dashboardcontroller = function () {
});
}
})
.catch(error => res.status(500).send(error));
.catch((error) => res.status(500).send(error));
};

const monthlydata = function (req, res) {
const userId = mongoose.Types.ObjectId(req.params.userId);
const laborthismonth = dashboardhelper.laborthismonth(
userId,
req.params.fromDate,
req.params.toDate,
req.params.toDate
);
laborthismonth.then((results) => {
if (!results || results.length === 0) {
Expand All @@ -112,7 +112,7 @@ const dashboardcontroller = function () {
const laborthisweek = dashboardhelper.laborthisweek(
userId,
req.params.fromDate,
req.params.toDate,
req.params.toDate
);
laborthisweek.then((results) => {
res.status(200).send(results);
Expand All @@ -133,7 +133,7 @@ const dashboardcontroller = function () {
});
}
})
.catch(error => res.status(400).send(error));
.catch((error) => res.status(400).send(error));
};

const orgData = function (req, res) {
Expand All @@ -143,7 +143,7 @@ const dashboardcontroller = function () {
.then((results) => {
res.status(200).send(results[0]);
})
.catch(error => res.status(400).send(error));
.catch((error) => res.status(400).send(error));
};

const getBugReportEmailBody = function (
Expand All @@ -155,7 +155,7 @@ const dashboardcontroller = function () {
expected,
actual,
visual,
severity,
severity
) {
const text = `New Bug Report From <b>${firstName} ${lastName}</b>:
<p>[Feature Name] Bug Title:</p>
Expand Down Expand Up @@ -200,15 +200,15 @@ const dashboardcontroller = function () {
expected,
actual,
visual,
severity,
severity
);

try {
emailSender(
"[email protected]",
`Bug Rport from ${firstName} ${lastName}`,
emailBody,
email,
email
);
res.status(200).send("Success");
} catch {
Expand All @@ -234,8 +234,8 @@ const dashboardcontroller = function () {
let fieldaaray = [];
if (suggestionData.field.length) {
fieldaaray = suggestionData.field.map(
item => `<p>${item}</p>
<p>${args[3][item]}</p>`,
(item) => `<p>${item}</p>
<p>${args[3][item]}</p>`
);
}
const text = `New Suggestion From <b>${args[3].firstName} ${
Expand Down Expand Up @@ -263,15 +263,13 @@ const dashboardcontroller = function () {

// send suggestion email
const sendMakeSuggestion = async (req, res) => {
const {
suggestioncate, suggestion, confirm, email, ...rest
} = req.body;
const { suggestioncate, suggestion, confirm, email, ...rest } = req.body;
const emailBody = await getsuggestionEmailBody(
suggestioncate,
suggestion,
confirm,
rest,
email,
email
);
try {
emailSender(
Expand All @@ -281,7 +279,7 @@ const dashboardcontroller = function () {
null,
null,
email,
null,
null
);
res.status(200).send("Success");
} catch {
Expand Down Expand Up @@ -310,7 +308,7 @@ const dashboardcontroller = function () {
}
if (req.body.action === "delete") {
suggestionData.suggestion = suggestionData.suggestion.filter(
(item, index) => index + 1 !== +req.body.newField,
(item, index) => index + 1 !== +req.body.newField
);
}
} else {
Expand All @@ -319,7 +317,7 @@ const dashboardcontroller = function () {
}
if (req.body.action === "delete") {
suggestionData.field = suggestionData.field.filter(
item => item !== req.body.newField,
(item) => item !== req.body.newField
);
}
}
Expand Down
Loading

0 comments on commit 810f13c

Please sign in to comment.