fix: items issues.

This commit is contained in:
a.bouhuolia
2021-02-09 10:23:52 +02:00
parent 01aaa9de25
commit 083bf36c6b
18 changed files with 316 additions and 318 deletions

View File

@@ -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 = () => {};

View File

@@ -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'),
});

View File

@@ -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,
};
},
);

View File

@@ -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',
};

View 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,
};
},
});