-
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 branch 'development' into shivansh_custom_blue_tick_email_for_c…
…ore_team
- Loading branch information
Showing
50 changed files
with
5,683 additions
and
1,917 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
{"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","Understand people's needs and how we can help them achieve their goals","Other"],"field":[]} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,6 @@ | ||
const mongoose = require('mongoose'); | ||
const path = require('path'); | ||
const fs = require('fs/promises'); | ||
const dashboardhelper = require('../helpers/dashboardhelper')(); | ||
const emailSender = require('../utilities/emailSender'); | ||
|
||
|
@@ -83,7 +85,7 @@ const dashboardcontroller = function () { | |
const { | ||
firstName, lastName, title, environment, reproduction, expected, actual, visual, severity, email, | ||
} = req.body; | ||
const emailBody = getBugReportEmailBody(firstName, lastName, title, environment, reproduction, expected, actual, visual, severity); | ||
const emailBody = getBugReportEmailBody(firstName, lastName, title, environment, reproduction, expected, actual, visual, severity); | ||
|
||
try { | ||
emailSender( | ||
|
@@ -97,7 +99,82 @@ const dashboardcontroller = function () { | |
res.status(500).send('Failed'); | ||
} | ||
}; | ||
// read suggestion data from file | ||
const readSuggestionFile = async () => { | ||
const filepath = path.join(process.cwd(), 'src', 'constants', 'suggestionModalData.json'); | ||
let readfile = await fs.readFile(filepath).catch(err => console.log(err)); | ||
readfile = JSON.parse(readfile); | ||
return readfile; | ||
}; | ||
// create suggestion emailbody | ||
const getsuggestionEmailBody = async (...args) => { | ||
const readfile = await readSuggestionFile(); | ||
let fieldaaray = []; | ||
if (readfile.field.length) { | ||
fieldaaray = readfile.field.map(item => `<p>${item}</p> | ||
<p>${args[3][item]}</p>`); | ||
} | ||
const text = `New Suggestion: | ||
<p>Suggestion Category:</p> | ||
<p>${args[0]}</p> | ||
<p>Suggestion:</p> | ||
<p>${args[1]}</p> | ||
${fieldaaray.length > 0 ? fieldaaray : ''} | ||
<p>Wants Feedback:</p> | ||
<p>${args[2]}</p> | ||
<p>Thank you,<br /> | ||
One Community</p>`; | ||
|
||
return text; | ||
}; | ||
|
||
// send suggestion email | ||
const sendMakeSuggestion = async (req, res) => { | ||
const { | ||
suggestioncate, suggestion, confirm, ...rest | ||
} = req.body; | ||
const emailBody = await getsuggestionEmailBody(suggestioncate, suggestion, confirm, rest); | ||
try { | ||
emailSender( | ||
'[email protected]', | ||
'A new suggestion', | ||
emailBody, | ||
); | ||
res.status(200).send('Success'); | ||
} catch { | ||
res.status(500).send('Failed'); | ||
} | ||
}; | ||
|
||
|
||
const getSuggestionOption = async (req, res) => { | ||
const readfile = await readSuggestionFile(); | ||
res.status(200).send(readfile); | ||
}; | ||
// add new suggestion category or field | ||
const editSuggestionOption = async (req, res) => { | ||
let readfile = await readSuggestionFile(); | ||
if (req.body.suggestion) { | ||
if (req.body.action === 'add') readfile.suggestion.unshift(req.body.newField); | ||
if (req.body.action === 'delete') { | ||
readfile = { | ||
...readfile, | ||
suggestion: readfile.suggestion.filter((item, index) => index + 1 !== +req.body.newField), | ||
}; | ||
} | ||
} else { | ||
if (req.body.action === 'add') readfile.field.unshift(req.body.newField); | ||
if (req.body.action === 'delete') { | ||
readfile = { | ||
...readfile, | ||
field: readfile.field.filter(item => item !== req.body.newField), | ||
}; | ||
} | ||
} | ||
const filepath = path.join(process.cwd(), 'src', 'constants', 'suggestionModalData.json'); | ||
await fs.writeFile(filepath, JSON.stringify(readfile)).catch(err => console.log(err)); | ||
res.status(200).send('success'); | ||
}; | ||
|
||
return { | ||
dashboarddata, | ||
|
@@ -106,6 +183,9 @@ const dashboardcontroller = function () { | |
leaderboarddata, | ||
orgData, | ||
sendBugReport, | ||
getSuggestionOption, | ||
editSuggestionOption, | ||
sendMakeSuggestion, | ||
}; | ||
}; | ||
|
||
|
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 |
---|---|---|
@@ -0,0 +1,54 @@ | ||
const mongoose = require('mongoose'); | ||
// const userProfile = require('../models/userProfile'); | ||
// const hasPermission = require('../utilities/permissions'); | ||
const escapeRegex = require('../utilities/escapeRegex'); | ||
|
||
|
||
const informationController = function (Information) { | ||
const getInformations = function (req, res) { | ||
Information.find({}, 'infoName infoContent visibility') | ||
.then(results => res.status(200).send(results)) | ||
.catch(error => res.status(404).send(error)); | ||
}; | ||
|
||
|
||
const addInformation = function (req, res) { | ||
Information.find({ infoName: { $regex: escapeRegex(req.body.infoName), $options: 'i' } }) | ||
.then((result) => { | ||
if (result.length > 0) { | ||
res.status(400).send({ error: `Info Name must be unique. Another infoName with name ${result[0].infoName} already exists. Please note that info names are case insensitive` }); | ||
return; | ||
} | ||
const _info = new Information(); | ||
_info.infoName = req.body.infoName; | ||
_info.infoContent = req.body.infoContent || 'Unspecified'; | ||
_info.visibility = req.body.visibility || '0'; | ||
_info.save() | ||
.then(newInformation => res.status(201).send(newInformation)) | ||
.catch(error => res.status(400).send(error)); | ||
}) | ||
.catch(error => res.status(500).send({ error })); | ||
}; | ||
const deleteInformation = function (req, res) { | ||
Information.findOneAndDelete({ _id: req.params.id }) | ||
.then(deletedInformation => res.status(200).send(deletedInformation)) | ||
.catch(error => res.status(400).send(error)); | ||
}; | ||
|
||
// Update existing information by id | ||
const updateInformation = function (req, res) { | ||
Information.findOneAndUpdate({ _id: req.params.id }, req.body, { new: true }) | ||
.then(updatedInformation => res.status(200).send(updatedInformation)) | ||
.catch(error => res.status(400).send(error)); | ||
}; | ||
|
||
return { | ||
getInformations, | ||
addInformation, | ||
updateInformation, | ||
deleteInformation, | ||
}; | ||
}; | ||
|
||
|
||
module.exports = informationController; |
Oops, something went wrong.