Skip to content

Commit

Permalink
back - ImpactInfo
Browse files Browse the repository at this point in the history
Fix bug in feedback token
update graphql schema
  • Loading branch information
jsmadja committed Apr 8, 2017
1 parent 8db5dc3 commit f6b3cc6
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 8 deletions.
7 changes: 6 additions & 1 deletion back/queries/feedback_find.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,12 @@
badges
created_at
updated_at
impact
impact {
id
description
created_at
updated_at
}
customer {
id
firstname
Expand Down
7 changes: 6 additions & 1 deletion back/queries/feedback_find_by_token.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
badges
created_at
updated_at
impact
customer {
id
firstname
Expand All @@ -16,5 +15,11 @@
firstname
lastname
}
impact {
id
description
created_at
updated_at
}
}
}
11 changes: 10 additions & 1 deletion back/src/feedback/query.feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,16 @@ const feedback_by_token = {
},
},
resolve(obj, { token }) {
return FeedbackRepository.getFeedbackByToken(token);
let dbFeedback;
return FeedbackRepository.getFeedbackByToken(token)
.then(_feedback => dbFeedback = _feedback)
.then(() => ImpactRepository.getImpact(dbFeedback.impact_id))
.then(impact => dbFeedback.impact = impact)
.then(() => CustomerRepository.getCustomer(dbFeedback.customer_id))
.then(customer => dbFeedback.customer = customer)
.then(() => XebianRepository.getXebian(dbFeedback.xebian_id))
.then(xebian => dbFeedback.xebian = xebian)
.then(() => dbFeedback);
},
};

Expand Down
3 changes: 2 additions & 1 deletion back/src/feedback/type.feedback.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
const Author = require('./type.author');
const ImpactInfo = require('../impact/type.impact.info');
const {
GraphQLObjectType,
GraphQLString,
Expand All @@ -14,7 +15,7 @@ const Feedback = new GraphQLObjectType({
type: new GraphQLNonNull(GraphQLString),
},
impact: {
type: GraphQLJSON,
type: ImpactInfo,
},
comment: {
type: GraphQLString,
Expand Down
26 changes: 26 additions & 0 deletions back/src/impact/type.impact.info.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
const {
GraphQLObjectType,
GraphQLString,
GraphQLNonNull,
} = require('graphql');
const GraphQLDate = require('graphql-date');

const ImpactInfo = new GraphQLObjectType({
name: 'ImpactInfo',
fields: {
id: {
type: new GraphQLNonNull(GraphQLString),
},
description: {
type: new GraphQLNonNull(GraphQLString),
},
created_at: {
type: GraphQLDate,
},
updated_at: {
type: GraphQLDate,
},
},
});

module.exports = ImpactInfo;
2 changes: 1 addition & 1 deletion back/src/mail/templates/invitation-email/html.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<pre>{{impact.description}}</pre>
</p>
<p>
Pourriez-vous vous rendre <a href="https://impact.xebia.fr/feedbacks/{{feedback.token}}">à cette adresse</a>.
Pourriez-vous vous rendre <a href="https://impact.xebia.fr/#/feedbacks/{{feedback.token}}">à cette adresse</a>.
</p>
<p>
Pour en savoir plus sur X-Impact, n'hésite pas à consulter <a href="http://impact.xebia.fr">notre site</a>.
Expand Down
2 changes: 1 addition & 1 deletion back/src/mail/templates/invitation-email/text.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Nous vous invitons à laisser un feedback à {{xebian.firstname}} {{xebian.lastn

{{impact.description}}

Pourriez-vous vous rendre à cette adresse : https://impact.xebia.fr/feedbacks/{{feedback.token}}
Pourriez-vous vous rendre à cette adresse : https://impact.xebia.fr/#/feedbacks/{{feedback.token}}

Pour en savoir plus sur X-Impact, n'hésite pas à consulter <a href="http://impact.xebia.fr">notre site</a>.

Expand Down
4 changes: 3 additions & 1 deletion back/src/monthly-feedback/monthly-feedback.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,14 @@ const MailService = require('../mail/mail.service');
const createAndSendFeedback = (impact) => {
let customer;
let xebian;
let feedback;
return FeedbackRepository.createCustomerFeedback(impact.id, impact.customer_id)
.then(_feedback => feedback = _feedback)
.then(() => CustomerRepository.getCustomer(impact.customer_id))
.then(_customer => customer = _customer)
.then(() => XebianRepository.getXebian(impact.xebian_id))
.then(_xebian => xebian = _xebian)
.then((feedback) => {
.then(() => {
feedback.token = FeedbackRepository.createToken(feedback);
return MailService.send({ to: customer.email, feedback, customer, xebian, impact, template: 'invitation-email' });
});
Expand Down
2 changes: 1 addition & 1 deletion graphql.schema.json

Large diffs are not rendered by default.

0 comments on commit f6b3cc6

Please sign in to comment.