@@ -5,19 +5,25 @@ import { useQuery } from "react-query";
5
5
import { groupsForUser } from "api/queries/groups" ;
6
6
import { useOrganizationId } from "hooks" ;
7
7
import { useAuth } from "components/AuthProvider/AuthProvider" ;
8
+ import { useDashboard } from "components/Dashboard/DashboardProvider" ;
8
9
9
10
import { Stack } from "@mui/system" ;
10
11
import { AccountUserGroups } from "./AccountUserGroups" ;
11
12
import { AccountForm } from "./AccountForm" ;
12
13
import { Section } from "components/SettingsLayout/Section" ;
13
14
14
15
export const AccountPage : FC = ( ) => {
15
- const { updateProfile, updateProfileError, isUpdatingProfile } = useAuth ( ) ;
16
- const permissions = usePermissions ( ) ;
17
-
18
16
const me = useMe ( ) ;
17
+ const permissions = usePermissions ( ) ;
19
18
const organizationId = useOrganizationId ( ) ;
20
- const groupsQuery = useQuery ( groupsForUser ( organizationId , me . id ) ) ;
19
+ const { updateProfile, updateProfileError, isUpdatingProfile } = useAuth ( ) ;
20
+ const { entitlements } = useDashboard ( ) ;
21
+
22
+ const hasGroupsFeature = entitlements . features . user_role_management . enabled ;
23
+ const groupsQuery = useQuery ( {
24
+ ...groupsForUser ( organizationId , me . id ) ,
25
+ enabled : hasGroupsFeature ,
26
+ } ) ;
21
27
22
28
return (
23
29
< Stack spacing = { 6 } >
@@ -33,11 +39,13 @@ export const AccountPage: FC = () => {
33
39
</ Section >
34
40
35
41
{ /* Has <Section> embedded inside because its description is dynamic */ }
36
- < AccountUserGroups
37
- groups = { groupsQuery . data }
38
- loading = { groupsQuery . isLoading }
39
- error = { groupsQuery . error }
40
- />
42
+ { hasGroupsFeature && (
43
+ < AccountUserGroups
44
+ groups = { groupsQuery . data }
45
+ loading = { groupsQuery . isLoading }
46
+ error = { groupsQuery . error }
47
+ />
48
+ ) }
41
49
</ Stack >
42
50
) ;
43
51
} ;
0 commit comments