Skip to content

Commit

Permalink
GITC-665: Ensure that the same token is used in calculations for the …
Browse files Browse the repository at this point in the history
…items in the checkout cart for ETH network
  • Loading branch information
nutrina committed Dec 10, 2021
1 parent 237e890 commit 84e808b
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions app/assets/v2/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -1684,7 +1684,18 @@ Vue.component('grants-cart', {
// Read array of grants in cart from localStorage
let grantData = CartData.loadCart();

this.selectedETHCartToken = grantData.length > 0 && grantData[0].grant_donation_currency;
this.selectedETHCartToken = null;

for (var index = 0; index < grantData.length; index++) {
if (grantData[index].grant_donation_currency) {
this.selectedETHCartToken = grantData[index].grant_donation_currency;
break;
}
}

if (!this.selectedETHCartToken) {
this.selectedETHCartToken = 'DAI';
}

const grantIds = grantData.map(grant => grant.grant_id);

Expand All @@ -1701,7 +1712,7 @@ Vue.component('grants-cart', {

// Make sure none have empty currencies, and if they do default to 5 DAI. This is done
// to prevent the cart from getting stuck loading if a currency is empty
updatedGrant[grantIndex]['grant_donation_currency'] = grant.grant_donation_currency ? grant.grant_donation_currency : 'DAI';
updatedGrant[grantIndex]['grant_donation_currency'] = this.selectedETHCartToken;
updatedGrant[grantIndex]['grant_donation_amount'] = grant.grant_donation_amount ? grant.grant_donation_amount : '5';
});

Expand Down

0 comments on commit 84e808b

Please sign in to comment.