Skip to content

Commit

Permalink
fix: add fallback to data needed in SettingsLayout (#17004)
Browse files Browse the repository at this point in the history
  • Loading branch information
hbjORbj authored Oct 8, 2024
1 parent e6f81d0 commit 670b82f
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions packages/features/settings/appDir/SettingsLayoutAppDirClient.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import React, { useEffect, useState, useMemo } from "react";
import { useOrgBranding } from "@calcom/features/ee/organizations/context/provider";
import Shell from "@calcom/features/shell/Shell";
import { classNames } from "@calcom/lib";
import { HOSTED_CAL_FEATURES, WEBAPP_URL } from "@calcom/lib/constants";
import { HOSTED_CAL_FEATURES, IS_CALCOM, WEBAPP_URL } from "@calcom/lib/constants";
import { getPlaceholderAvatar } from "@calcom/lib/defaultAvatarImage";
import { getUserAvatarUrl } from "@calcom/lib/getAvatarUrl";
import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams";
Expand Down Expand Up @@ -141,6 +141,9 @@ tabs.find((tab) => {
// TODO: Enable dsync for self hosters
// tab.children?.push({ name: "directory_sync", href: "/settings/security/dsync" });
}
if (tab.name === "admin" && IS_CALCOM) {
tab.children?.push({ name: "create_license_key", href: "/settings/license-key/new" });
}
});

// The following keys are assigned to admin only
Expand Down Expand Up @@ -393,8 +396,8 @@ const SettingsSidebarContainer = ({
className = "",
navigationIsOpenedOnMobile,
bannersHeight,
currentOrg,
otherTeams,
currentOrg: currentOrgProp,
otherTeams: otherTeamsProp,
}: SettingsSidebarContainerProps) => {
const searchParams = useCompatSearchParams();
const { t } = useLocale();
Expand All @@ -405,7 +408,16 @@ const SettingsSidebarContainer = ({
teamMenuOpen: boolean;
}[]
>();

const session = useSession();
const { data: _currentOrg } = trpc.viewer.organizations.listCurrent.useQuery(undefined, {
enabled: !!session.data?.user?.org && !currentOrgProp,
});

const { data: _otherTeams } = trpc.viewer.organizations.listOtherTeams.useQuery(undefined, {
enabled: !!session.data?.user?.org && !otherTeamsProp,
});
const currentOrg = currentOrgProp ?? _currentOrg;
const otherTeams = otherTeamsProp ?? _otherTeams;
// Same as above but for otherTeams
useEffect(() => {
if (otherTeams) {
Expand Down

0 comments on commit 670b82f

Please sign in to comment.