feat: move accounts data-table component to components file.

This commit is contained in:
Ahmed Bouhuolia
2020-11-24 11:34:28 +02:00
parent 9779591029
commit 431a6be377
6 changed files with 42 additions and 85 deletions

View File

@@ -1,11 +1,13 @@
import t from 'store/types';
import { createReducer} from '@reduxjs/toolkit';
import { createTableQueryReducers } from 'store/queryReducers';
import { listToTree } from 'utils';
const initialState = {
items: {},
views: {},
list: [],
listTree: [],
accountsTypes: [],
accountsById: {},
tableQuery: {
@@ -44,6 +46,15 @@ const accountsReducer = createReducer(initialState, {
[t.ACCOUNTS_LIST_SET]: (state, action) => {
const { accounts } = action.payload;
state.list = accounts.map(account => account.id);
state.listTree = listToTree(accounts, {
parentFieldKey: 'parent_account_id',
idFieldKey: 'id',
nodeMapper: (item) => ({
id: item.id,
parent_account_id: item.parent_account_id,
children: [],
}),
});
},
[t.ACCOUNT_TYPES_LIST_SET]: (state, action) => {