import React, { ReactNode } from 'react';
import Sidebar from '../sidebar/Sidebar';
import { useSidebarContext } from '../sidebar/SidebarContext';
import { usePanelManager } from './PanelManagerContext';

interface DocumentsLayoutProps {
  sidebarProps?: Record<string, unknown>;
  children?: ReactNode;
}

const DocumentsLayout: React.FC<DocumentsLayoutProps> = ({ sidebarProps = {}, children }) => {
  const { collapsed } = useSidebarContext();
  const { sidebarSuppressed } = usePanelManager();
  const sidebarHidden = collapsed || sidebarSuppressed;
  return (
    <main className={`documents-main${sidebarHidden ? ' documents-main--sidebar-hidden' : ''}`}>
      {!sidebarHidden ? <Sidebar {...sidebarProps} /> : null}
      {children}
    </main>
  );
};

export default DocumentsLayout;
