mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 06: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:
@@ -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',
|
||||
};
|
||||
Reference in New Issue
Block a user