import React, {useEffect} from 'react'; import { useHistory } from 'react-router'; import { connect } from 'react-redux'; import { Alignment, Navbar, NavbarGroup, Tabs, Tab, Button } from '@blueprintjs/core'; import { useParams } from 'react-router-dom'; import Icon from 'components/Icon'; import { Link, withRouter } from 'react-router-dom'; import { compose } from 'utils'; import {useUpdateEffect} from 'hooks'; import withItemsActions from 'containers/Items/withItemsActions'; import withDashboard from 'containers/Dashboard/withDashboard'; import withViewDetail from 'containers/Views/withViewDetails'; import withItems from 'containers/Items/withItems'; import { FormattedMessage as T, useIntl } from 'react-intl'; function ItemsViewsTabs({ // #withViewDetail viewId, viewItem, // #withItems itemsViews, // #withItemsActions addItemsTableQueries, changeItemsCurrentView, // #withDashboard setTopbarEditView, changePageSubtitle, // #props onViewChanged, }) { const history = useHistory(); const { custom_view_id: customViewId } = useParams(); const handleClickNewView = () => { setTopbarEditView(null); history.push('/custom_views/items/new'); }; const handleViewLinkClick = () => { setTopbarEditView(customViewId); } useEffect(() => { changeItemsCurrentView(customViewId || -1); setTopbarEditView(customViewId); changePageSubtitle((customViewId && viewItem) ? viewItem.name : ''); addItemsTableQueries({ custom_view_id: customViewId || null, }); return () => { setTopbarEditView(null); changeItemsCurrentView(-1); changePageSubtitle(''); }; }, [customViewId]); useUpdateEffect(() => { onViewChanged && onViewChanged(customViewId); }, [customViewId]); const tabs = itemsViews.map(view => { const baseUrl = '/items'; const link = ( {view.name} ); return (); }); return ( } onClick={handleViewLinkClick} /> {tabs}