Scheduling infrastructure for absolutely everyone.
feat: hide if team slider if org is private (#14201)
sean-brydonaf8d38e3a6cb
diff --git a/apps/web/pages/availability/index.tsx b/apps/web/pages/availability/index.tsxindex 30cd99df98a..3f8cb3c195d 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/componeimport { 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 (<div><Shell@@ -204,15 +216,12 @@ export default function AvailabilityPage() {if (!value) return;router.push(`${pathname}?${createQueryString("type", value)}`);}}- options={[- { value: "mine", label: t("my_availability") },- { value: "team", label: t("team_availability") },- ]}+ options={toggleGroupOptions}/><NewScheduleButton /></div>}>- {searchParams?.get("type") === "team" ? (+ {searchParams?.get("type") === "team" && (!isOrgAndPrivate || isOrgAdminOrOwner) ? (<AvailabilitySliderTable userTimeFormat={me?.data?.timeFormat ?? null} />) : (<AvailabilityListWithQuery />