Skip to content

Commit

Permalink
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 18, 2023
1 parent 937b0cb commit af6443c
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions src/app/pages/home/components/account-actions.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,15 @@
import { useLocation, useNavigate } from 'react-router-dom';

import { ChainID } from '@stacks/transactions';
import { HomePageSelectors } from '@tests/selectors/home.selectors';
import { Flex, FlexProps } from 'leather-styles/jsx';

import { RouteUrls } from '@shared/route-urls';

import { whenStacksChainId } from '@app/common/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,7 @@ export function AccountActions(props: FlexProps) {
const location = useLocation();
const isBitcoinEnabled = useConfigBitcoinEnabled();
const stacksAccount = useCurrentStacksAccount();
const currentNetwork = useCurrentNetwork();

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

<ActionButton
data-testid={HomePageSelectors.SwapBtn}
icon={<SwapIcon />}
label="Swap"
onClick={() => navigate(RouteUrls.Swap)}
/>
{whenStacksChainId(currentNetwork.chain.stacks.chainId)({
[ChainID.Mainnet]: (
<ActionButton
data-testid={HomePageSelectors.SwapBtn}
icon={<SwapIcon />}
label="Swap"
onClick={() => navigate(RouteUrls.Swap)}
/>
),
[ChainID.Testnet]: null,
})}
</Flex>
);
}

0 comments on commit af6443c

Please sign in to comment.