fix: add fallback to data needed in SettingsLayout (#17004)

This commit is contained in:
Benny Joo
2024-10-08 15:51:38 -04:00
committed by GitHub
parent e6f81d09c8
commit 670b82fd23
@@ -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";
@@ -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
@@ -393,8 +396,8 @@ const SettingsSidebarContainer = ({
className = "",
navigationIsOpenedOnMobile,
bannersHeight,
currentOrg,
otherTeams,
currentOrg: currentOrgProp,
otherTeams: otherTeamsProp,
}: SettingsSidebarContainerProps) => {
const searchParams = useCompatSearchParams();
const { t } = useLocale();
@@ -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) {