* add a layoutfile to use-page-wrapper route group * refactor and move bookings status page to route group * improve logic in pagesAndRewritePaths * fix * add use client directive * move /403 and /500 * move /auth/error * move /connect-and-join * move /enterprise * move /maintenance * move /more * move /upgrade * chore: remove WithLayout from 8 low-risk single pages (#18745) * move /403 and /500 * move /auth/error * move /connect-and-join * move /enterprise * move /maintenance * move /more * move /upgrade * move /availability pages * move /event-types pages * move /insights pages * move /apps to use-page-wrapper group * move /getting-started to use-page-wrapper group * move /signup to use-page-wrapper group * move /workflows to use-page-wrapper group * move /video pages to use-page-wrapper group * pass dehydratedState in layout * pass dehydratedState in layout * move settings/(settings-layout) to use-page-wrapper * move settings/(admin-layout) to use-page-wrapper * move remaining settings pages to (use-page-wrapper) * fix test * remove unused code * remove unused files * fix type check * remove test tag * remove page * RSC should not default export client components
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
"use client";
|
|
|
|
import { usePathname, useRouter } from "next/navigation";
|
|
import type { ComponentProps } from "react";
|
|
import React, { useEffect } from "react";
|
|
|
|
import type Shell from "@calcom/features/shell/Shell";
|
|
import { UserPermissionRole } from "@calcom/prisma/enums";
|
|
import { ErrorBoundary } from "@calcom/ui";
|
|
|
|
export type AdminLayoutProps = {
|
|
children: React.ReactNode;
|
|
userRole: UserPermissionRole | "INACTIVE_ADMIN" | undefined;
|
|
} & ComponentProps<typeof Shell>;
|
|
export default function AdminLayoutAppDirClient({ userRole, children }: AdminLayoutProps) {
|
|
const pathname = usePathname();
|
|
const router = useRouter();
|
|
|
|
// Force redirect on component level
|
|
useEffect(() => {
|
|
if (userRole !== UserPermissionRole.ADMIN) {
|
|
router.replace("/settings/my-account/profile");
|
|
}
|
|
}, [userRole, router]);
|
|
|
|
const isAppsPage = pathname?.startsWith("/settings/admin/apps");
|
|
return (
|
|
<div className="divide-subtle bg-default mx-auto flex max-w-4xl flex-row divide-y">
|
|
<div className={isAppsPage ? "min-w-0" : "flex flex-1 [&>*]:flex-1"}>
|
|
<ErrorBoundary>{children}</ErrorBoundary>
|
|
</div>
|
|
</div>
|
|
);
|
|
}
|