Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/lightertu/TeamDivider
Browse files Browse the repository at this point in the history
  • Loading branch information
lightertu committed Jun 8, 2017
2 parents 3afc538 + cab937a commit 25b0811
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion server/config/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,5 @@ module.exports = {
'secret': 'asdawldjal',
databaseUrl: 'mongodb://teamdivider:[email protected]:37101/teamdivider',
authenticationMiddleware: passport.authenticate('jwt', { session: false }),
SENDGRID_API_KEY: "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",
SENDGRID_API_KEY: process.env.SENDGRID_API_KEY,
};
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@ const ObjectIdIsValid = require("mongoose").Types.ObjectId.isValid;

const Activity = require("../../../models").Activity;

const sendgridAPIKey = require("../../../config/main").SENDGRID_API_KEY;
const sendgrid = require("sendgrid")(sendgridAPIKey);
const mailHelper = require('sendgrid').mail;
const sendGridAPIKey = require("../../../config/main").SENDGRID_API_KEY;



function groupParticipantsByGroupNumber (pars) {
Expand Down Expand Up @@ -75,6 +74,13 @@ module.exports = function (req, res, next) {
createErrorHandler(res, HttpStatus.BAD_REQUEST)(errorMessage);
return;
}
if (typeof sendGridAPIKey === 'undefined' || sendGridAPIKey === null){
const errorMessage = 'Server terminal does not have the environment variable "SENDGRID_API_KEY". Please run the related bash script first.';
createErrorHandler(res, HttpStatus.INTERNAL_SERVER_ERROR)(errorMessage);
return;
}
const sendGrid = require("sendgrid")(sendGridAPIKey);
const mailHelper = require('sendgrid').mail;

Activity.findOne({_id: req.params.activityId, _creator: req.user._id, isDeleted: false})
.populate({
Expand All @@ -101,13 +107,13 @@ module.exports = function (req, res, next) {
const content = new mailHelper.Content('text/html', generateHTMLText(member, group, activity));
const email = new mailHelper.Mail(from_email, subject, to_email, content);

const emailRequest = sendgrid.emptyRequest({
const emailRequest = sendGrid.emptyRequest({
method: 'POST',
path: '/v3/mail/send',
body: email.toJSON()
});

sendgrid.API(emailRequest, function (error, response) {
sendGrid.API(emailRequest, function (error, response) {
if (error !== null){
console.log(error);
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ export default class EditActivityInfoModal extends React.Component {
return;
}

if (this.props.activityHolder.get('currentCapacity') >=
this.props.activityHolder.get('totalCapacity')) {
this.props.updateActivityFailedToEdit(true);
this.props.updateActivityEditError('TOTAL CAPACITY MUST NOT BE BIGGER THAN CURRENT CAPACITY');
return;
}

this.props.updateActivityFailedToEdit(false);
this.props.updateActivityEditError('');
Expand Down Expand Up @@ -80,8 +86,8 @@ export default class EditActivityInfoModal extends React.Component {
Cancel
</Button>
<Button positive
disabled={this.props.isCreating}
loading={this.props.isCreating}
disabled={this.props.isLoading}
loading={this.props.isLoading}
content='Save Changes'
onClick={ this.updateActivityHandler }
/>
Expand Down

0 comments on commit 25b0811

Please sign in to comment.