fix: resources table issues.

This commit is contained in:
a.bouhuolia
2021-02-21 16:03:17 +02:00
parent 350a148747
commit f96166514b
13 changed files with 68 additions and 29 deletions

View File

@@ -9,6 +9,7 @@ import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import BillsEmptyStatus from './BillsEmptyStatus';
import withBills from './withBills';
import withBillActions from './withBillsActions';
import withSettings from 'containers/Settings/withSettings';
import withAlertsActions from 'containers/Alert/withAlertActions';
@@ -22,6 +23,9 @@ function BillsDataTable({
// #withBillsActions
setBillsTableState,
// #withBills
billsTableState,
// #withAlerts
openAlert,
}) {
@@ -73,6 +77,7 @@ function BillsDataTable({
<DataTable
columns={columns}
data={bills}
initialState={billsTableState}
loading={isBillsLoading}
headerLoading={isBillsLoading}
progressBarLoading={isBillsFetching}
@@ -96,6 +101,7 @@ function BillsDataTable({
}
export default compose(
withBills(({ billsTableState }) => ({ billsTableState })),
withBillActions,
withAlertsActions,
withSettings(({ organizationSettings }) => ({

View File

@@ -101,7 +101,9 @@ function PaymentMadeForm() {
const onError = ({
response: {
error: { data: errors },
error: {
data: { errors },
},
},
}) => {
const getError = (errorType) => errors.find((e) => e.type === errorType);
@@ -116,9 +118,7 @@ function PaymentMadeForm() {
};
if (!isNewMode) {
editPaymentMadeMutate([paymentMadeId, form])
.then(onSaved)
.catch(onError);
editPaymentMadeMutate([paymentMadeId, form]).then(onSaved).catch(onError);
} else {
createPaymentMadeMutate(form).then(onSaved).catch(onError);
}

View File

@@ -12,7 +12,7 @@ const PaymentMadesListContext = createContext();
/**
* Accounts chart data provider.
*/
function PaymentMadesListProvider({ accountsTableQuery, ...props }) {
function PaymentMadesListProvider({ query, ...props }) {
// Fetch accounts resource views and fields.
const {
data: paymentMadesViews,
@@ -30,7 +30,7 @@ function PaymentMadesListProvider({ accountsTableQuery, ...props }) {
data: { paymentMades, pagination, filterMeta },
isLoading: isPaymentsLoading,
isFetching: isPaymentsFetching,
} = usePaymentMades(accountsTableQuery, { keepPreviousData: true });
} = usePaymentMades(query, { keepPreviousData: true });
// Detarmines the datatable empty status.
const isEmptyStatus =

View File

@@ -9,6 +9,7 @@ import TableSkeletonRows from 'components/Datatable/TableSkeletonRows';
import TableSkeletonHeader from 'components/Datatable/TableHeaderSkeleton';
import withPaymentMadeActions from './withPaymentMadeActions';
import withPaymentMade from './withPaymentMade';
import withSettings from 'containers/Settings/withSettings';
import withAlertsActions from 'containers/Alert/withAlertActions';
import { usePaymentMadesTableColumns, ActionsMenu } from './components';
@@ -19,7 +20,10 @@ import { usePaymentMadesListContext } from './PaymentMadesListProvider';
*/
function PaymentMadesTable({
// #withPaymentMadeActions
addPaymentMadesTableQueries,
setPaymentMadesTableState,
// #withPaymentMade
paymentMadesTableState,
// #withAlerts
openAlert,
@@ -52,9 +56,9 @@ function PaymentMadesTable({
// Handle datatable fetch data once the table state change.
const handleDataTableFetchData = useCallback(
({ pageIndex, pageSize, sortBy }) => {
addPaymentMadesTableQueries({ pageIndex, pageSize, sortBy });
setPaymentMadesTableState({ pageIndex, pageSize, sortBy });
},
[addPaymentMadesTableQueries],
[setPaymentMadesTableState],
);
// Display empty status instead of the table.
@@ -66,6 +70,7 @@ function PaymentMadesTable({
<DataTable
columns={columns}
data={paymentMades}
initialState={paymentMadesTableState}
onFetchData={handleDataTableFetchData}
loading={isPaymentsLoading}
headerLoading={isPaymentsLoading}
@@ -91,6 +96,7 @@ function PaymentMadesTable({
export default compose(
withPaymentMadeActions,
withPaymentMade(({ paymentMadesTableState }) => ({ paymentMadesTableState })),
withAlertsActions,
withSettings(({ organizationSettings }) => ({
baseCurrency: organizationSettings?.baseCurrency,