New send flow for the Amazon integration
This commit is contained in:
parent
93b759ffca
commit
1d1b632886
10 changed files with 197 additions and 10 deletions
|
|
@ -1,7 +1,7 @@
|
|||
'use strict';
|
||||
|
||||
angular.module('copayApp.controllers').controller('amazonController',
|
||||
function($scope, $timeout, $ionicModal, $log, lodash, bwcError, amazonService, platformInfo, externalLinkService, popupService) {
|
||||
function($scope, $timeout, $ionicModal, $log, lodash, amazonService, platformInfo, externalLinkService, popupService, gettextCatalog) {
|
||||
|
||||
$scope.network = amazonService.getEnvironment();
|
||||
|
||||
|
|
@ -19,6 +19,14 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
$timeout(function() {
|
||||
$scope.$digest();
|
||||
});
|
||||
if ($scope.cardClaimCode) {
|
||||
var card = lodash.find($scope.giftCards, { claimCode: $scope.cardClaimCode });
|
||||
if (lodash.isEmpty(card)) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), gettextCatalog.getString('Card not found'));
|
||||
return;
|
||||
}
|
||||
$scope.openCardModal(card);
|
||||
}
|
||||
});
|
||||
$scope.updatePendingGiftCards();
|
||||
};
|
||||
|
|
@ -26,12 +34,16 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
$scope.updatePendingGiftCards = lodash.debounce(function() {
|
||||
|
||||
amazonService.getPendingGiftCards(function(err, gcds) {
|
||||
$timeout(function() {
|
||||
$scope.giftCards = gcds;
|
||||
$scope.$digest();
|
||||
});
|
||||
lodash.forEach(gcds, function(dataFromStorage) {
|
||||
if (dataFromStorage.status == 'PENDING') {
|
||||
$log.debug("creating gift card");
|
||||
amazonService.createGiftCard(dataFromStorage, function(err, giftCard) {
|
||||
if (err) {
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), bwcError.msg(err));
|
||||
popupService.showAlert(gettextCatalog.getString('Error'), err);
|
||||
return;
|
||||
}
|
||||
if (giftCard.status != 'PENDING') {
|
||||
|
|
@ -84,6 +96,7 @@ angular.module('copayApp.controllers').controller('amazonController',
|
|||
};
|
||||
|
||||
$scope.$on("$ionicView.beforeEnter", function(event, data) {
|
||||
$scope.cardClaimCode = data.stateParams.cardClaimCode;
|
||||
initAmazon();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue