mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-20 23:00:34 +00:00
feat: application booting.
This commit is contained in:
@@ -29,12 +29,12 @@ export const fetchOrganizations = () => (dispatch) =>
|
||||
|
||||
export const setOrganizationSetupCompleted =
|
||||
(congrats) => (dispatch, getState) => {
|
||||
const organizationId = getState().authentication.organizationId;
|
||||
const tenantId = getState().authentication.tenantId;
|
||||
|
||||
dispatch({
|
||||
type: t.SET_ORGANIZATION_CONGRATS,
|
||||
payload: {
|
||||
organizationId,
|
||||
tenantId,
|
||||
congrats,
|
||||
},
|
||||
});
|
||||
|
||||
@@ -27,10 +27,10 @@ const reducer = createReducer(initialState, {
|
||||
},
|
||||
|
||||
[t.SET_ORGANIZATION_CONGRATS]: (state, action) => {
|
||||
const { organizationId, congrats } = action.payload;
|
||||
const { tenantId, congrats } = action.payload;
|
||||
|
||||
state.data[organizationId] = {
|
||||
...(state.data[organizationId] || {}),
|
||||
state.data[tenantId] = {
|
||||
...(state.data[tenantId] || {}),
|
||||
is_congrats: !!congrats,
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,50 +1,39 @@
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
|
||||
const organizationSelector = (state, props) => state.organizations.data[props.organizationId];
|
||||
const organizationSelector = (state, props) => {
|
||||
const tenantId = state.organizations.byOrganizationId[props.organizationId];
|
||||
return state.organizations.data[tenantId];
|
||||
};
|
||||
|
||||
export const getOrganizationByIdFactory = () => createSelector(
|
||||
organizationSelector,
|
||||
(organization) => organization
|
||||
);
|
||||
export const getOrganizationByIdFactory = () =>
|
||||
createSelector(organizationSelector, (organization) => organization);
|
||||
|
||||
export const isOrganizationSeededFactory = () => createSelector(
|
||||
organizationSelector,
|
||||
(organization) => {
|
||||
export const isOrganizationSeededFactory = () =>
|
||||
createSelector(organizationSelector, (organization) => {
|
||||
return !!organization?.seeded_at;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
export const isOrganizationBuiltFactory = () => createSelector(
|
||||
organizationSelector,
|
||||
(organization) => {
|
||||
export const isOrganizationBuiltFactory = () =>
|
||||
createSelector(organizationSelector, (organization) => {
|
||||
return !!organization?.initialized_at;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
export const isOrganizationReadyFactory = () => createSelector(
|
||||
organizationSelector,
|
||||
(organization) => {
|
||||
export const isOrganizationReadyFactory = () =>
|
||||
createSelector(organizationSelector, (organization) => {
|
||||
return organization?.is_ready;
|
||||
},
|
||||
);
|
||||
});
|
||||
|
||||
export const isOrganizationSubscribedFactory = () => createSelector(
|
||||
organizationSelector,
|
||||
(organization) => {
|
||||
export const isOrganizationSubscribedFactory = () =>
|
||||
createSelector(organizationSelector, (organization) => {
|
||||
return organization?.subscriptions?.length > 0;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
export const isOrganizationCongratsFactory = () => createSelector(
|
||||
organizationSelector,
|
||||
(organization) => {
|
||||
export const isOrganizationCongratsFactory = () =>
|
||||
createSelector(organizationSelector, (organization) => {
|
||||
return !!organization?.is_congrats;
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
export const isOrganizationBuildRunningFactory = () => createSelector(
|
||||
organizationSelector,
|
||||
(organization) => {
|
||||
export const isOrganizationBuildRunningFactory = () =>
|
||||
createSelector(organizationSelector, (organization) => {
|
||||
return !!organization?.is_build_running;
|
||||
}
|
||||
)
|
||||
});
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
|
||||
export default {
|
||||
ORGANIZATION_SET: 'ORGANIZATION_SET',
|
||||
ORGANIZATIONS_LIST_SET: 'ORGANIZATIONS_LIST_SET',
|
||||
SET_ORGANIZATION_CONGRATS: 'SET_ORGANIZATION_CONGRATS'
|
||||
};
|
||||
Reference in New Issue
Block a user