diff --git a/apps/next/src/pages/Portfolio/components/PortfolioHome/components/PortolioDetails/components/PortfolioActionButtons.tsx b/apps/next/src/pages/Portfolio/components/PortfolioHome/components/PortolioDetails/components/PortfolioActionButtons.tsx index 3f64c25d6..d8e232cd6 100644 --- a/apps/next/src/pages/Portfolio/components/PortfolioHome/components/PortolioDetails/components/PortfolioActionButtons.tsx +++ b/apps/next/src/pages/Portfolio/components/PortfolioHome/components/PortolioDetails/components/PortfolioActionButtons.tsx @@ -11,6 +11,7 @@ import { MdAdd } from 'react-icons/md'; import { useHistory } from 'react-router-dom'; import { getBridgePath, getSendPath, getSwapPath } from '@/config/routes'; +import { FunctionNames, useIsFunctionAvailable } from '@core/ui'; const onNotImplementedClick = (e: React.MouseEvent) => { e.preventDefault(); @@ -27,10 +28,18 @@ const ICON_SIZE = 19.2; export const PortfolioActionButtons = () => { const { push } = useHistory(); + const { checkIsFunctionSupported } = useIsFunctionAvailable(); + + const isSwapSupported = checkIsFunctionSupported(FunctionNames.SWAP); + const isBuySupported = checkIsFunctionSupported(FunctionNames.BUY); + + let delay = 0; + const getDelay = () => (delay += 300); + return ( {/* TODO: create the proper animation */} - + } @@ -38,23 +47,29 @@ export const PortfolioActionButtons = () => { onClick={() => push(getSendPath())} /> - - } - label="Swap" - onClick={() => push(getSwapPath())} - /> - - - } - label="Buy" - onClick={onNotImplementedClick} - /> - - + + {isSwapSupported && ( + + } + label="Swap" + onClick={() => push(getSwapPath())} + /> + + )} + + {isBuySupported && ( + + } + label="Buy" + onClick={onNotImplementedClick} + /> + + )} + } diff --git a/packages/ui/src/hooks/useIsFunctionAvailable.ts b/packages/ui/src/hooks/useIsFunctionAvailable.ts index afcfd5b75..26262a2b0 100644 --- a/packages/ui/src/hooks/useIsFunctionAvailable.ts +++ b/packages/ui/src/hooks/useIsFunctionAvailable.ts @@ -168,7 +168,7 @@ const enabledFeatures = { ChainId.ETHEREUM_HOMESTEAD, ChainId.SOLANA_MAINNET_ID, ], - Buy: [ChainId.AVALANCHE_MAINNET_ID, ChainId.AVALANCHE_TESTNET_ID], + Buy: [ChainId.AVALANCHE_MAINNET_ID], }; /**