2016-11-01 14:21:35 -03:00
|
|
|
'use strict';
|
|
|
|
|
|
2016-11-07 17:31:13 -03:00
|
|
|
angular.module('copayApp.controllers').controller('sendFeedbackController', function($scope, $state, $log, $http, $httpParamSerializer, $stateParams, gettextCatalog, popupService, configService, lodash) {
|
|
|
|
|
var URL = "https://docs.google.com/forms/d/e/1FAIpQLSfHHAKb-CKjQnsuC_36IFaXlGsqLd5tZh79ywNfSADoVsw-gQ/formResponse";
|
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-03 13:39:01 -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-07 17:31:13 -03:00
|
|
|
$scope.sendFeedback = function(feedback) {
|
|
|
|
|
|
|
|
|
|
var config = configService.getSync();
|
|
|
|
|
var dataSrc = {
|
|
|
|
|
"entry.490635314": lodash.values(config.emailFor)[0] || 'no email setted',
|
|
|
|
|
"entry.1447064148": feedback,
|
|
|
|
|
"entry.2142850951": $stateParams.score
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$http(_post(dataSrc)).then(function(data) {
|
|
|
|
|
$log.info("SUCCESS: Feedback sent");
|
|
|
|
|
$state.go('feedback.thanks', {
|
|
|
|
|
score: $stateParams.score,
|
|
|
|
|
skipped: false
|
|
|
|
|
});
|
|
|
|
|
}, function(data) {
|
|
|
|
|
$log.info("Could not send feedback");
|
|
|
|
|
popupService.showAlert(gettextCatalog.getString("Error"), gettextCatalog.getString("Could not send feedback, try again please"));
|
2016-11-01 14:21:35 -03:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
2016-11-07 17:31:13 -03:00
|
|
|
var _post = function(dataSrc) {
|
|
|
|
|
return {
|
|
|
|
|
method: 'POST',
|
|
|
|
|
url: URL,
|
|
|
|
|
headers: {
|
|
|
|
|
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8'
|
|
|
|
|
},
|
|
|
|
|
data: $httpParamSerializer(dataSrc)
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2016-11-01 14:21:35 -03:00
|
|
|
$scope.skip = function() {
|
|
|
|
|
$state.go('feedback.thanks', {
|
|
|
|
|
score: $scope.score,
|
2016-11-02 15:30:14 -03:00
|
|
|
skipped: true
|
2016-11-01 14:21:35 -03:00
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
});
|