2016-11-01 14:21:35 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2016-11-09 12:09:22 -03:00
|
|
|
angular.module('copayApp.controllers').controller('sendFeedbackController', function($scope, $state, $log, $stateParams, gettextCatalog, popupService, configService, lodash, feedbackService, ongoingProcess) {
|
2016-11-01 14:21:35 -03:00
|
|
|
$scope.score = parseInt($stateParams.score);
|
|
|
|
|
switch ($scope.score) {
|
|
|
|
|
case 1:
|
|
|
|
|
$scope.reaction = gettextCatalog.getString("Ouch!");
|
2016-11-03 13:39:01 -03:00
|
|
|
$scope.comment = gettextCatalog.getString("There's obviously something we're doing wrong.");
|
2016-11-01 14:21:35 -03:00
|
|
|
break;
|
|
|
|
|
case 2:
|
|
|
|
|
$scope.reaction = gettextCatalog.getString("Oh no!");
|
2016-11-03 13:39:01 -03:00
|
|
|
$scope.comment = gettextCatalog.getString("There's obviously something we're doing wrong.");
|
2016-11-01 14:21:35 -03:00
|
|
|
break;
|
|
|
|
|
case 3:
|
|
|
|
|
$scope.reaction = gettextCatalog.getString("Thanks!");
|
2016-11-03 13:39:01 -03:00
|
|
|
$scope.comment = gettextCatalog.getString("We're always looking for ways to improve BitPay wallet.");
|
2016-11-01 14:21:35 -03:00
|
|
|
break;
|
|
|
|
|
case 4:
|
|
|
|
|
$scope.reaction = gettextCatalog.getString("Thanks!");
|
2016-11-08 15:13:28 -03:00
|
|
|
$scope.comment = gettextCatalog.getString("That's exciting to hear. We'd love to earn that fifth star from you.");
|
2016-11-01 14:21:35 -03:00
|
|
|
break;
|
|
|
|
|
case 5:
|
|
|
|
|
$scope.reaction = gettextCatalog.getString("Feedback!");
|
2016-11-03 13:39:01 -03:00
|
|
|
$scope.comment = gettextCatalog.getString("We're always looking for ways to improve BitPay wallet.");
|
2016-11-01 14:21:35 -03:00
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2016-11-08 11:49:03 -03:00
|
|
|
$scope.sendFeedback = function(feedback, skip) {
|
2016-11-07 17:31:13 -03:00
|
|
|
|
|
|
|
|
var config = configService.getSync();
|
2016-11-09 12:09:22 -03:00
|
|
|
|
2016-11-07 17:31:13 -03:00
|
|
|
var dataSrc = {
|
2016-11-09 12:09:22 -03:00
|
|
|
"Email": lodash.values(config.emailFor)[0] || ' ',
|
|
|
|
|
"Feedback": skip ? ' ' : feedback,
|
|
|
|
|
"Score": $stateParams.score
|
2016-11-07 17:31:13 -03:00
|
|
|
};
|
|
|
|
|
|
2016-11-09 12:09:22 -03:00
|
|
|
ongoingProcess.set('sendingFeedback', true);
|
|
|
|
|
feedbackService.send(dataSrc, function(err) {
|
|
|
|
|
ongoingProcess.set('sendingFeedback', false);
|
|
|
|
|
if (err) {
|
|
|
|
|
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Could not send feedback'));
|
|
|
|
|
return;
|
|
|
|
|
}
|
2016-11-08 11:49:03 -03:00
|
|
|
$state.go('feedback.thanks', {
|
|
|
|
|
score: $stateParams.score,
|
|
|
|
|
skipped: skip
|
|
|
|
|
});
|
2016-11-01 14:21:35 -03:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|