Skip to content

Commit

Permalink
contribution states
Browse files Browse the repository at this point in the history
  • Loading branch information
octavioamu committed Oct 21, 2020
1 parent ae2ed9c commit 0f2d428
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
12 changes: 5 additions & 7 deletions app/assets/v2/js/cart.js
Original file line number Diff line number Diff line change
Expand Up @@ -571,27 +571,25 @@ Vue.component('grants-cart', {
'amount_per_period': grant.grant_donation_num_rounds

}]}
console.log(data)

vm.$set(grant, 'loading', true);
vm.$set(grant, 'error', null);
const postContribution = fetchData('v1/api/contribute', 'POST', JSON.stringify(data));

vm.errorMessage = '';

$.when(postContribution).then(response => {
// set the cooldown time to one minute
console.log(response)
if (response.success_contributions) {
console.log(grant.grant_id , response.success_contributions[0].grant_id)
if (response.success_contributions.length) {
if(grant.grant_id === response.success_contributions[0].grant_id ){
// grant.error= response.invalid_contributions[0].message;
vm.$set(grant, 'success', response.success_contributions[0].message);
}
}
if (response.invalid_contributions) {
console.log(grant.grant_id === response.invalid_contributions[0].grant_id)
if (response.invalid_contributions.length) {
if(grant.grant_id === response.invalid_contributions[0].grant_id ){
// grant.error= response.invalid_contributions[0].message;
vm.$set(grant, 'loading', false);
vm.$set(grant, 'error', response.invalid_contributions[0].message);
}

Expand All @@ -605,7 +603,7 @@ Vue.component('grants-cart', {
}
}).catch((e) => {
vm.$set(grant, 'error', 'error submitting data, try again later');

vm.$set(grant, 'loading', false);
});
},
// TODO: SMS related methos and state should be removed and refactored into the component that
Expand Down
8 changes: 4 additions & 4 deletions app/grants/templates/grants/cart-vue.html
Original file line number Diff line number Diff line change
Expand Up @@ -508,22 +508,22 @@ <h1 class="col-auto text-left font-bigger-2 black" style="font-weight: bold; mar
</div>
</div>
<div class="bg-white rounded col ml-2 py-3 d-flex flex-column mt-4">
<p class="font-body"><span class="underline">Step 2</span>: Copy and paste your <b>transaction hash</b> below, and press the confirm button.</p>
<p class="font-body"><span class="underline">Step 2</span>: Copy and paste your <b>Contributor Address</b> below, and press the confirm button.</p>
<div class="form-row align-items-end">
<div class="col">
<!-- <div class="col">
<div class="">
<label :for="`payoutTxId_${grant.grant_id}`" class="font-smaller-1">Transaction Hash:</label>
<input v-model="grant.payoutTxId" :name="`payoutTxId_${grant.grant_id}`" :id="`payoutTxId_${grant.grant_id}`" placeholder="00000..." class="form-control form-control-sm" pattern="[a-zA-Z0-9]{64}$">
</div>
</div>
</div> -->
<div class="col">
<div class="">
<label :for="`contributor_address_${grant.grant_id}`" class="font-smaller-1">Contributor Address:</label>
<input v-model="grant.contributor_address" :name="`contributor_address_${grant.grant_id}`" :id="`contributor_address_${grant.grant_id}`" placeholder="00000..." class="form-control form-control-sm" pattern="^t1[a-zA-Z0-9]{33}$">
</div>
</div>
<div class="">
<button type="submit" class="btn btn-sm btn-gc-blue" :disabled="!grant.payoutTxId">Confirm</button>
<button type="submit" class="btn btn-sm btn-gc-blue" :disabled="!grant.contributor_address || grant.loading">Confirm</button>
</div>
</div>
<div v-if="grant.error" class="font-body text-danger">[[grant.error]]</div>
Expand Down

0 comments on commit 0f2d428

Please sign in to comment.