import { SharedResourceManagementPage } from '../SharedResourceManagementPage';
import { AutomationTypeManagementPage } from '../AutomationTypeManagementPage';
import { AutomationContextManagementPage } from '../AutomationContextManagementPage';
import { TokenSettingManagementPage } from '../TokenSettingManagementPage';
import { BoardPage } from '../../../features/board';
import { HistoryPage } from '../../../features/history';
import { PlanBoardChartsPage, PlanBoardPage, PlanSchedulePage, ReleaseReviewPage } from '../../../features/planBoard';
import { ServerCommandPage } from '../../../features/serverCommand';
import { useMainLayoutContext } from '../layout/MainLayoutContext';

export function PlansPage() {
  const {
    selectedPlanMenu,
    activePlanQuickFilter,
    planQuickFilterRequestKey,
    initialSelectedPlanId,
    initialSelectedWorkId,
  } = useMainLayoutContext();

  if (selectedPlanMenu === 'board') {
    return (
      <div className="app-main-panel">
        <BoardPage />
      </div>
    );
  }

  if (selectedPlanMenu === 'charts') {
    return (
      <div className="app-main-panel">
        <PlanBoardChartsPage />
      </div>
    );
  }

  if (selectedPlanMenu === 'schedule') {
    return (
      <div className="app-main-panel">
        <PlanSchedulePage />
      </div>
    );
  }

  if (selectedPlanMenu === 'release-review') {
    return (
      <div className="app-main-panel">
        <ReleaseReviewPage />
      </div>
    );
  }

  if (selectedPlanMenu === 'history') {
    return (
      <div className="app-main-panel">
        <HistoryPage />
      </div>
    );
  }

  if (selectedPlanMenu === 'automation-type') {
    return (
      <div className="app-main-panel">
        <AutomationTypeManagementPage />
      </div>
    );
  }

  if (selectedPlanMenu === 'automation-context') {
    return (
      <div className="app-main-panel">
        <AutomationContextManagementPage />
      </div>
    );
  }

  if (selectedPlanMenu === 'token-setting') {
    return (
      <div className="app-main-panel">
        <TokenSettingManagementPage />
      </div>
    );
  }

  if (selectedPlanMenu === 'shared-resource') {
    return (
      <div className="app-main-panel">
        <SharedResourceManagementPage />
      </div>
    );
  }

  if (selectedPlanMenu === 'server-command') {
    return (
      <div className="app-main-panel">
        <ServerCommandPage />
      </div>
    );
  }

  return (
    <div className="app-main-panel">
      <PlanBoardPage
        statusFilter={selectedPlanMenu === 'release' ? 'done' : selectedPlanMenu}
        quickFilter={activePlanQuickFilter}
        quickFilterRequestKey={planQuickFilterRequestKey}
        initialSelectedPlanId={initialSelectedPlanId}
        initialSelectedWorkId={initialSelectedWorkId}
      />
    </div>
  );
}
