Skip to content

Commit

Permalink
update button disable logic to check if nim is active
Browse files Browse the repository at this point in the history
  • Loading branch information
onmax committed Nov 25, 2024
1 parent 660c125 commit 03573f9
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 18 deletions.
14 changes: 9 additions & 5 deletions src/components/MobileActionBar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</button>
<button class="send nq-button-pill light-blue flex-row"
@click="send" @mousedown.prevent
:disabled="$config.disableNetworkInteraction || sendDisabled"
:disabled="sendDisabled"
>
<ArrowRightSmallIcon />{{ $t('Send') }}
</button>
Expand All @@ -18,6 +18,7 @@
<script lang="ts">
import { defineComponent, computed } from '@vue/composition-api';
import { ArrowRightSmallIcon, ScanQrCodeIcon } from '@nimiq/vue-components';
import { useConfig } from '@/composables/useConfig';
import { AddressType, useAddressStore } from '../stores/Address';
import { useAccountStore } from '../stores/Account';
import { CryptoCurrency } from '../lib/Constants';
Expand Down Expand Up @@ -78,17 +79,20 @@ export default defineComponent({
}
}
const sendDisabled = computed(() =>
context.root.$route.path !== '/' && nimOrBtcOrStable(
const { config } = useConfig();
const sendDisabled = computed(() => {
if (activeCurrency.value === 'nim' && config.disableNetworkInteraction) return true;
return context.root.$route.path !== '/' && nimOrBtcOrStable(
!activeAddressInfo.value || !activeAddressInfo.value.balance,
!btcBalance.value,
(stablecoin.value === CryptoCurrency.USDC
? !accountUsdcBalance.value
: stablecoin.value === CryptoCurrency.USDT
? !accountUsdtBridgedBalance.value
: true),
),
);
);
});
return {
receive,
Expand Down
7 changes: 3 additions & 4 deletions src/components/layouts/AccountOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@
</div>

<Tooltip
v-if="!$config.disableNetworkInteraction
v-if="(activeCurrency === 'nim' && !$config.disableNetworkInteraction)
&& $config.fastspot.enabled
&& hasBitcoinAddresses && $config.enableBitcoin
&& (nimAccountBalance > 0 || btcAccountBalance > 0)"
Expand All @@ -85,7 +85,7 @@
</Tooltip>

<Tooltip
v-if="!$config.disableNetworkInteraction
v-if="(activeCurrency === 'nim' && !$config.disableNetworkInteraction)
&& $config.fastspot.enabled
&& activeAccountInfo && activeAccountInfo.type !== AccountType.LEDGER
&& hasPolygonAddresses && $config.polygon.enabled
Expand Down Expand Up @@ -156,8 +156,7 @@
</button>

<Tooltip
v-if="!$config.disableNetworkInteraction
&& $config.fastspot.enabled
v-if="$config.fastspot.enabled
&& activeAccountInfo && activeAccountInfo.type !== AccountType.LEDGER
&& hasBitcoinAddresses && $config.enableBitcoin
&& hasPolygonAddresses && $config.polygon.enabled
Expand Down
6 changes: 4 additions & 2 deletions src/components/layouts/AddressOverview.vue
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,10 @@

<button class="send nq-button-pill light-blue flex-row"
@click="$router.push(`/send/${activeCurrency}`)" @mousedown.prevent
:disabled="$config.disableNetworkInteraction
|| (activeCurrency === 'nim' && (!activeAddressInfo || !activeAddressInfo.balance))
:disabled="
(activeCurrency === 'nim'
&& (!activeAddressInfo || !activeAddressInfo.balance
|| $config.disableNetworkInteraction))
|| (activeCurrency === 'btc' && !btcAccountBalance)
|| (activeCurrency === 'usdc' && !accountUsdcBalance /* can only send native usdc */)
|| (activeCurrency === CryptoCurrency.USDT && !accountUsdtBridgedBalance)"
Expand Down
8 changes: 5 additions & 3 deletions src/components/layouts/Sidebar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
<template #trigger>
<button
class="nq-button-s inverse"
:disabled="$config.disableNetworkInteraction || hasActiveSwap"
:disabled="(activeCurrency === 'nim' && $config.disableNetworkInteraction) || hasActiveSwap"
@click="openModal('buy')"
@mousedown.prevent="hideTooltips"
>{{ $t('Buy') }}</button>
Expand All @@ -74,7 +74,8 @@
>
<template #trigger>
<button class="nq-button-s inverse"
:disabled="$config.disableNetworkInteraction || !canSellCryptoWithMoonpay"
:disabled="(activeCurrency === 'nim' && $config.disableNetworkInteraction)
|| !canSellCryptoWithMoonpay"
@click="openModal('moonpay-sell-info')"
@mousedown.prevent="hideTooltips"
>{{ $t('Sell') }}</button>
Expand Down Expand Up @@ -130,7 +131,7 @@
>
<template #trigger>
<button
:disabled="$config.disableNetworkInteraction
:disabled="(activeCurrency === 'nim' && $config.disableNetworkInteraction)
|| fastspotEnabledCryptoSwapAssets.length <= 1
|| walletActivatedCurrencies.length <= 1
|| !hasSwappableBalance
Expand Down Expand Up @@ -345,6 +346,7 @@ export default defineComponent({
openModal,
canSellCryptoWithMoonpay,
nimSellOptions,
activeCurrency,
};
},
components: {
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/BuyCryptoModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@
v-if="!insufficientLimit || !$config.ten31Pass.enabled || kycUser"
:assets="[activeCurrency]"
:buttonColor="kycUser ? 'purple' : 'light-blue'"
:disabled="$config.disableNetworkInteraction || !canSign"
:disabled="(activeCurrency === 'nim' && $config.disableNetworkInteraction) || !canSign"
:error="estimateError || swapError"
:requireCompleteBtcHistory="false"
@click="sign"
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/SellCryptoModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
v-if="!insufficientLimit || !$config.ten31Pass.enabled || kycUser"
:assets="[activeCurrency]"
:buttonColor="kycUser ? 'purple' : 'light-blue'"
:disabled="$config.disableNetworkInteraction || !canSign"
:disabled="(activeCurrency === 'nim' && $config.disableNetworkInteraction) || !canSign"
:error="estimateError || swapError"
requireCompleteBtcHistory
@click="sign"
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/SendModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@
</PageBody>
<SendModalFooter
:assets="[CryptoCurrency.NIM]"
:disabled="$config.disableNetworkInteraction || !canSend"
:disabled="(activeCurrency === 'nim' && $config.disableNetworkInteraction) || !canSend"
@click="sign"
><template #cta>{{ $t('Send {currency}', { currency: 'NIM' }) }}</template></SendModalFooter>
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/components/swap/SwapModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@
v-if="!isLimitReached || !$config.ten31Pass.enabled || kycUser"
:assets="[assetToCurrency(leftAsset), assetToCurrency(rightAsset)]"
:buttonColor="kycUser ? 'purple' : 'light-blue'"
:disabled="$config.disableNetworkInteraction || !canSign || currentlySigning"
:disabled="(activeCurrency === 'nim' && $config.disableNetworkInteraction) || !canSign || currentlySigning"
:error="disabledAssetError || estimateError || swapError || polygonFeeError"
requireCompleteBtcHistory
@click="sign"
Expand Down

0 comments on commit 03573f9

Please sign in to comment.