mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
feat: move accounts data-table component to components file.
This commit is contained in:
@@ -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) => {
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import t from 'store/types';
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist'
|
||||
import storage from 'redux-persist/lib/storage' // defaults to localStorage for web
|
||||
|
||||
const initialState = {
|
||||
pageTitle: '',
|
||||
@@ -12,7 +14,7 @@ const initialState = {
|
||||
requestsLoading: 0,
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
[t.CHANGE_DASHBOARD_PAGE_TITLE]: (state, action) => {
|
||||
state.pageTitle = action.pageTitle;
|
||||
},
|
||||
@@ -65,6 +67,18 @@ export default createReducer(initialState, {
|
||||
}
|
||||
});
|
||||
|
||||
export default persistReducer({
|
||||
key: 'bigcapital:dashboard',
|
||||
blacklist: [
|
||||
'pageTitle',
|
||||
'pageSubtitle',
|
||||
'pageHint',
|
||||
'preferencesPageTitle',
|
||||
'topbarEditViewId'
|
||||
],
|
||||
storage,
|
||||
}, reducerInstance);
|
||||
|
||||
export const getDialogPayload = (state, dialogName) => {
|
||||
return typeof state.dashboard.dialogs[dialogName] !== 'undefined'
|
||||
? state.dashboard.dialogs[dialogName].payload : {};
|
||||
|
||||
Reference in New Issue
Block a user