fix: tables with custom views.

This commit is contained in:
a.bouhuolia
2021-02-21 14:21:07 +02:00
parent df2d215071
commit 4fe00d59d8
20 changed files with 44 additions and 58 deletions

View File

@@ -42,6 +42,7 @@ function EstimateActionsBar({
history.push('/estimates/new');
};
// Handle tab change.
const handleTabChange = (customView) => {
setEstimatesTableState({
customViewId: customView.id || null,

View File

@@ -1,8 +1,6 @@
import React, { useCallback } from 'react';
import classNames from 'classnames';
import { useHistory } from 'react-router-dom';
import { CLASSES } from 'common/classes';
import { compose } from 'utils';
import { DataTable } from 'components';

View File

@@ -23,21 +23,21 @@ function EstimateViewTabs({
// Estimates list context.
const { estimatesViews } = useEstimatesListContext();
// Estimates views.
const tabs = estimatesViews.map((view) => ({
...pick(view, ['name', 'id']),
}));
const handleTabsChange = (viewId) => {
setEstimatesTableState({
customViewId: viewId || null,
});
// Handle tab change.
const handleTabsChange = (customViewId) => {
setEstimatesTableState({ customViewId: customViewId || null });
};
return (
<Navbar className={'navbar--dashboard-views'}>
<NavbarGroup align={Alignment.LEFT}>
<DashboardViewsTabs
customViewId={estimatesTableState.customViewId}
currentViewId={estimatesTableState.customViewId}
resourceName={'estimates'}
tabs={tabs}
onChange={handleTabsChange}

View File

@@ -31,9 +31,9 @@ function InvoiceViewTabs({
}));
// Handle tab change.
const handleTabsChange = (customView) => {
const handleTabsChange = (customViewId) => {
setInvoicesTableState({
customViewId: customView.id || null,
customViewId: customViewId || null,
});
};
@@ -46,7 +46,7 @@ function InvoiceViewTabs({
<Navbar className={'navbar--dashboard-views'}>
<NavbarGroup align={Alignment.LEFT}>
<DashboardViewsTabs
customViewId={invoicesTableState.customViewId}
currentViewId={invoicesTableState.customViewId}
resourceName={'invoices'}
tabs={tabs}
onNewViewTabClick={handleClickNewView}

View File

@@ -46,9 +46,7 @@ function InvoiceActionsBar({
// Handle views tab change.
const handleTabChange = (customView) => {
setInvoicesTableState({
customViewId: customView.id || null,
});
setInvoicesTableState({ customViewId: customView.id || null });
};
return (

View File

@@ -1,9 +1,7 @@
import React, { useCallback } from 'react';
import { useHistory } from 'react-router-dom';
import classNames from 'classnames';
import InvoicesEmptyStatus from './InvoicesEmptyStatus';
import { CLASSES } from 'common/classes';
import { compose } from 'utils';
import { DataTable } from 'components';

View File

@@ -3,7 +3,7 @@ import React from 'react';
import 'style/pages/SaleInvoice/List.scss';
import { DashboardContentTable, DashboardPageContent } from 'components';
import InvoiceActionsBar from './InvoiceActionsBar';
import InvoicesActionsBar from './InvoicesActionsBar';
import { InvoicesListProvider } from './InvoicesListProvider';
import InvoiceViewTabs from './InvoiceViewTabs';
@@ -26,7 +26,7 @@ function InvoicesList({
<InvoicesListProvider
query={transformTableStateToQuery(invoicesTableState)}
>
<InvoiceActionsBar />
<InvoicesActionsBar />
<DashboardPageContent>
<InvoiceViewTabs />

View File

@@ -8,7 +8,7 @@ const InvoicesListContext = createContext();
/**
* Accounts chart data provider.
*/
function InvoicesListProvider({ accountsTableQuery, ...props }) {
function InvoicesListProvider({ query, ...props }) {
// Fetch accounts resource views and fields.
const { data: invoicesViews, isFetching: isViewsLoading } = useResourceViews(
'sale_invoices',
@@ -25,7 +25,7 @@ function InvoicesListProvider({ accountsTableQuery, ...props }) {
data: { invoices, pagination, filterMeta },
isFetching: isInvoicesFetching,
isLoading: isInvoicesLoading,
} = useInvoices(accountsTableQuery, { keepPreviousData: true });
} = useInvoices(query, { keepPreviousData: true });
// Detarmines the datatable empty status.
const isEmptyStatus =

View File

@@ -4,7 +4,7 @@ import {
} from 'store/Invoice/invoices.actions';
const mapDipatchToProps = (dispatch) => ({
setInvoicesTableState: (query) => setInvoicesTableState(query),
setInvoicesTableState: (queries) => dispatch(setInvoicesTableState(queries)),
});
export default connect(null, mapDipatchToProps);

View File

@@ -44,9 +44,9 @@ function ReceiptActionsBar({
};
// Handle the active tab change.
const handleTabChange = (viewId) => {
const handleTabChange = (customView) => {
setReceiptsTableState({
csutomViewId: viewId.id || null,
customViewId: customView.id || null,
});
};

View File

@@ -27,9 +27,9 @@ function ReceiptViewTabs({
}));
// Handles the active tab chaning.
const handleTabsChange = (customView) => {
const handleTabsChange = (customViewId) => {
setReceiptsTableState({
customViewId: customView.id || null,
customViewId: customViewId || null,
});
};
@@ -37,7 +37,7 @@ function ReceiptViewTabs({
<Navbar className={'navbar--dashboard-views'}>
<NavbarGroup align={Alignment.LEFT}>
<DashboardViewsTabs
initialViewId={receiptTableState.customViewId}
currentViewId={receiptTableState.customViewId}
tabs={tabs}
resourceName={'receipts'}
onChange={handleTabsChange}