Skip to content

Commit 49356d6

Browse files
committed
fix: review comments
1 parent 5fbd197 commit 49356d6

File tree

3 files changed

+11
-8
lines changed

3 files changed

+11
-8
lines changed

src/constants.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,10 @@ export const CONNECT_NOTIFICATION_EVENT = {
307307
EXTERNAL_ACTION_EMAIL: 'external.action.email',
308308
};
309309

310+
export const TEMPLATE_IDS = {
311+
APPLY_COPILOT: 'd-d7c1f48628654798a05c8e09e52db14f',
312+
CREATE_REQUEST: 'd-3efdc91da580479d810c7acd50a4c17f'
313+
}
310314
export const REGEX = {
311315
URL: /^(http(s?):\/\/)?(www\.)?[a-zA-Z0-9\.\-\_]+(\.[a-zA-Z]{2,15})+(\:[0-9]{2,5})?(\/[a-zA-Z0-9\_\-\s\.\/\?\%\#\&\=;]*)?$/, // eslint-disable-line
312316
};

src/routes/copilotOpportunityApply/create.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import config from 'config';
66
import models from '../../models';
77
import util from '../../util';
88
import { PERMISSION } from '../../permissions/constants';
9-
import { CONNECT_NOTIFICATION_EVENT, COPILOT_OPPORTUNITY_STATUS } from '../../constants';
9+
import { CONNECT_NOTIFICATION_EVENT, COPILOT_OPPORTUNITY_STATUS, TEMPLATE_IDS, USER_ROLE } from '../../constants';
1010
import { createEvent } from '../../services/busApi';
1111

1212
const applyCopilotRequestValidations = {
@@ -68,13 +68,13 @@ module.exports = [
6868

6969
return models.CopilotApplication.create(data)
7070
.then(async (result) => {
71-
const pmRole = await util.getRolesByRoleName('Project Manager', req.log, req.id);
71+
const pmRole = await util.getRolesByRoleName(USER_ROLE.PROJECT_MANAGER, req.log, req.id);
7272
const { subjects = [] } = await util.getRoleInfo(pmRole[0], req.log, req.id);
7373

7474
const creator = await util.getMemberDetailsByUserIds([opportunity.userId], req.log, req.id);
7575
const listOfSubjects = subjects;
7676
if (creator) {
77-
const isCreatorPartofSubjects = subjects.find(item => item.email === creator[0].email);
77+
const isCreatorPartofSubjects = subjects.find(item => item.email.toLowerCase() === creator[0].email.toLowerCase());
7878
if (!isCreatorPartofSubjects) {
7979
listOfSubjects.push({
8080
email: creator[0].email,
@@ -91,7 +91,7 @@ module.exports = [
9191
user_name: subject.handle,
9292
opportunity_details_url: `${copilotPortalUrl}/opportunity/${opportunity.id}#applications`,
9393
},
94-
sendgrid_template_id: "d-d7c1f48628654798a05c8e09e52db14f",
94+
sendgrid_template_id: TEMPLATE_IDS.APPLY_COPILOT,
9595
recipients: [subject.email],
9696
version: 'v3',
9797
}, req.log);

src/routes/copilotRequest/approveRequest.service.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import _ from 'lodash';
22
import config from 'config';
33

44
import models from '../../models';
5-
import { CONNECT_NOTIFICATION_EVENT, COPILOT_REQUEST_STATUS } from '../../constants';
5+
import { CONNECT_NOTIFICATION_EVENT, COPILOT_REQUEST_STATUS, TEMPLATE_IDS, USER_ROLE } from '../../constants';
66
import util from '../../util';
77
import { createEvent } from '../../services/busApi';
88

@@ -56,19 +56,18 @@ module.exports = (req, data, existingTransaction) => {
5656
.create(data, { transaction });
5757
}))
5858
.then(async (opportunity) => {
59-
const roles = await util.getRolesByRoleName('copilot', req.log, req.id);
59+
const roles = await util.getRolesByRoleName(USER_ROLE.TC_COPILOT, req.log, req.id);
6060
const { subjects = [] } = await util.getRoleInfo(roles[0], req.log, req.id);
6161
const emailEventType = CONNECT_NOTIFICATION_EVENT.EXTERNAL_ACTION_EMAIL;
6262
const copilotPortalUrl = config.get('copilotPortalUrl');
6363
req.log.info("Sending emails to all copilots about new opportunity");
6464
subjects.forEach(subject => {
65-
req.log.info("Each copilot members", subject);
6665
createEvent(emailEventType, {
6766
data: {
6867
user_name: subject.handle,
6968
opportunity_details_url: `${copilotPortalUrl}/opportunity/${opportunity.id}`,
7069
},
71-
sendgrid_template_id: "d-3efdc91da580479d810c7acd50a4c17f",
70+
sendgrid_template_id: TEMPLATE_IDS.CREATE_REQUEST,
7271
recipients: [subject.email],
7372
version: 'v3',
7473
}, req.log);

0 commit comments

Comments
 (0)