From af8d38e3a6cb62c7917f5ef92fef34a833ca44c3 Mon Sep 17 00:00:00 2001 From: sean-brydon <55134778+sean-brydon@users.noreply.github.com> Date: Tue, 26 Mar 2024 12:51:03 +0000 Subject: [PATCH] feat: hide if team slider if org is private (#14201) * feat: hide if org is private * fix: allow owners and admin to see page --- apps/web/pages/availability/index.tsx | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/apps/web/pages/availability/index.tsx b/apps/web/pages/availability/index.tsx index 30cd99df98..3f8cb3c195 100644 --- a/apps/web/pages/availability/index.tsx +++ b/apps/web/pages/availability/index.tsx @@ -10,6 +10,7 @@ import { AvailabilitySliderTable } from "@calcom/features/timezone-buddy/compone import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { HttpError } from "@calcom/lib/http-error"; +import { MembershipRole } from "@calcom/prisma/enums"; import type { RouterOutputs } from "@calcom/trpc/react"; import { trpc } from "@calcom/trpc/react"; import useMeQuery from "@calcom/trpc/react/hooks/useMeQuery"; @@ -174,6 +175,7 @@ export default function AvailabilityPage() { const router = useRouter(); const pathname = usePathname(); const me = useMeQuery(); + const { data } = trpc.viewer.organizations.listCurrent.useQuery(); // Get a new searchParams string by merging the current // searchParams with a provided key/value pair @@ -186,6 +188,16 @@ export default function AvailabilityPage() { }, [searchParams] ); + + const isOrgAdminOrOwner = + data && (data.user.role === MembershipRole.OWNER || data.user.role === MembershipRole.ADMIN); + const isOrgAndPrivate = data?.isOrganization && data.isPrivate; + const toggleGroupOptions = [{ value: "mine", label: t("my_availability") }]; + + if (!isOrgAndPrivate || isOrgAdminOrOwner) { + toggleGroupOptions.push({ value: "team", label: t("team_availability") }); + } + return (