UI styling. Improve error handle

This commit is contained in:
Gustavo Maximiliano Cortez 2017-07-06 18:10:04 -03:00
commit 0b3cb389ae
No known key found for this signature in database
GPG key ID: 15EDAD8D9F2EB1AF
6 changed files with 132 additions and 80 deletions

View file

@ -142,13 +142,21 @@ angular.module('copayApp.controllers').controller('buyMercadoLibreController', f
var checkTransaction = lodash.throttle(function(count, dataSrc) {
mercadoLibreService.createGiftCard(dataSrc, function(err, giftCard) {
$log.debug("creating gift card " + count);
if (err || !giftCard.pin) {
if (err) {
$scope.sendStatus = '';
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
giftCard = {};
giftCard.status = 'FAILURE';
}
if (giftCard && giftCard.cardStatus && (giftCard.cardStatus != 'active' && giftCard.cardStatus != 'inactive' && giftCard.cardStatus != 'expired')) {
$scope.sendStatus = '';
ongoingProcess.set('buyingGiftCard', false, statusChangeHandler);
giftCard = {};
giftCard.status = 'FAILURE';
}
if (giftCard.status == 'PENDING' && count < 3) {
$log.debug("Waiting for payment confirmation");
checkTransaction(count + 1, dataSrc);

View file

@ -24,18 +24,15 @@ angular.module('copayApp.controllers').controller('mercadoLibreCardsController',
};
$scope.updatePendingGiftCards = lodash.debounce(function() {
$scope.updatingPending = {};
updateGiftCards(function() {
var index = 0;
var gcds = $scope.giftCards;
lodash.forEach(gcds, function(dataFromStorage) {
if (dataFromStorage.status == 'PENDING' || dataFromStorage.status == 'invalid') {
if (dataFromStorage.status == 'PENDING') {
$log.debug("Creating / Updating gift card");
$scope.updatingPending[dataFromStorage.invoiceId] = true;
mercadoLibreService.createGiftCard(dataFromStorage, function(err, giftCard) {
$scope.updatingPending[dataFromStorage.invoiceId] = false;
if (err) {
popupService.showAlert('Error creating gift card', err);
return;
@ -44,6 +41,12 @@ angular.module('copayApp.controllers').controller('mercadoLibreCardsController',
if (giftCard.status != 'PENDING') {
var newData = {};
if (!giftCard.status) dataFromStorage.status = null; // Fix error from server
var cardStatus = giftCard.cardStatus;
if (cardStatus && (cardStatus != 'active' && cardStatus != 'inactive' && cardStatus != 'expired'))
giftCard.status = 'FAILURE';
lodash.merge(newData, dataFromStorage, giftCard);
mercadoLibreService.savePendingGiftCard(newData, null, function(err) {

View file

@ -140,7 +140,7 @@ angular.module('copayApp.services').factory('mercadoLibreService', function($htt
$log.info('Mercado Libre Gift Card Create/Update: ' + status);
return cb(null, data.data);
}, function(data) {
$log.error('Mercado Libre Gift Card Create/Update: ' + data.data.message);
$log.error('Mercado Libre Gift Card Create/Update: ', JSON.stringify(data.data));
return cb(data.data);
});
};

View file

@ -144,3 +144,50 @@
}
}
}
#meli-card {
.card-head {
margin: 20px 0;
text-align: center;
.date {
font-size: 12px;
margin: 10px 0;
}
.amount {
font-size: 16px;
font-weight: bold;
}
}
.card-status {
text-align: center;
margin-bottom: 25px;
.card-status-desc {
margin-top: 5px;
font-size: 12px;
color: $v-text-secondary-color;
}
.redeem-pin {
font-weight: bold;
font-size: 22px;
}
.button-redeem {
margin-top: 10px;
background: transparent;
border: none;
font-size: 12px;
color: $v-text-accent-color;
}
}
.card-remove {
text-align: center;
margin-top: 30px;
.button-remove {
margin-top: 10px;
background: transparent;
border: none;
font-size: 12px;
color: red;
}
}
}