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

Update withdrawal UX #1466

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from
Prev Previous commit
Next Next commit
using maxPerAccountDailyWithdrawalAmount insteads
mimiiiz committed Jun 18, 2021
commit 0ee7bdb7f0900f014db70fb1ad84ea0cb6a87864
16 changes: 8 additions & 8 deletions src/components/gateway/WithdrawForm.vue
Original file line number Diff line number Diff line change
@@ -33,14 +33,14 @@
</div>
<div>
<h6>{{ $t('components.gateway.withdraw_form_modal.balance') }} {{ balance | tokenAmount(tokenInfo.decimals)}} {{ token }}</h6>
<h6 v-if="reachedLimit()">
<h6 v-if="reachedLimit">
{{ $t('components.gateway.withdraw_form_modal.daily_withdrawal_limit_reached') }}
{{ isWithdrawalLimitEnabled | tokenAmount(tokenInfo.decimals) }} {{ token }}
</h6>
<h6 v-if="isWithdrawalLimitEnabled && isCheckDailyRemainingWithdrawAmount() && !reachedLimit()">
<h6 v-if="isWithdrawalLimitEnabled && isCheckDailyRemainingWithdrawAmount() && !reachedLimit">
{{ $t('components.gateway.withdraw_form_modal.daily_remaining_withdraw_amount') }}
{{ dailyRemainingWithdrawAmount | tokenAmount(tokenInfo.decimals) }} /
{{ isWithdrawalLimitEnabled | tokenAmount(tokenInfo.decimals) }} {{ token }}
{{ maxPerAccountDailyWithdrawalAmount | tokenAmount(tokenInfo.decimals) }} {{ token }}
</h6>
<amount-input
:min="min"
@@ -69,7 +69,7 @@
class="ml-2"
@click="requestWithdrawal"
variant="primary"
:disabled="validInput === false || max <= 0 || reachedLimit()"
:disabled="validInput === false || max <= 0 || reachedLimit"
>{{ $t('components.gateway.withdraw_form_modal.withdraw') }}</b-btn>
</template>
</b-modal>
@@ -109,6 +109,7 @@ export default class WithdrawForm extends Vue {
isValidAddress: boolean = false
recepient = ""
dailyRemainingWithdrawAmount: BN = ZERO
maxPerAccountDailyWithdrawalAmount: BN = ZERO

tokenInfo: TokenData | null = null

@@ -178,7 +179,7 @@ export default class WithdrawForm extends Vue {
this.visible = false
}

reachedLimit() {
get reachedLimit() {
return this.isWithdrawalLimitEnabled && this.dailyRemainingWithdrawAmount.lte(new BN(0))
}

@@ -220,10 +221,9 @@ export default class WithdrawForm extends Vue {
if (lastWithdrawalLimitResetDate.toDateString() !== todayDate.toDateString()) {
totalWithdrawalAmount = new BN(0)
}

const gatewayState = await gateway.getGatewayState()
const maxPerAccountDailyWithdrawalAmount: BN = gatewayState!.maxPerAccountDailyWithdrawalAmount
const remainingWithdrawAmount = maxPerAccountDailyWithdrawalAmount.sub(totalWithdrawalAmount)
this.maxPerAccountDailyWithdrawalAmount = gatewayState!.maxPerAccountDailyWithdrawalAmount
const remainingWithdrawAmount = this.maxPerAccountDailyWithdrawalAmount.sub(totalWithdrawalAmount)

console.log("remainingWithdrawAmount: ", remainingWithdrawAmount.toString())
return remainingWithdrawAmount