From a6b15d2bce46fb5ef9ae526a80c64140abd59a46 Mon Sep 17 00:00:00 2001 From: Matt Date: Wed, 30 Sep 2020 20:27:12 -0700 Subject: [PATCH] Fix bugs in #7458 that happen when items are removed from cart (#7573) --- app/assets/v2/js/cart.js | 14 +++++++++++++- app/grants/templates/grants/cart-vue.html | 4 ++-- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index 7185ecf3bed..3b0cc40e082 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -2561,7 +2561,19 @@ Vue.component('grants-cart', { }); // Read array of grants in cart from localStorage - this.grantData = CartData.loadCart(); + const grantData = CartData.loadCart(); + + // Make sure none have empty currencies, and if they do default to 0.001 ETH. This is done + // to prevent the cart from getting stuck loading if a currency is empty + grantData.forEach((grant, index) => { + if (!grant.grant_donation_currency) { + grantData[index].grant_donation_currency = 'ETH'; + grantData[index].grant_donation_amount = '0.001'; + } + }); + CartData.setCart(grantData); + this.grantData = grantData; + // Initialize array of empty comments this.comments = this.grantData.map(grant => undefined); diff --git a/app/grants/templates/grants/cart-vue.html b/app/grants/templates/grants/cart-vue.html index 68f6e57286f..db6cc214aeb 100644 --- a/app/grants/templates/grants/cart-vue.html +++ b/app/grants/templates/grants/cart-vue.html @@ -155,7 +155,7 @@

- @@ -212,7 +212,7 @@

+
{% comment %} Title and logo {% endcomment %}