mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-18 05:40:31 +00:00
feat(ManualJournals): Auto-increment.
fix(BillPayment): Validate the opened payment bills. fix(redux): presist redux state. fix(useRequestQuery): hook.
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
@@ -10,6 +10,17 @@ const initialState = {
|
||||
},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const STORAGE_KEY = 'bigcapital:bills';
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('BILLS'),
|
||||
});
|
||||
});
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
@@ -10,6 +12,17 @@ const initialState = {
|
||||
},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('ESTIMATES'),
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:estimates';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
@@ -10,6 +12,17 @@ const initialState = {
|
||||
},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('INVOICES'),
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:invoices';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
@@ -11,6 +13,17 @@ const initialState = {
|
||||
},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('PAYMENT_MADES'),
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:paymentMades';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
@@ -10,6 +12,17 @@ const initialState = {
|
||||
},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('PAYMENT_RECEIVES'),
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:paymentReceives';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -1,14 +1,25 @@
|
||||
import { createReducer} from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
|
||||
},
|
||||
tableState: {},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('ACCOUNTS'),
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:accounts';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -2,13 +2,8 @@ import t from 'store/types';
|
||||
|
||||
export const setLogin = ({ user, token, tenant }) => ({
|
||||
type: t.LOGIN_SUCCESS,
|
||||
payload: {
|
||||
user,
|
||||
token,
|
||||
tenant,
|
||||
},
|
||||
payload: { user, token, tenant, },
|
||||
});
|
||||
|
||||
export const setLogout = () => ({
|
||||
type: t.LOGOUT,
|
||||
});
|
||||
export const setLogout = () => ({ type: t.LOGOUT });
|
||||
export const setStoreReset = () => ({ type: t.RESET });
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import t from 'store/types';
|
||||
|
||||
const initialState = {
|
||||
@@ -11,7 +13,9 @@ const initialState = {
|
||||
errors: [],
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const STORAGE_KEY = 'bigcapital:authentication';
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
[t.LOGIN_SUCCESS]: (state, action) => {
|
||||
const { token, user, tenant } = action.payload;
|
||||
state.token = token;
|
||||
@@ -25,19 +29,20 @@ export default createReducer(initialState, {
|
||||
state.errors = action.errors;
|
||||
},
|
||||
|
||||
[t.LOGOUT]: (state) => {
|
||||
state.token = '';
|
||||
state.user = {};
|
||||
state.organization = '';
|
||||
state.organizationId = null;
|
||||
state.tenant = {};
|
||||
},
|
||||
|
||||
[t.LOGIN_CLEAR_ERRORS]: (state) => {
|
||||
state.errors = [];
|
||||
},
|
||||
});
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
blacklist: ['errors'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
export const isAuthenticated = (state) => !!state.authentication.token;
|
||||
export const hasErrorType = (state, errorType) => {
|
||||
return state.authentication.errors.find((e) => e.type === errorType);
|
||||
|
||||
@@ -5,4 +5,5 @@ export default {
|
||||
LOGIN_FAILURE: 'LOGIN_FAILURE',
|
||||
LOGOUT: 'LOGOUT',
|
||||
LOGIN_CLEAR_ERRORS: 'LOGIN_CLEAR_ERRORS',
|
||||
RESET: 'RESET',
|
||||
};
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
compose,
|
||||
} from 'redux';
|
||||
import thunkMiddleware from 'redux-thunk';
|
||||
import { persistStore, persistReducer } from 'redux-persist';
|
||||
import { persistStore, persistReducer, purgeStoredState } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import monitorReducerEnhancer from 'store/enhancers/monitorReducer';
|
||||
import loggerMiddleware from 'middleware/logger';
|
||||
@@ -44,7 +44,7 @@ const createStoreFactory = (initialState = {}) => {
|
||||
|--------------------------------------------------
|
||||
*/
|
||||
const store = createReduxStore(
|
||||
persistReducer(persistConfig, rootReducer),
|
||||
rootReducer,
|
||||
initialState,
|
||||
composeEnhancers(applyMiddleware(...middleware), ...enhancers),
|
||||
);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
|
||||
const initialState = {
|
||||
@@ -8,6 +10,17 @@ const initialState = {
|
||||
},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('CUSTOMERS'),
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:estimates';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -1,7 +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
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
|
||||
const initialState = {
|
||||
pageTitle: '',
|
||||
@@ -18,6 +18,8 @@ const initialState = {
|
||||
backLink: false,
|
||||
};
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:dashboard';
|
||||
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
[t.CHANGE_DASHBOARD_PAGE_TITLE]: (state, action) => {
|
||||
state.pageTitle = action.pageTitle;
|
||||
@@ -117,14 +119,10 @@ const reducerInstance = createReducer(initialState, {
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: 'bigcapital:dashboard',
|
||||
blacklist: [
|
||||
'pageTitle',
|
||||
'pageSubtitle',
|
||||
'pageHint',
|
||||
'preferencesPageTitle',
|
||||
'topbarEditViewId',
|
||||
'backLink',
|
||||
key: STORAGE_KEY,
|
||||
whitelist: [
|
||||
'sidebarExpended',
|
||||
'previousSidebarExpended',
|
||||
],
|
||||
storage,
|
||||
},
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
@@ -10,6 +10,17 @@ const initialState = {
|
||||
},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('EXPENSES'),
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:expenses';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
@@ -12,6 +12,17 @@ const initialState = {
|
||||
selectedRows: [],
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('INVENTORY_ADJUSTMENTS'),
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:inventoryAdjustments';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
@@ -8,6 +10,18 @@ const initialState = {
|
||||
tableState: {},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('ITEMS_CATEGORIES'),
|
||||
});
|
||||
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:itemCategories';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
@@ -12,6 +12,17 @@ const initialState = {
|
||||
selectedRows: [],
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('ITEMS'),
|
||||
});
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:items';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
@@ -1,7 +1,7 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import { createTableStateReducers } from 'store/tableState.reducer';
|
||||
|
||||
const initialState = {
|
||||
tableState: {
|
||||
@@ -10,6 +10,17 @@ const initialState = {
|
||||
},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('MANUAL_JOURNALS'),
|
||||
});
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:manualJournals';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
@@ -10,6 +12,17 @@ const initialState = {
|
||||
},
|
||||
};
|
||||
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('RECEIPTS'),
|
||||
});
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:receipts';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
import { combineReducers } from 'redux';
|
||||
|
||||
import types from './types';
|
||||
|
||||
import authentication from './authentication/authentication.reducer';
|
||||
import dashboard from './dashboard/dashboard.reducer';
|
||||
import users from './users/users.reducer';
|
||||
@@ -30,7 +32,7 @@ import subscriptions from './subscription/subscription.reducer';
|
||||
import inventoryAdjustments from './inventoryAdjustments/inventoryAdjustment.reducer';
|
||||
import plans from './plans/plans.reducer';
|
||||
|
||||
export default combineReducers({
|
||||
const appReducer = combineReducers({
|
||||
authentication,
|
||||
organizations,
|
||||
subscriptions,
|
||||
@@ -61,3 +63,13 @@ export default combineReducers({
|
||||
inventoryAdjustments,
|
||||
plans
|
||||
});
|
||||
|
||||
// Reset the state of a redux store
|
||||
const rootReducer = (state, action) => {
|
||||
if (action.type === types.RESET) {
|
||||
state = undefined;
|
||||
}
|
||||
return appReducer(state, action)
|
||||
}
|
||||
|
||||
export default rootReducer;
|
||||
15
client/src/store/vendors/vendors.reducer.js
vendored
15
client/src/store/vendors/vendors.reducer.js
vendored
@@ -1,4 +1,6 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { persistReducer } from 'redux-persist';
|
||||
import storage from 'redux-persist/lib/storage';
|
||||
import {
|
||||
createTableStateReducers,
|
||||
} from 'store/tableState.reducer';
|
||||
@@ -9,6 +11,17 @@ const initialState = {
|
||||
pageIndex: 0,
|
||||
},
|
||||
};
|
||||
export default createReducer(initialState, {
|
||||
const reducerInstance = createReducer(initialState, {
|
||||
...createTableStateReducers('VENDORS'),
|
||||
});
|
||||
|
||||
const STORAGE_KEY = 'bigcapital:vendors';
|
||||
|
||||
export default persistReducer(
|
||||
{
|
||||
key: STORAGE_KEY,
|
||||
whitelist: ['tableState'],
|
||||
storage,
|
||||
},
|
||||
reducerInstance,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user