import { WorkspaceProvider } from '@/contexts/workspace';
import Navigation from './Navigation';
import prisma from '@/lib/prisma';

export default async function WorkspaceLayout({ children, params }: Readonly<{ children: React.ReactNode; params: { workspace: string } }>) {
	const workspace = await prisma.workspace.findUnique({
		where: {
			slug: params.workspace,
		},
	});
	if (!workspace) return <div>Workspace not found</div>;

	return (
		<WorkspaceProvider workspace={workspace}>
			<div className="bg-white flex justify-center py-2 pt-4 border-b-2 border-b-gray-200">
				<div className="container">
					<div className="border-t-[1px] border-t-gray-200">
						<Navigation />
					</div>
				</div>
			</div>
			<div className="bg-[#ECEFF1] overflow-y-auto flex-grow">
				<div className="container">{children}</div>
			</div>
		</WorkspaceProvider>
	);
}
