mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
fix: items issues.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
import t from 'store/types';
|
||||
|
||||
export const setItemsTableState = (queries) => {
|
||||
return {
|
||||
type: t.ITEMS_TABLE_STATE_SET,
|
||||
payload: { queries },
|
||||
};
|
||||
};
|
||||
|
||||
export const setSelectedRowsItems = () => {};
|
||||
|
||||
@@ -1,16 +1,17 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import {
|
||||
createTableQueryReducers,
|
||||
} from 'store/journalNumber.reducer';
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
|
||||
const initialState = {
|
||||
tableQuery: {
|
||||
tableState: {
|
||||
pageSize: 12,
|
||||
page: 1,
|
||||
pageIndex: 0,
|
||||
filters: [],
|
||||
},
|
||||
selectedRows: [],
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
...createTableQueryReducers('ITEMS'),
|
||||
...createTableStateReducers('ITEMS'),
|
||||
});
|
||||
@@ -1,17 +1,17 @@
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
|
||||
const itemsTableQuerySelector = (state) => state.items.tableQuery;
|
||||
const itemsTableStateSelector = (state) => state.items.tableState;
|
||||
|
||||
// Get items table query marged with location query.
|
||||
export const getItemsTableQueryFactory = () =>
|
||||
// Get items table state marged with location query.
|
||||
export const getItemsTableStateFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
paginationLocationQuery,
|
||||
itemsTableQuerySelector,
|
||||
(locationQuery, tableQuery) => {
|
||||
itemsTableStateSelector,
|
||||
(locationQuery, tableState) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableQuery,
|
||||
...tableState,
|
||||
};
|
||||
},
|
||||
);
|
||||
|
||||
@@ -1,17 +1,4 @@
|
||||
|
||||
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_LOADING: 'ITEMS_TABLE_LOADING',
|
||||
ITEMS_SET_CURRENT_VIEW: 'ITEMS_SET_CURRENT_VIEW',
|
||||
ITEMS_BULK_DELETE: 'ITEMS_BULK_DELETE',
|
||||
ITEM_SELECTED_ROWS_SET: 'ITEM_SELECTED_ROWS_SET',
|
||||
};
|
||||
ITEMS_TABLE_STATE_SET: 'ITEMS/TABLE_STATE_SET',
|
||||
};
|
||||
18
client/src/store/tableState.reducer.js
Normal file
18
client/src/store/tableState.reducer.js
Normal file
@@ -0,0 +1,18 @@
|
||||
|
||||
const TYPES = {
|
||||
TABLE_STATE_SET: 'TABLE_STATE_SET',
|
||||
};
|
||||
|
||||
export const createTableStateReducers = (RESOURCE_NAME) => ({
|
||||
/**
|
||||
* Resource table state set.
|
||||
*/
|
||||
[`${RESOURCE_NAME}/${TYPES.TABLE_STATE_SET}`]: (state, action) => {
|
||||
const { queries } = action.payload;
|
||||
|
||||
state.tableState = {
|
||||
...state.tableState,
|
||||
...queries,
|
||||
};
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user