import { ProjectAi } from './project-ai'
import { ProjectCron } from './project-cron'
import { ProjectNewChannel } from './project-new-channel'
import { ProjectNotes } from './project-notes'
import { ProjectOverview } from './project-overview'
import type { ProjectTaskUpdate } from './project-task-edit-modal'
import { ProjectTasks } from './project-tasks'
import type { ChannelKey, ProjectWorkspace } from './project-types'

export function ProjectChannelPage({
  activeChannel,
  activeWorkspace,
  activeTaskID,
  onSelectItem,
  onOpenTask,
  onCloseTask,
  onCreateTask,
  onUploadSource,
  onCreateCronPlan,
  onCreateProjectTag,
  onUpdateTask,
}: {
  activeChannel: ChannelKey
  activeWorkspace: ProjectWorkspace
  activeTaskID: string | null
  onSelectItem: (title: string) => void
  onOpenTask: (taskID: string) => void
  onCloseTask: () => void
  onCreateTask: () => void
  onUploadSource: () => void
  onCreateCronPlan: () => void
  onCreateProjectTag: (name: string) => void
  onUpdateTask: (update: ProjectTaskUpdate) => void
}) {
  switch (activeChannel) {
    case 'tasks':
      return <ProjectTasks activeWorkspace={activeWorkspace} activeTaskID={activeTaskID} onOpenTask={onOpenTask} onCloseTask={onCloseTask} onSelectItem={onSelectItem} onCreateTask={onCreateTask} onCreateProjectTag={onCreateProjectTag} onUpdateTask={onUpdateTask} />
    case 'ai':
      return <ProjectAi activeWorkspace={activeWorkspace} onSelectItem={onSelectItem} />
    case 'notes':
      return <ProjectNotes activeWorkspace={activeWorkspace} onSelectItem={onSelectItem} onUploadSource={onUploadSource} />
    case 'cron':
      return <ProjectCron activeWorkspace={activeWorkspace} onSelectItem={onSelectItem} onCreateCronPlan={onCreateCronPlan} />
    case 'new-channel':
      return <ProjectNewChannel activeWorkspace={activeWorkspace} />
    case 'overview':
    default:
      return <ProjectOverview activeWorkspace={activeWorkspace} onSelectItem={onSelectItem} onUpdateTask={onUpdateTask} />
  }
}
