diff --git a/app/assets/v2/js/cart.js b/app/assets/v2/js/cart.js index ba627df4641..6d87f97b67b 100644 --- a/app/assets/v2/js/cart.js +++ b/app/assets/v2/js/cart.js @@ -1185,7 +1185,7 @@ Vue.component('grants-cart', { }, /** - * @notice POSTs donation data to database. Intended to be called from finalizeCheckout() + * @notice POSTs donation data to database */ async postToDatabase(txHash, contractAddress, userAddress) { // this.donationInputs is the array used for bulk donations @@ -1291,17 +1291,12 @@ Vue.component('grants-cart', { // Clear cart, redirect back to grants page, and show success alert localStorage.setItem('contributions_were_successful', 'true'); localStorage.setItem('contributions_count', String(this.grantsByTenant.length)); - var network = document.web3network; let timeout_amount = 1500 + (CartData.loadCart().length * 500); setTimeout(function() { _alert('Contributions saved', 'success', 1000); setTimeout(function() { - if (network === 'rinkeby') { - window.location.href = `${window.location.origin}/grants/?network=rinkeby&category=`; - } else { - window.location.href = `${window.location.origin}/grants`; - } + window.location.href = `${window.location.origin}/grants`; }, 500); }, timeout_amount); }, diff --git a/app/assets/v2/js/grants/funding.js b/app/assets/v2/js/grants/funding.js index 81be5cb0ce6..e67c1f6357a 100644 --- a/app/assets/v2/js/grants/funding.js +++ b/app/assets/v2/js/grants/funding.js @@ -7,6 +7,8 @@ $(document).ready(function() { const shouldShowAlert = Boolean(localStorage.getItem('contributions_were_successful')); if (shouldShowAlert) { + // This alert currently shows after Ethereum checkouts only. As a result, we make sure to + // only clear ETH grants from local storage const numberOfContributions = Number(localStorage.getItem('contributions_count')); const grantWord = numberOfContributions === 1 ? 'grant' : 'grants'; const message = `You have successfully funded ${numberOfContributions} ${grantWord}. Thank you for your contribution!`; @@ -15,23 +17,26 @@ $(document).ready(function() { localStorage.removeItem('contributions_were_successful'); localStorage.removeItem('contributions_count'); $('#tweetModal').modal('show'); - let donations = CartData.loadCart(); - if (donations.length) { + const allDonations = CartData.loadCart(); + const ethereumDonations = allDonations.filter((grant) => grant.tenants[0] === 'ETH'); + const otherDonations = allDonations.filter((grant) => grant.tenants[0] !== 'ETH'); + + if (allDonations.length) { let cart_html = 'You just funded: '; let bulk_add_cart = CartData.share_url(); - for (let i = 0; i < donations.length; i += 1) { - const donation = donations[i]; + for (let i = 0; i < allDonations.length; i += 1) { + const donation = allDonations[i]; cart_html += '
  • ' + donation['grant_title'] + ' for ' + donation['grant_donation_amount'] + ' ' + donation['grant_donation_currency'] + ' (+' + donation['grant_donation_clr_match'] + ' DAI match)
  • '; } cart_html += '
    Here is a handy link for sharing this collection with others.'; $("" + cart_html + '').insertBefore($('#tweetModal span.copy')); - $('#tweetModal a.button').attr('href', 'https://twitter.com/intent/tweet?text=I%20just%20funded%20these%20' + donations.length + '%20grants%20on%20@gitcoin%20=%3E%20' + bulk_add_cart); + $('#tweetModal a.button').attr('href', 'https://twitter.com/intent/tweet?text=I%20just%20funded%20these%20' + allDonations.length + '%20grants%20on%20@gitcoin%20=%3E%20' + bulk_add_cart); $('#tweetModal a.button').text('Tweet about it'); } - CartData.setCart([]); + CartData.setCart(otherDonations); } $('#js-addToCart-form').submit(function(event) {