import type { PropsWithChildren } from "react"; import { notFound } from "next/navigation"; import { AppShellMain } from "@mantine/core"; import { TRPCError } from "@trpc/server"; import { logger } from "@homarr/log"; import { GlobalItemServerDataRunner } from "@homarr/widgets"; import { MainHeader } from "~/components/layout/header"; import { BoardLogoWithTitle } from "~/components/layout/logo/board-logo"; import { ClientShell } from "~/components/layout/shell"; import type { Board } from "./_types"; import { BoardProvider } from "./(content)/_context"; import type { Params } from "./(content)/_creator"; import { BoardMantineProvider } from "./(content)/_theme"; interface CreateBoardLayoutProps { headerActions: JSX.Element; getInitialBoardAsync: (params: TParams) => Promise; isBoardContentPage: boolean; } export const createBoardLayout = ({ headerActions, getInitialBoardAsync: getInitialBoard, isBoardContentPage, }: CreateBoardLayoutProps) => { const Layout = async ({ params, children, }: PropsWithChildren<{ params: TParams; }>) => { const initialBoard = await getInitialBoard(params).catch((error) => { if (error instanceof TRPCError && error.code === "NOT_FOUND") { logger.warn(error); notFound(); } throw error; }); return ( } actions={headerActions} hasNavigation={false} /> {children} ); }; return Layout; };