mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
fix(preformance): Optimize preformance of virtualized list. fix(preformance): Optimize financial reports preformance.
50 lines
1.3 KiB
JavaScript
50 lines
1.3 KiB
JavaScript
import { createReducer } from '@reduxjs/toolkit';
|
|
import t from 'store/types';
|
|
|
|
const initialState = {
|
|
token: '',
|
|
organization: '',
|
|
organizationId: null,
|
|
user: '',
|
|
tenant: {},
|
|
locale: '',
|
|
errors: [],
|
|
};
|
|
|
|
export default createReducer(initialState, {
|
|
[t.LOGIN_SUCCESS]: (state, action) => {
|
|
const { token, user, tenant } = action.payload;
|
|
state.token = token;
|
|
state.user = user;
|
|
state.organization = tenant.organization_id;
|
|
state.organizationId = tenant.id;
|
|
state.tenant = tenant;
|
|
},
|
|
|
|
[t.LOGIN_FAILURE]: (state, action) => {
|
|
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 const isAuthenticated = (state) => !!state.authentication.token;
|
|
export const hasErrorType = (state, errorType) => {
|
|
return state.authentication.errors.find((e) => e.type === errorType);
|
|
};
|
|
|
|
export const isTenantSeeded = (state) => !!state.tenant.seeded_at;
|
|
export const isTenantBuilt = (state) => !!state.tenant.initialized_at;
|
|
|
|
export const isTenantHasSubscription = () => false;
|
|
export const isTenantSubscriptionExpired = () => false; |