mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 13:20:31 +00:00
- feat: Highlight inactive accounts in data-table.
- feat: Separate accounts list and table order.
This commit is contained in:
@@ -19,32 +19,29 @@ export const fetchAccountTypes = () => {
|
||||
});
|
||||
};
|
||||
|
||||
export const fetchAccountsList = ({ query } = {}) => {
|
||||
export const fetchAccountsList = () => {
|
||||
return (dispatch) =>
|
||||
new Promise((resolve, reject) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_LOADING,
|
||||
});
|
||||
const query = { column_sort_by: 'name', sort_order: 'asc' };
|
||||
|
||||
ApiService.get('accounts', { params: query })
|
||||
.then((response) => {
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_PAGE_SET,
|
||||
accounts: response.data.accounts,
|
||||
customViewId: response.data.customViewId,
|
||||
});
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_ITEMS_SET,
|
||||
accounts: response.data.accounts,
|
||||
});
|
||||
dispatch({
|
||||
type: t.ACCOUNTS_LIST_SET,
|
||||
payload: {
|
||||
accounts: response.data.accounts,
|
||||
}
|
||||
})
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
dispatch({
|
||||
type: t.SET_DASHBOARD_REQUEST_COMPLETED,
|
||||
});
|
||||
reject(error);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -5,6 +5,7 @@ import { createTableQueryReducers } from 'store/queryReducers';
|
||||
const initialState = {
|
||||
items: {},
|
||||
views: {},
|
||||
list: [],
|
||||
accountsTypes: [],
|
||||
accountsById: {},
|
||||
tableQuery: {
|
||||
@@ -40,6 +41,11 @@ const accountsReducer = createReducer(initialState, {
|
||||
};
|
||||
},
|
||||
|
||||
[t.ACCOUNTS_LIST_SET]: (state, action) => {
|
||||
const { accounts } = action.payload;
|
||||
state.list = accounts.map(account => account.id);
|
||||
},
|
||||
|
||||
[t.ACCOUNT_TYPES_LIST_SET]: (state, action) => {
|
||||
state.accountsTypes = action.account_types;
|
||||
},
|
||||
|
||||
@@ -6,6 +6,9 @@ const accountsDataSelector = (state) => state.accounts.items;
|
||||
const accountsCurrentViewSelector = (state) => state.accounts.currentViewId;
|
||||
const accountIdPropSelector = (state, props) => props.accountId;
|
||||
|
||||
const accountsListSelector = state => state.accounts.list;
|
||||
|
||||
|
||||
export const getAccountsItems = createSelector(
|
||||
accountsViewsSelector,
|
||||
accountsDataSelector,
|
||||
@@ -19,6 +22,14 @@ export const getAccountsItems = createSelector(
|
||||
},
|
||||
);
|
||||
|
||||
export const getAccountsListFactory = () => createSelector(
|
||||
accountsListSelector,
|
||||
accountsDataSelector,
|
||||
(accounts, accountsItems) => {
|
||||
return pickItemsFromIds(accountsItems, accounts);
|
||||
},
|
||||
)
|
||||
|
||||
export const getAccountById = createSelector(
|
||||
accountsDataSelector,
|
||||
accountIdPropSelector,
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
export default {
|
||||
ACCOUNT_TYPES_LIST_SET: 'ACCOUNT_TYPES_LIST_SET',
|
||||
ACCOUNTS_PAGE_SET: 'ACCOUNTS_PAGE_SET',
|
||||
ACCOUNTS_LIST_SET: 'ACCOUNTS_LIST_SET',
|
||||
ACCOUNTS_ITEMS_SET: 'ACCOUNTS_ITEMS_SET',
|
||||
ACCOUNT_SET: 'ACCOUNT_SET',
|
||||
ACCOUNT_DELETE: 'ACCOUNT_DELETE',
|
||||
|
||||
Reference in New Issue
Block a user