diff --git a/apps/web/app/(use-page-wrapper)/settings/(settings-layout)/SettingsLayoutAppDirClient.tsx b/apps/web/app/(use-page-wrapper)/settings/(settings-layout)/SettingsLayoutAppDirClient.tsx index 3cf08edc37..2f37eaa93a 100644 --- a/apps/web/app/(use-page-wrapper)/settings/(settings-layout)/SettingsLayoutAppDirClient.tsx +++ b/apps/web/app/(use-page-wrapper)/settings/(settings-layout)/SettingsLayoutAppDirClient.tsx @@ -16,7 +16,6 @@ import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage"; import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl"; import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams"; import { useLocale } from "@calcom/lib/hooks/useLocale"; -import type { OrganizationRepository } from "@calcom/lib/server/repository/organization"; import { IdentityProvider, UserPermissionRole } from "@calcom/prisma/enums"; import { trpc } from "@calcom/trpc/react"; import classNames from "@calcom/ui/classNames"; @@ -273,8 +272,6 @@ interface SettingsSidebarContainerProps { className?: string; navigationIsOpenedOnMobile?: boolean; bannersHeight?: number; - currentOrg: SettingsLayoutProps["currentOrg"]; - otherTeams: SettingsLayoutProps["otherTeams"]; } const TeamListCollapsible = () => { @@ -441,10 +438,9 @@ const SettingsSidebarContainer = ({ className = "", navigationIsOpenedOnMobile, bannersHeight, - currentOrg: currentOrgProp, - otherTeams: otherTeamsProp, }: SettingsSidebarContainerProps) => { const searchParams = useCompatSearchParams(); + const orgBranding = useOrgBranding(); const { t } = useLocale(); const [otherTeamMenuState, setOtherTeamMenuState] = useState< { @@ -453,19 +449,17 @@ const SettingsSidebarContainer = ({ }[] >(); const session = useSession(); - const { data: _currentOrg } = trpc.viewer.organizations.listCurrent.useQuery(undefined, { - enabled: !!session.data?.user?.org && !currentOrgProp, + const { data } = trpc.viewer.delegationCredential.check.useQuery(undefined, { + enabled: !!session.data?.user?.org, }); - const tabsWithPermissions = useTabs({ - isDelegationCredentialEnabled: !!_currentOrg?.features?.delegationCredential, + isDelegationCredentialEnabled: data?.hasDelegationCredential ?? false, }); - const { data: _otherTeams } = trpc.viewer.organizations.listOtherTeams.useQuery(undefined, { - enabled: !!session.data?.user?.org && !otherTeamsProp, + const { data: otherTeams } = trpc.viewer.organizations.listOtherTeams.useQuery(undefined, { + enabled: !!session.data?.user?.org, }); - const currentOrg = currentOrgProp ?? _currentOrg; - const otherTeams = otherTeamsProp ?? _otherTeams; + // Same as above but for otherTeams useEffect(() => { if (otherTeams) { @@ -485,8 +479,7 @@ const SettingsSidebarContainer = ({ } }, [searchParams?.get("id"), otherTeams]); - const isOrgAdminOrOwner = - currentOrg && currentOrg?.user?.role && ["OWNER", "ADMIN"].includes(currentOrg?.user?.role); + const isOrgAdminOrOwner = checkAdminOrOwner(orgBranding?.role); return (