Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bugs in #7458 that happen when items are removed from cart #7573

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 13 additions & 1 deletion app/assets/v2/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
4 changes: 2 additions & 2 deletions app/grants/templates/grants/cart-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ <h1 class="col-auto text-left font-bigger-2 black" style="font-weight: bold; mar
v-model="grant.grant_donation_amount" type="number" placeholder="Amount">
<select2 v-model="grant.grant_donation_currency" class="col-6 form-control"
style="margin-right:0.5rem" placeholder="Select token">
<option v-for="option in currencies[index]" v-bind:value="option" :disabled="!option">
<option v-for="(option, index) in currencies[index]" v-bind:value="option" :disabled="!option" :key="`currency-${index}`">
<span v-if="!option" style="height:1px; font-size:1px">&mdash;&mdash;&mdash;&mdash;</span>
<span v-else>[[ option ]]</span>
</option>
Expand Down Expand Up @@ -212,7 +212,7 @@ <h1 class="col-auto text-left font-bigger-2 black" style="font-weight: bold; mar
</div>
</div>
{% comment %} Cart Contents: NOT MOBILE {% endcomment %}
<div v-if="!isMobileDevice" v-for="(grant, index) in grantData" class="grant-row">
<div v-if="!isMobileDevice" v-for="(grant, index) in grantData" class="grant-row" :key="grant.grant_id">
<div class="grant-row-style">
<div class="row align-items-center justify-content-between" style="margin-left:0.5rem">
{% comment %} Title and logo {% endcomment %}
Expand Down