mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
59 lines
1.5 KiB
JavaScript
59 lines
1.5 KiB
JavaScript
import React, { useMemo } from 'react';
|
|
import { Alignment, Navbar, NavbarGroup } from '@blueprintjs/core';
|
|
import { pick } from 'lodash';
|
|
|
|
import { DashboardViewsTabs } from 'components';
|
|
|
|
import withCustomers from './withCustomers';
|
|
import withCustomersActions from './withCustomersActions';
|
|
import withDashboardActions from 'containers/Dashboard/withDashboardActions';
|
|
|
|
import { useCustomersListContext } from './CustomersListProvider';
|
|
import { compose } from 'utils';
|
|
|
|
/**
|
|
* Customers views tabs.
|
|
*/
|
|
function CustomersViewsTabs({
|
|
// #withCustomersActions
|
|
setCustomersTableState,
|
|
|
|
// #withCustomers
|
|
customersTableState,
|
|
}) {
|
|
// Customers list context.
|
|
const { customersViews } = useCustomersListContext();
|
|
|
|
const tabs = useMemo(
|
|
() =>
|
|
customersViews.map((view) => pick(view, ['name', 'id']), [
|
|
customersViews,
|
|
]),
|
|
[customersViews],
|
|
);
|
|
|
|
// Handle tabs change.
|
|
const handleTabsChange = (viewId) => {
|
|
setCustomersTableState({ customViewId: viewId || null });
|
|
};
|
|
|
|
return (
|
|
<Navbar className="navbar--dashboard-views">
|
|
<NavbarGroup align={Alignment.LEFT}>
|
|
<DashboardViewsTabs
|
|
currentViewId={customersTableState.customViewId}
|
|
resourceName={'customers'}
|
|
tabs={tabs}
|
|
onChange={handleTabsChange}
|
|
/>
|
|
</NavbarGroup>
|
|
</Navbar>
|
|
);
|
|
}
|
|
|
|
export default compose(
|
|
withDashboardActions,
|
|
withCustomersActions,
|
|
withCustomers(({ customersTableState }) => ({ customersTableState })),
|
|
)(CustomersViewsTabs);
|