mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 21:00:31 +00:00
BC-5 fix: general tab of preferences form submitting.
This commit is contained in:
24
client/src/store/authentication/authentication.selectors.js
Normal file
24
client/src/store/authentication/authentication.selectors.js
Normal file
@@ -0,0 +1,24 @@
|
||||
import { defaultTo } from 'lodash';
|
||||
import { createSelector } from '@reduxjs/toolkit';
|
||||
|
||||
const getCurrentOrganizationId = (state) => state.authentication.organization;
|
||||
const getCurrentTenantId = (state) => state.authentication.organizationId;
|
||||
const getOrganizationsMap = (state) => state.organizations.data;
|
||||
|
||||
// Retrieve organization tenant id.
|
||||
export const getOrganizationTenantIdFactory = () =>
|
||||
createSelector(getCurrentTenantId, (tenantId) => tenantId);
|
||||
|
||||
// Retrieve organization id.
|
||||
export const getOrganizationIdFactory = () =>
|
||||
createSelector(getCurrentOrganizationId, (tenantId) => tenantId);
|
||||
|
||||
// Retrieve current organization meta object.
|
||||
export const getCurrentOrganizationFactory = () =>
|
||||
createSelector(
|
||||
getCurrentTenantId,
|
||||
getOrganizationsMap,
|
||||
(tenantId, organizationsMap) => {
|
||||
return defaultTo(organizationsMap[tenantId], {});
|
||||
},
|
||||
);
|
||||
@@ -1,4 +1,5 @@
|
||||
import { createReducer } from '@reduxjs/toolkit';
|
||||
import { omit } from 'lodash';
|
||||
import t from 'store/types';
|
||||
|
||||
const initialState = {
|
||||
@@ -16,7 +17,8 @@ const reducer = createReducer(initialState, {
|
||||
organizations.forEach((organization) => {
|
||||
_data[organization.id] = {
|
||||
...state.data[organization.id],
|
||||
...organization,
|
||||
...organization.metadata,
|
||||
...omit(organization, ['metadata']),
|
||||
};
|
||||
_dataByOrganizationId[organization.organization_id] = organization.id;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user