Skip to content

Commit

Permalink
fix: fix: only show swaps option on mainnet, closes #4687
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarkhanzadian committed Dec 14, 2023
1 parent 8d160b0 commit d799836
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/app/pages/home/components/account-actions.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,13 @@ import { useLocation, useNavigate } from 'react-router-dom';
import { HomePageSelectors } from '@tests/selectors/home.selectors';
import { Flex, FlexProps } from 'leather-styles/jsx';

import { bitcoinNetworkModeToCoreNetworkMode } from '@shared/crypto/bitcoin/bitcoin.utils';
import { RouteUrls } from '@shared/route-urls';
import { whenNetwork } from '@shared/utils';

import { useConfigBitcoinEnabled } from '@app/query/common/remote-config/remote-config.query';
import { useCurrentStacksAccount } from '@app/store/accounts/blockchain/stacks/stacks-account.hooks';
import { useCurrentNetwork } from '@app/store/networks/networks.selectors';
import { ArrowDownIcon } from '@app/ui/components/icons/arrow-down-icon';
import { PlusIcon } from '@app/ui/components/icons/plus-icon';
import { SwapIcon } from '@app/ui/components/icons/swap-icon';
Expand All @@ -19,6 +22,10 @@ export function AccountActions(props: FlexProps) {
const location = useLocation();
const isBitcoinEnabled = useConfigBitcoinEnabled();
const stacksAccount = useCurrentStacksAccount();
const currentNetwork = useCurrentNetwork();
const networkType = bitcoinNetworkModeToCoreNetworkMode(
currentNetwork.chain.bitcoin.bitcoinNetwork
);

const receivePath = isBitcoinEnabled
? RouteUrls.Receive
Expand All @@ -42,13 +49,17 @@ export function AccountActions(props: FlexProps) {
onClick={() => navigate(RouteUrls.FundChooseCurrency)}
/>
)}

<ActionButton
data-testid={HomePageSelectors.SwapBtn}
icon={<SwapIcon />}
label="Swap"
onClick={() => navigate(RouteUrls.Swap)}
/>
{whenNetwork(networkType)({
mainnet: (
<ActionButton
data-testid={HomePageSelectors.SwapBtn}
icon={<SwapIcon />}
label="Swap"
onClick={() => navigate(RouteUrls.Swap)}
/>
),
testnet: null,
})}
</Flex>
);
}

0 comments on commit d799836

Please sign in to comment.