-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #623 from OneCommunityGlobal/xiaow_hotfix_of_canno…
…t_create_team XiaoW_Hot fix of cannot create new team
- Loading branch information
Showing
4 changed files
with
67 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { | ||
|
@@ -11,7 +11,7 @@ const dashboardcontroller = function () { | |
const snapshot = dashboardhelper.personaldetails(userId); | ||
|
||
snapshot.then((results) => { | ||
res.send(results).status(200); | ||
res.status(200).send(results); | ||
}); | ||
}; | ||
|
||
|
@@ -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, | ||
}, | ||
]; | ||
|
@@ -42,10 +42,10 @@ 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); | ||
res.status(200).send(results); | ||
}); | ||
}; | ||
|
||
|
@@ -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) { | ||
|
@@ -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 ( | ||
|
@@ -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> | ||
|
@@ -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, | ||
); | ||
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: [], | ||
}; | ||
|
@@ -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} ${ | ||
|
@@ -178,7 +178,7 @@ const dashboardcontroller = function () { | |
<p>${args[0]}</p> | ||
<b> ⚹ Suggestion:</b> | ||
<p>${args[1]}</p> | ||
${fieldaaray.length > 0 ? fieldaaray : ""} | ||
${fieldaaray.length > 0 ? fieldaaray : ''} | ||
<b> ⚹ Name of Suggester:</b> | ||
<p>${args[3].firstName} ${args[3].lastName}</p> | ||
<b> ⚹ Email of Suggester:</b> | ||
|
@@ -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, | ||
); | ||
try { | ||
emailSender( | ||
"[email protected]", | ||
"A new suggestion", | ||
'[email protected]', | ||
'A new suggestion', | ||
emailBody, | ||
null, | ||
null, | ||
email, | ||
null | ||
null, | ||
); | ||
res.status(200).send("Success"); | ||
res.status(200).send('Success'); | ||
} catch { | ||
res.status(500).send("Failed"); | ||
res.status(500).send('Failed'); | ||
} | ||
}; | ||
|
||
|
@@ -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'); | ||
} | ||
}; | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters