Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 17 additions & 9 deletions site/src/pages/UserSettingsPage/AccountPage/AccountPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@ import { useQuery } from "react-query";
import { groupsForUser } from "api/queries/groups";
import { useOrganizationId } from "hooks";
import { useAuth } from "components/AuthProvider/AuthProvider";
import { useDashboard } from "components/Dashboard/DashboardProvider";

import { Stack } from "@mui/system";
import { AccountUserGroups } from "./AccountUserGroups";
import { AccountForm } from "./AccountForm";
import { Section } from "components/SettingsLayout/Section";

export const AccountPage: FC = () => {
const { updateProfile, updateProfileError, isUpdatingProfile } = useAuth();
const permissions = usePermissions();

const me = useMe();
const permissions = usePermissions();
const organizationId = useOrganizationId();
const groupsQuery = useQuery(groupsForUser(organizationId, me.id));
const { updateProfile, updateProfileError, isUpdatingProfile } = useAuth();
const { entitlements } = useDashboard();

const hasGroupsFeature = entitlements.features.user_role_management.enabled;
const groupsQuery = useQuery({
...groupsForUser(organizationId, me.id),
enabled: hasGroupsFeature,
});

return (
<Stack spacing={6}>
Expand All @@ -33,11 +39,13 @@ export const AccountPage: FC = () => {
</Section>

{/* Has <Section> embedded inside because its description is dynamic */}
<AccountUserGroups
groups={groupsQuery.data}
loading={groupsQuery.isLoading}
error={groupsQuery.error}
/>
{hasGroupsFeature && (
<AccountUserGroups
groups={groupsQuery.data}
loading={groupsQuery.isLoading}
error={groupsQuery.error}
/>
)}
</Stack>
);
};
Expand Down