Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Navneeth create see teams management tab custom permission #556

2 changes: 1 addition & 1 deletion src/controllers/badgeController.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const badgeController = function (Badge) {
record.badgeCollection = req.body.badgeCollection;

if (cache.hasCache(`user-${userToBeAssigned}`)) cache.removeCache(`user-${userToBeAssigned}`);

record.save()
.then(results => res.status(201).send(results._id))
.catch(errors => res.status(500).send(errors));
Expand Down
90 changes: 46 additions & 44 deletions src/controllers/dashBoardController.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
const path = require("path");
const fs = require("fs/promises");
const mongoose = require("mongoose");
const dashboardhelper = require("../helpers/dashboardhelper")();
const emailSender = require("../utilities/emailSender");
const path = require('path');
const fs = require('fs/promises');
const mongoose = require('mongoose');
const dashboardhelper = require('../helpers/dashboardhelper')();
const emailSender = require('../utilities/emailSender');

const dashboardcontroller = function () {
const dashboarddata = function (req, res) {
Expand All @@ -20,13 +20,13 @@ const dashboardcontroller = function () {
const laborthismonth = dashboardhelper.laborthismonth(
userId,
req.params.fromDate,
req.params.toDate
req.params.toDate,
);
laborthismonth.then((results) => {
if (!results || results.length === 0) {
const emptyresult = [
{
projectName: "",
projectName: '',
timeSpent_hrs: 0,
},
];
Expand All @@ -42,7 +42,7 @@ const dashboardcontroller = function () {
const laborthisweek = dashboardhelper.laborthisweek(
userId,
req.params.fromDate,
req.params.toDate
req.params.toDate,
);
laborthisweek.then((results) => {
res.send(results).status(200);
Expand All @@ -63,7 +63,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 @@ -73,7 +73,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 @@ -85,7 +85,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 @@ -130,32 +130,32 @@ const dashboardcontroller = function () {
expected,
actual,
visual,
severity
severity,
);

try {
emailSender(
"[email protected]",
'[email protected]',
`Bug Rport from ${firstName} ${lastName}`,
emailBody,
email
email,
);
res.status(200).send("Success");
res.status(200).send('Success');
} catch {
res.status(500).send("Failed");
res.status(500).send('Failed');
}
};

const suggestionData = {
suggestion: [
"Identify and remedy poor client and/or user service experiences",
"Identify bright spots and enhance positive service experiences",
"Make fundamental changes to our programs and/or operations",
"Inform the development of new programs/projects",
"Identify where we are less inclusive or equitable across demographic groups",
"Strengthen relationships with the people we serve",
'Identify and remedy poor client and/or user service experiences',
'Identify bright spots and enhance positive service experiences',
'Make fundamental changes to our programs and/or operations',
'Inform the development of new programs/projects',
'Identify where we are less inclusive or equitable across demographic groups',
'Strengthen relationships with the people we serve',
"Understand people's needs and how we can help them achieve their goals",
"Other",
'Other',
],
field: [],
};
Expand All @@ -164,8 +164,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 All @@ -178,7 +178,7 @@ const dashboardcontroller = function () {
<p>${args[0]}</p>
<b> &#9913; Suggestion:</b>
<p>${args[1]}</p>
${fieldaaray.length > 0 ? fieldaaray : ""}
${fieldaaray.length > 0 ? fieldaaray : ''}
<b> &#9913; Name of Suggester:</b>
<p>${args[3].firstName} ${args[3].lastName}</p>
<b> &#9913; Email of Suggester:</b>
Expand All @@ -193,27 +193,29 @@ 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(
"[email protected]",
"A new suggestion",
'[email protected]',
'A new suggestion',
emailBody,
null,
null,
email,
null
);
res.status(200).send("Success");
res.status(200).send('Success');
} catch {
res.status(500).send("Failed");
res.status(500).send('Failed');
}
};

Expand All @@ -222,40 +224,40 @@ const dashboardcontroller = function () {
if (suggestionData) {
res.status(200).send(suggestionData);
} else {
res.status(404).send("Suggestion data not found.");
res.status(404).send('Suggestion data not found.');
}
} catch (error) {
console.error("Error getting suggestion data:", error);
res.status(500).send("Internal Server Error");
console.error('Error getting suggestion data:', error);
res.status(500).send('Internal Server Error');
}
};

const editSuggestionOption = async (req, res) => {
try {
if (req.body.suggestion) {
if (req.body.action === "add") {
if (req.body.action === 'add') {
suggestionData.suggestion.unshift(req.body.newField);
}
if (req.body.action === "delete") {
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 {
if (req.body.action === "add") {
if (req.body.action === 'add') {
suggestionData.field.unshift(req.body.newField);
}
if (req.body.action === "delete") {
if (req.body.action === 'delete') {
suggestionData.field = suggestionData.field.filter(
(item) => item !== req.body.newField
item => item !== req.body.newField,
);
}
}

res.status(200).send("success");
res.status(200).send('success');
} catch (error) {
console.error("Error editing suggestion option:", error);
res.status(500).send("Internal Server Error");
console.error('Error editing suggestion option:', error);
res.status(500).send('Internal Server Error');
}
};

Expand Down
22 changes: 10 additions & 12 deletions src/controllers/isEmailExistsController.js
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
const UserProfile = require('../models/userProfile');

const isEmailExistsController = function () {

const isEmailExists = async function (req, res) {

try {
const userProfile = await UserProfile.findOne({ email: req.params.email }).lean().exec()
try {
const userProfile = await UserProfile.findOne({ email: req.params.email }).lean().exec();

if (userProfile) {
res.status(200).send(`Email, ${userProfile.email}, found.`)
res.status(200).send(`Email, ${userProfile.email}, found.`);
} else {
res.status(403).send(`Email, ${req.params.email}, not found.`)
res.status(403).send(`Email, ${req.params.email}, not found.`);
}
} catch (err) {
console.log(err)
console.log(err);
}
}
};

return {
isEmailExists
}
}
isEmailExists,
};
};

module.exports = isEmailExistsController
module.exports = isEmailExistsController;
Loading
Loading