mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 21:30:31 +00:00
feat: cashflow service.
This commit is contained in:
21
src/store/CashflowAccounts/CashflowAccounts.actions.js
Normal file
21
src/store/CashflowAccounts/CashflowAccounts.actions.js
Normal file
@@ -0,0 +1,21 @@
|
||||
import t from 'store/types';
|
||||
|
||||
/**
|
||||
* Sets the cashflow accounts table state.
|
||||
*/
|
||||
export const setCashflowAccountsTableState = (queries) => {
|
||||
return {
|
||||
type: t.CASHFLOW_ACCOUNTS_TABLE_STATE_SET,
|
||||
payload: { queries },
|
||||
};
|
||||
};
|
||||
|
||||
/**
|
||||
* Resets the cashflow accounts table state.
|
||||
*/
|
||||
export const resetCashflowAccountsTableState = () => {
|
||||
return {
|
||||
type: t.CASHFLOW_ACCOUNTS_TABLE_STATE_RESET,
|
||||
};
|
||||
};
|
||||
|
||||
31
src/store/CashflowAccounts/CashflowAccounts.reducer.js
Normal file
31
src/store/CashflowAccounts/CashflowAccounts.reducer.js
Normal file
@@ -0,0 +1,31 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer, purgeStoredState } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
import t from 'store/types';
|
||||
|
||||
export const defaultTableQuery = {
|
||||
filterRoles: [],
|
||||
};
|
||||
|
||||
const initialState = {
|
||||
tableState: defaultTableQuery,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:cashflow_accounts';
|
||||
|
||||
const CONFIG = {
|
||||
key: STORAGE_KEY,
|
||||
whitelist: [],
|
||||
storage,
|
||||
};
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('CASHFLOW_ACCOUNTS', defaultTableQuery),
|
||||
|
||||
[t.RESET]: () => {
|
||||
purgeStoredState(CONFIG);
|
||||
},
|
||||
});
|
||||
|
||||
export default persistReducer(CONFIG, reducerInstance);
|
||||
19
src/store/CashflowAccounts/CashflowAccounts.selectors.js
Normal file
19
src/store/CashflowAccounts/CashflowAccounts.selectors.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { paginationLocationQuery } from 'store/selectors';
|
||||
import { createDeepEqualSelector } from 'utils';
|
||||
|
||||
// Accounts table state selector
|
||||
const cashflowAccountsTableStateSelector = (state, props) =>
|
||||
state.cashflowAccounts.tableState;
|
||||
|
||||
// Get accounts table state marged with location query.
|
||||
export const getCashflowAccountsTableStateFactory = () =>
|
||||
createDeepEqualSelector(
|
||||
paginationLocationQuery,
|
||||
cashflowAccountsTableStateSelector,
|
||||
(locationQuery, tableState) => {
|
||||
return {
|
||||
...locationQuery,
|
||||
...tableState,
|
||||
};
|
||||
},
|
||||
);
|
||||
5
src/store/CashflowAccounts/CashflowAccounts.types.js
Normal file
5
src/store/CashflowAccounts/CashflowAccounts.types.js
Normal file
@@ -0,0 +1,5 @@
|
||||
|
||||
export default {
|
||||
CASHFLOW_ACCOUNTS_TABLE_STATE_SET: 'CASHFLOW_ACCOUNTS/TABLE_STATE_SET',
|
||||
CASHFLOW_ACCOUNTS_TABLE_STATE_RESET: 'CASHFLOW_ACCOUNTS/TABLE_STATE_RESET',
|
||||
};
|
||||
@@ -6,6 +6,7 @@ import authentication from './authentication/authentication.reducer';
|
||||
import dashboard from './dashboard/dashboard.reducer';
|
||||
import users from './users/users.reducer';
|
||||
import accounts from './accounts/accounts.reducer';
|
||||
import cashflowAccounts from './CashflowAccounts/CashflowAccounts.reducer';
|
||||
import fields from './customFields/customFields.reducer';
|
||||
import items from './items/items.reducer';
|
||||
import views from './customViews/customViews.reducer';
|
||||
@@ -39,6 +40,7 @@ const appReducer = combineReducers({
|
||||
dashboard,
|
||||
users,
|
||||
accounts,
|
||||
cashflowAccounts,
|
||||
manualJournals,
|
||||
fields,
|
||||
views,
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import authentication from './authentication/authentication.types';
|
||||
import accounts from './accounts/accounts.types';
|
||||
import cashflowAccounts from './CashflowAccounts/CashflowAccounts.types';
|
||||
import accounting from './manualJournals/manualJournals.types';
|
||||
import currencies from './currencies/currencies.types';
|
||||
import customFields from './customFields/customFields.types';
|
||||
@@ -32,6 +33,7 @@ import plans from './plans/plans.types';
|
||||
export default {
|
||||
...authentication,
|
||||
...accounts,
|
||||
...cashflowAccounts,
|
||||
...currencies,
|
||||
...customFields,
|
||||
...customViews,
|
||||
|
||||
Reference in New Issue
Block a user