import React, { useState } from 'react'; import { UPDATE_NOTIFICATION_CATEGORY } from 'app/modules/notifications/store/updateNotification/updateNotifications.constants'; import { NavTab } from './navTab'; import { POOL_SECTION } from 'app/modules/pools/store'; import { dashboardPoolRoute, ROUTER } from 'app/common/routes'; import { some } from 'lodash'; import { Collapsible } from 'app/shared/components/collapsible/collapsible'; import * as Text from 'app/shared/components/text/text'; import cx from 'classnames'; interface Props { userPools: any; updateNotifications: any; section: any; additionalRouteParams?: { [key: string]: string; } } const mapSectionNameToNotificationCategory = (sectionName) => { switch (sectionName) { case POOL_SECTION.FORECAST: return UPDATE_NOTIFICATION_CATEGORY.FORECAST; case POOL_SECTION.DOCUMENTS: return UPDATE_NOTIFICATION_CATEGORY.DOCUMENTS; default: return false; } }; export const TopNavTabList = ({ userPools, updateNotifications, section, additionalRouteParams }: Props) => { const [ isListExpanded, changeListExpansion ] = useState(false); const poolRoute = section ? `${section}PoolRoute` : dashboardPoolRoute; const actualPoolName = userPools.find((userPools) => location.pathname.includes(userPools.id))?.name; const poolTabsList = userPools.map((pool) => { const notificationCategory = mapSectionNameToNotificationCategory(section); return
; }); return ( <>
{poolTabsList}
changeListExpansion(!isListExpanded)} >
{actualPoolName}
{ poolTabsList }
); };