mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 13:50:31 +00:00
feat: datatables pagination.
This commit is contained in:
@@ -30,13 +30,17 @@ export const fetchItems = ({ query }) => {
|
||||
customViewId: response.data?.filter_meta?.view?.custom_view_id,
|
||||
paginationMeta: response.data.pagination,
|
||||
});
|
||||
dispatch({
|
||||
type: t.ITEMS_PAGINATION_SET,
|
||||
payload: {
|
||||
pagination: response.data.pagination,
|
||||
customViewId: response.data.customViewId || -1,
|
||||
}
|
||||
})
|
||||
dispatch({
|
||||
type: t.ITEMS_TABLE_LOADING,
|
||||
payload: { loading: false },
|
||||
});
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
import t from 'store/types';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { getItemsViewPages } from 'store/items/items.selectors';
|
||||
import { createTableQueryReducers } from 'store/queryReducers';
|
||||
import {
|
||||
viewPaginationSetReducer,
|
||||
createTableQueryReducers,
|
||||
} from 'store/journalNumber.reducer';
|
||||
|
||||
const initialState = {
|
||||
items: {},
|
||||
@@ -9,12 +12,15 @@ const initialState = {
|
||||
itemsRelation: {},
|
||||
currentPage: 1,
|
||||
currentViewId: -1,
|
||||
tableQuery: {},
|
||||
bulkActions: {},
|
||||
loading: false,
|
||||
tableQuery: {
|
||||
page_size: 12,
|
||||
page: 1,
|
||||
},
|
||||
};
|
||||
|
||||
const itemsReducer = createReducer(initialState, {
|
||||
export default createReducer(initialState, {
|
||||
[t.ITEMS_SET]: (state, action) => {
|
||||
const _items = {};
|
||||
|
||||
@@ -111,9 +117,10 @@ const itemsReducer = createReducer(initialState, {
|
||||
});
|
||||
state.items = items;
|
||||
},
|
||||
});
|
||||
|
||||
export default createTableQueryReducers('items', itemsReducer);
|
||||
...viewPaginationSetReducer(t.ITEMS_PAGINATION_SET),
|
||||
...createTableQueryReducers('ITEMS'),
|
||||
});
|
||||
|
||||
export const getItemById = (state, id) => {
|
||||
return state.items.items[id];
|
||||
|
||||
@@ -2,12 +2,13 @@ export default {
|
||||
ITEMS_SET: 'ITEMS_SET',
|
||||
ITEM_SET: 'ITEM_SET',
|
||||
ITEMS_PAGE_SET: 'ITEMS_PAGE_SET',
|
||||
ITEMS_PAGINATION_SET: 'ITEMS_PAGINATION_SET',
|
||||
ITEM_DELETE: 'ITEM_DELETE',
|
||||
ITEM_BULK_ACTION_ADD: 'ITEM_BULK_ACTION_ADD',
|
||||
ITEM_BULK_ACTION_REMOVE: 'ITEM_BULK_ACTION_REMOVE',
|
||||
|
||||
ITEMS_TABLE_QUERY_SET: 'ITEMS_TABLE_QUERY_SET',
|
||||
ITEMS_TABLE_QUERIES_ADD: 'ITEMS_TABLE_QUERIES_ADD',
|
||||
ITEMS_TABLE_QUERY_SET: 'ITEMS/TABLE_QUERY_SET',
|
||||
ITEMS_TABLE_QUERIES_ADD: 'ITEMS/TABLE_QUERIES_ADD',
|
||||
|
||||
ITEMS_TABLE_LOADING: 'ITEMS_TABLE_LOADING',
|
||||
ITEMS_SET_CURRENT_VIEW: 'ITEMS_SET_CURRENT_VIEW',
|
||||
|
||||
Reference in New Issue
Block a user