mirror of
https://github.com/umami-software/umami.git
synced 2026-02-14 01:25:37 +01:00
17 lines
639 B
TypeScript
17 lines
639 B
TypeScript
'use client';
|
|
import { Loading } from '@umami/react-zen';
|
|
import { createContext, type ReactNode } from 'react';
|
|
import { useBoardQuery } from '@/components/hooks/queries/useBoardQuery';
|
|
import type { Board } from '@/generated/prisma/client';
|
|
|
|
export const BoardContext = createContext<Board>(null);
|
|
|
|
export function BoardProvider({ boardId, children }: { boardId: string; children: ReactNode }) {
|
|
const { data: board, isFetching, isLoading } = useBoardQuery(boardId);
|
|
|
|
if (isFetching && isLoading) {
|
|
return <Loading placement="absolute" />;
|
|
}
|
|
|
|
return <BoardContext.Provider value={board}>{children}</BoardContext.Provider>;
|
|
}
|