Skip to content

Commit d416bbd

Browse files
feat(hooks): add useActiveTeamInfo hook for team info abstraction
1 parent 6e94f25 commit d416bbd

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import { useAppState } from 'app/overmind';
2+
3+
export type ActiveTeamInfo = {
4+
id: string | null;
5+
name: string | null;
6+
sdkWorkspace: boolean;
7+
frozen: boolean;
8+
};
9+
10+
/**
11+
* Hook to access active team information.
12+
*
13+
* This hook provides an abstraction layer over the Overmind state,
14+
* making it easier to migrate away from Overmind in the future.
15+
*
16+
* @returns Active team information or null values if no team is active
17+
*/
18+
export const useActiveTeamInfo = (): ActiveTeamInfo => {
19+
const { activeTeamInfo } = useAppState();
20+
21+
if (!activeTeamInfo) {
22+
return {
23+
id: null,
24+
name: null,
25+
sdkWorkspace: false,
26+
frozen: false,
27+
};
28+
}
29+
30+
return {
31+
id: activeTeamInfo.id,
32+
name: activeTeamInfo.name,
33+
sdkWorkspace: activeTeamInfo.sdkWorkspace ?? false,
34+
frozen: activeTeamInfo.frozen,
35+
};
36+
};
37+

0 commit comments

Comments
 (0)