Add try catch block if user reject a withdraw action

This commit is contained in:
RcleydsonR 2023-02-17 18:06:58 -03:00
parent ec5fb7ef76
commit 94640c4492
4 changed files with 12 additions and 7 deletions

View File

@ -112,7 +112,7 @@ showInitialItems();
<template> <template>
<div class="blur-container" v-if="loadingWalletTransactions"> <div class="blur-container" v-if="loadingWalletTransactions">
<SpinnerComponent width="8" height="8" color="white"></SpinnerComponent> <SpinnerComponent width="8" height="8" fillColor="white"></SpinnerComponent>
</div> </div>
<div class="blur-container" v-if="!loadingWalletTransactions"> <div class="blur-container" v-if="!loadingWalletTransactions">
<div <div

View File

@ -197,7 +197,7 @@ watch(walletAddress, (): void => {
<SpinnerComponent <SpinnerComponent
width="4" width="4"
height="4" height="4"
color="blue-600" fillColor="white"
></SpinnerComponent> ></SpinnerComponent>
</div> </div>
<div <div

View File

@ -3,7 +3,7 @@
const props = defineProps({ const props = defineProps({
width: String, width: String,
height: String, height: String,
color: String, fillColor: String,
show: Boolean, show: Boolean,
}); });
@ -11,7 +11,7 @@ const getCustomClass = () => {
return [ return [
`w-${props.width}`, `w-${props.width}`,
`h-${props.height}`, `h-${props.height}`,
`fill-${props.color}`, `fill-${props.fillColor}`,
"text-gray-200", "text-gray-200",
"animate-spin", "animate-spin",
"dark:text-gray-600", "dark:text-gray-600",

View File

@ -23,15 +23,20 @@ const transactionsList = ref<WalletTransaction[]>([]);
const callWithdraw = async (amount: string) => { const callWithdraw = async (amount: string) => {
if (amount) { if (amount) {
loadingWithdraw.value = true; loadingWithdraw.value = true;
const withdraw = await withdrawDeposit(amount); let withdraw;
try {
withdraw = await withdrawDeposit(amount);
} catch {
loadingWithdraw.value = false;
}
if (withdraw) { if (withdraw) {
console.log("Saque realizado!"); console.log("Saque realizado!");
await getWalletTransactions(); await getWalletTransactions();
loadingWithdraw.value = false;
} else { } else {
console.log("Não foi possível realizar o saque!"); console.log("Não foi possível realizar o saque!");
loadingWithdraw.value = false;
} }
loadingWithdraw.value = false;
} }
}; };