@@ -26,6 +26,7 @@ export const createBoardContentPage = <
|
||||
layout: createBoardLayout({
|
||||
headerActions: <BoardContentHeaderActions />,
|
||||
getInitialBoard,
|
||||
isBoardContentPage: true,
|
||||
}),
|
||||
page: () => {
|
||||
return <ClientBoard />;
|
||||
|
||||
@@ -8,4 +8,5 @@ export default createBoardLayout<{ locale: string; name: string }>({
|
||||
async getInitialBoard({ name }) {
|
||||
return await api.board.getBoardByName({ name });
|
||||
},
|
||||
isBoardContentPage: false,
|
||||
});
|
||||
|
||||
@@ -17,11 +17,13 @@ import { BoardMantineProvider } from "./(content)/_theme";
|
||||
interface CreateBoardLayoutProps<TParams extends Params> {
|
||||
headerActions: JSX.Element;
|
||||
getInitialBoard: (params: TParams) => Promise<Board>;
|
||||
isBoardContentPage: boolean;
|
||||
}
|
||||
|
||||
export const createBoardLayout = <TParams extends Params>({
|
||||
headerActions,
|
||||
getInitialBoard,
|
||||
isBoardContentPage,
|
||||
}: CreateBoardLayoutProps<TParams>) => {
|
||||
const Layout = async ({
|
||||
params,
|
||||
@@ -39,7 +41,10 @@ export const createBoardLayout = <TParams extends Params>({
|
||||
});
|
||||
|
||||
return (
|
||||
<GlobalItemServerDataRunner board={initialBoard}>
|
||||
<GlobalItemServerDataRunner
|
||||
board={initialBoard}
|
||||
shouldRun={isBoardContentPage}
|
||||
>
|
||||
<BoardProvider initialBoard={initialBoard}>
|
||||
<BoardMantineProvider>
|
||||
<ClientShell hasNavigation={false}>
|
||||
|
||||
@@ -10,10 +10,17 @@ import { GlobalItemServerDataProvider } from "./provider";
|
||||
type Board = RouterOutputs["board"]["getDefaultBoard"];
|
||||
|
||||
type Props = PropsWithChildren<{
|
||||
shouldRun: boolean;
|
||||
board: Board;
|
||||
}>;
|
||||
|
||||
export const GlobalItemServerDataRunner = ({ board, children }: Props) => {
|
||||
export const GlobalItemServerDataRunner = ({
|
||||
board,
|
||||
shouldRun,
|
||||
children,
|
||||
}: Props) => {
|
||||
if (!shouldRun) return children;
|
||||
|
||||
const allItems = board.sections.flatMap((section) => section.items);
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user