mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
fix: tables with custom views.
This commit is contained in:
@@ -42,6 +42,7 @@ function EstimateActionsBar({
|
||||
history.push('/estimates/new');
|
||||
};
|
||||
|
||||
// Handle tab change.
|
||||
const handleTabChange = (customView) => {
|
||||
setEstimatesTableState({
|
||||
customViewId: customView.id || null,
|
||||
|
||||
@@ -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';
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -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}
|
||||
|
||||
@@ -46,9 +46,7 @@ function InvoiceActionsBar({
|
||||
|
||||
// Handle views tab change.
|
||||
const handleTabChange = (customView) => {
|
||||
setInvoicesTableState({
|
||||
customViewId: customView.id || null,
|
||||
});
|
||||
setInvoicesTableState({ customViewId: customView.id || null });
|
||||
};
|
||||
|
||||
return (
|
||||
@@ -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';
|
||||
|
||||
@@ -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 />
|
||||
|
||||
@@ -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 =
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user