|
| 1 | +import { recordEntries } from '@curvefi/prices-api/objects.util' |
1 | 2 | import Box from '@mui/material/Box' |
2 | 3 | import Button from '@mui/material/Button' |
| 4 | +import { useAnalyticsApp } from '@ui-kit/hooks/useFeatureFlags' |
3 | 5 | import { APP_LINK, type AppMenuOption, getInternalUrl } from '@ui-kit/shared/routes' |
4 | 6 | import { RouterLink } from '@ui-kit/shared/ui/RouterLink' |
5 | 7 |
|
6 | 8 | type AppNavAppsProps = { currentMenu: AppMenuOption; onChange: (appName: AppMenuOption) => void; networkId: string } |
7 | 9 |
|
8 | | -export const AppButtonLinks = ({ currentMenu, onChange, networkId }: AppNavAppsProps) => ( |
9 | | - <Box display="flex" alignItems="center" marginX={[2, 3, 4]} gap={2}> |
10 | | - {Object.entries(APP_LINK).map(([menu, { label, routes }]) => ( |
11 | | - <Button |
12 | | - key={menu} |
13 | | - color="navigation" |
14 | | - size="small" |
15 | | - className={currentMenu === menu ? 'current' : ''} |
16 | | - component={RouterLink} |
17 | | - onClick={() => onChange(menu as AppMenuOption)} |
18 | | - href={getInternalUrl(routes[0].app, networkId)} |
19 | | - data-testid={`app-link-${menu}`} |
20 | | - > |
21 | | - {label} |
22 | | - </Button> |
23 | | - ))} |
24 | | - </Box> |
25 | | -) |
| 10 | +export const AppButtonLinks = ({ currentMenu, onChange, networkId }: AppNavAppsProps) => { |
| 11 | + const showAnalytics = useAnalyticsApp() |
| 12 | + const apps = recordEntries(APP_LINK).filter(([app]) => app !== 'analytics' || showAnalytics) |
| 13 | + |
| 14 | + return ( |
| 15 | + <Box display="flex" alignItems="center" marginX={[2, 3, 4]} gap={2}> |
| 16 | + {apps.map(([menu, { label, routes }]) => ( |
| 17 | + <Button |
| 18 | + key={menu} |
| 19 | + color="navigation" |
| 20 | + size="small" |
| 21 | + className={currentMenu === menu ? 'current' : ''} |
| 22 | + component={RouterLink} |
| 23 | + onClick={() => onChange(menu as AppMenuOption)} |
| 24 | + href={getInternalUrl(routes[0].app, networkId)} |
| 25 | + data-testid={`app-link-${menu}`} |
| 26 | + > |
| 27 | + {label} |
| 28 | + </Button> |
| 29 | + ))} |
| 30 | + </Box> |
| 31 | + ) |
| 32 | +} |
0 commit comments