import { Layout } from '@arco-design/web-react'
import { OverviewPage } from './overview'
import { ProjectInspector } from './projects/project-inspector'
import { ProjectRail } from './projects/project-rail'
import { ProjectSidebar } from './projects/project-sidebar'
import { ProjectStatusbar } from './projects/project-statusbar'
import { ProjectTopbar } from './projects/project-topbar'
import type { ChannelKey, Project, Theme } from './projects/project-types'

const { Content } = Layout

export function ProjectPage({
  activeProject,
  activeChannel,
  selectedItem,
  theme,
  onSelectProject,
  onSelectChannel,
  onSelectItem,
  onToggleTheme,
}: {
  activeProject: Project
  activeChannel: ChannelKey
  selectedItem: string
  theme: Theme
  onSelectProject: (project: Project) => void
  onSelectChannel: (key: ChannelKey) => void
  onSelectItem: (title: string) => void
  onToggleTheme: () => void
}) {
  return (
    <Layout className="workbench-shell">
      <ProjectTopbar theme={theme} onToggleTheme={onToggleTheme} />

      <Layout className="workbench-main" hasSider>
        <ProjectRail activeProject={activeProject} onSelectProject={onSelectProject} />

        <ProjectSidebar
          activeProject={activeProject}
          activeChannel={activeChannel}
          onSelectChannel={onSelectChannel}
          onSelectItem={onSelectItem}
        />

        <Content className="stage">
          <OverviewPage onSelectItem={onSelectItem} />
        </Content>

        <ProjectInspector activeProject={activeProject} activeChannel={activeChannel} selectedItem={selectedItem} />
      </Layout>

      <ProjectStatusbar />
    </Layout>
  )
}
