From 97630e8addb0fab87286300b4a4728254c1dee95 Mon Sep 17 00:00:00 2001 From: Morgan <33722304+ThyMinimalDev@users.noreply.github.com> Date: Tue, 10 Sep 2024 18:05:22 +0300 Subject: [PATCH] fix: prevent creating multiple platform orgs (#16564) * fix: prevent creating multiple platform orgs * fixup! fix: prevent creating multiple platform orgs * fixup! fixup! fix: prevent creating multiple platform orgs * Bust cache in CI * Update schema.prisma --------- Co-authored-by: Hariom Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> --- .../web/pages/settings/platform/new/index.tsx | 35 +++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/apps/web/pages/settings/platform/new/index.tsx b/apps/web/pages/settings/platform/new/index.tsx index 459f4f7009..dfffff7d29 100644 --- a/apps/web/pages/settings/platform/new/index.tsx +++ b/apps/web/pages/settings/platform/new/index.tsx @@ -1,15 +1,50 @@ +import { useRouter } from "next/navigation"; + import LicenseRequired from "@calcom/features/ee/common/components/LicenseRequired"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { Meta } from "@calcom/ui"; +import { SkeletonContainer, SkeletonText } from "@calcom/ui"; import { getServerSideProps } from "@lib/settings/organizations/new/getServerSideProps"; import PageWrapper from "@components/PageWrapper"; +import usePlatformMe from "@components/settings/platform/hooks/usePlatformMe"; import CreateNewOrganizationPage, { LayoutWrapper } from "~/settings/platform/new/create-new-view"; +const SkeletonLoader = () => { + return ( + +
+ + + +
+
+ ); +}; + const Page = () => { const { t } = useLocale(); + const { isFetching, data: platformMe } = usePlatformMe(); + const router = useRouter(); + + if (isFetching) { + return ; + } + + if (platformMe?.organization?.id) { + // if user has a platform org redirect to platform dashboard + if (platformMe?.organization?.isPlatform) { + router.push("/settings/platform"); + // user has a regular org redirect to organization settings + } else { + router.push("/settings/organizations/profile"); + } + // display loader while redirection is happening + return ; + } + return (