@@ -11,6 +11,7 @@ import { MdAdd } from 'react-icons/md';
1111import { useHistory } from 'react-router-dom' ;
1212
1313import { getBridgePath , getSendPath , getSwapPath } from '@/config/routes' ;
14+ import { FunctionNames , useIsFunctionAvailable } from '@core/ui' ;
1415
1516const onNotImplementedClick = ( e : React . MouseEvent < HTMLButtonElement > ) => {
1617 e . preventDefault ( ) ;
@@ -27,34 +28,48 @@ const ICON_SIZE = 19.2;
2728
2829export const PortfolioActionButtons = ( ) => {
2930 const { push } = useHistory ( ) ;
31+ const { checkIsFunctionSupported } = useIsFunctionAvailable ( ) ;
32+
33+ const isSwapSupported = checkIsFunctionSupported ( FunctionNames . SWAP ) ;
34+ const isBuySupported = checkIsFunctionSupported ( FunctionNames . BUY ) ;
35+
36+ let delay = 0 ;
37+ const getDelay = ( ) => ( delay += 300 ) ;
38+
3039 return (
3140 < Stack direction = "row" gap = { 1 } width = "100%" >
3241 { /* TODO: create the proper animation */ }
33- < Slide direction = "left" in timeout = { 300 } easing = "ease-out" >
42+ < Slide direction = "left" in timeout = { getDelay ( ) } easing = "ease-out" >
3443 < SquareButton
3544 variant = "extension"
3645 icon = { < SendIcon size = { ICON_SIZE } /> }
3746 label = "Send"
3847 onClick = { ( ) => push ( getSendPath ( ) ) }
3948 />
4049 </ Slide >
41- < Slide direction = "left" in timeout = { 600 } easing = "ease-out" >
42- < SquareButton
43- variant = "extension"
44- icon = { < SwapIcon size = { ICON_SIZE } /> }
45- label = "Swap"
46- onClick = { ( ) => push ( getSwapPath ( ) ) }
47- />
48- </ Slide >
49- < Slide direction = "left" in timeout = { 900 } easing = "ease-out" >
50- < SquareButton
51- variant = "extension"
52- icon = { < MdAdd size = { ICON_SIZE } /> }
53- label = "Buy"
54- onClick = { onNotImplementedClick }
55- />
56- </ Slide >
57- < Slide direction = "left" in timeout = { 1200 } easing = "ease-out" >
50+
51+ { isSwapSupported && (
52+ < Slide direction = "left" in timeout = { getDelay ( ) } easing = "ease-out" >
53+ < SquareButton
54+ variant = "extension"
55+ icon = { < SwapIcon size = { ICON_SIZE } /> }
56+ label = "Swap"
57+ onClick = { ( ) => push ( getSwapPath ( ) ) }
58+ />
59+ </ Slide >
60+ ) }
61+
62+ { isBuySupported && (
63+ < Slide direction = "left" in timeout = { getDelay ( ) } easing = "ease-out" >
64+ < SquareButton
65+ variant = "extension"
66+ icon = { < MdAdd size = { ICON_SIZE } /> }
67+ label = "Buy"
68+ onClick = { onNotImplementedClick }
69+ />
70+ </ Slide >
71+ ) }
72+ < Slide direction = "left" in timeout = { getDelay ( ) } easing = "ease-out" >
5873 < SquareButton
5974 variant = "extension"
6075 icon = { < BridgeIcon size = { ICON_SIZE } /> }
0 commit comments