Files
bigcapital/client/src/containers/Customers/CustomersLanding/CustomersViewsTabs.js
a.bouhuolia c68b4ca9ba refactoring: expenses landing list.
refactoring: customers landing list.
refactoring: vendors landing list.
refactoring: manual journals landing list.
2021-02-10 18:35:19 +02:00

61 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
customViewId={customersTableState.customViewId}
resourceName={'customers'}
tabs={tabs}
onChange={handleTabsChange}
/>
</NavbarGroup>
</Navbar>
);
}
export default compose(
withDashboardActions,
withCustomersActions,
withCustomers(({ customersTableState }) => ({ customersTableState })),
)(CustomersViewsTabs);