gifts: prevent users from sending the same gift twice by clicking many times on the Send button

This commit is contained in:
Matteo Pagliazzi
2018-10-11 19:01:15 +02:00
parent c875861dab
commit 67bb179c25

View File

@@ -41,7 +41,11 @@ b-modal#send-gems(:title="title", :hide-footer="true", size='lg', @hide='onHide(
//include ../formatting-help //include ../formatting-help
.modal-footer .modal-footer
button.btn.btn-primary(v-if='fromBal', @click='sendGift()') {{ $t("send") }} button.btn.btn-primary(
v-if="fromBal",
@click="sendGift()",
:disabled="sendingInProgress"
) {{ $t("send") }}
template(v-else) template(v-else)
button.btn.btn-primary(@click='showStripe({gift, uuid: userReceivingGems._id})') {{ $t('card') }} button.btn.btn-primary(@click='showStripe({gift, uuid: userReceivingGems._id})') {{ $t('card') }}
button.btn.btn-warning(@click='openPaypalGift({gift: gift, giftedTo: userReceivingGems._id})') PayPal button.btn.btn-warning(@click='openPaypalGift({gift: gift, giftedTo: userReceivingGems._id})') PayPal
@@ -103,6 +107,7 @@ export default {
assistanceEmailObject: { assistanceEmailObject: {
hrefTechAssistanceEmail: `<a href="mailto:${TECH_ASSISTANCE_EMAIL}">${TECH_ASSISTANCE_EMAIL}</a>`, hrefTechAssistanceEmail: `<a href="mailto:${TECH_ASSISTANCE_EMAIL}">${TECH_ASSISTANCE_EMAIL}</a>`,
}, },
sendingInProgress: false,
}; };
}, },
computed: { computed: {
@@ -130,6 +135,7 @@ export default {
methods: { methods: {
// @TODO move to payments mixin or action (problem is that we need notifications) // @TODO move to payments mixin or action (problem is that we need notifications)
async sendGift () { async sendGift () {
this.sendingInProgress = true;
await this.$store.dispatch('members:transferGems', { await this.$store.dispatch('members:transferGems', {
message: this.gift.message, message: this.gift.message,
toUserId: this.userReceivingGems._id, toUserId: this.userReceivingGems._id,
@@ -139,7 +145,9 @@ export default {
this.close(); this.close();
}, },
onHide () { onHide () {
this.gift.gems.amount = 0;
this.gift.message = ''; this.gift.message = '';
this.sendingInProgress = false;
}, },
close () { close () {
this.$root.$emit('bv::hide::modal', 'send-gems'); this.$root.$emit('bv::hide::modal', 'send-gems');