Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2f291f7

Browse files
committed
add selector for the current org
1 parent db11f0e commit 2f291f7

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

‎client/packages/lowcoder/src/redux/selectors/orgSelectors.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { Org } from "@lowcoder-ee/constants/orgConstants";
22
import { getUser } from "./usersSelectors";
33
import { AppState } from "redux/reducers";
4+
import { getHomeOrg } from "./applicationSelector";
45

56
export const getOrgUsers = (state: AppState) => {
67
return state.ui.org.orgUsers;
@@ -33,8 +34,14 @@ export const getOrgLastMonthApiUsage = (state: AppState) => {
3334
// Add to usersSelectors.ts
3435
export const getWorkspaces = (state: AppState) => state.ui.users.workspaces;
3536

36-
export const getCurrentOrg = (state: AppState): Org | undefined => {
37-
const user = getUser(state);
38-
const workspaces = getWorkspaces(state);
39-
return workspaces.items.find(org => org.id === user.currentOrgId);
37+
export const getCurrentOrg = (state: AppState): Pick<Org, 'id' | 'name'> | undefined => {
38+
const homeOrg = getHomeOrg(state);
39+
if (!homeOrg) {
40+
return undefined;
41+
}
42+
43+
return {
44+
id: homeOrg.id,
45+
name: homeOrg.name,
46+
};
4047
};

0 commit comments

Comments
 (0)