import React from "react";
import QuickActionsBar from "./QuickActionsBar.jsx";
import NowStatusCard from "./NowStatusCard.jsx";
import ChecklistCard from "./ChecklistCard.jsx";
import MainTabs from "./MainTabs.jsx";
import TaskSettingsTab from "./TaskSettingsTab.jsx";
import MainTabContent from "./MainTabContent.jsx";
import TestRunCard from "./TestRunCard.jsx";
import useTabProps from "../hooks/useTabProps.js";

const AccountsTab = React.lazy(() => import("../tabs/AccountsTab.jsx"));
const LogsTab = React.lazy(() => import("../tabs/LogsTab.jsx"));
const QueueTab = React.lazy(() => import("../tabs/QueueTab.jsx"));
const EventsTab = React.lazy(() => import("../tabs/EventsTab.jsx"));
const SettingsTab = React.lazy(() => import("../tabs/SettingsTab.jsx"));

export default function AppMain({
  quickActions,
  nowStatus,
  testRun,
  runTestLive,
  checklist,
  tabs,
  taskSettings,
  accountsTab,
  logsTab,
  queueTab,
  eventsTab,
  settingsTab
}) {
  const {
    taskSettingsProps,
    accountsTabProps,
    logsTabProps,
    queueTabProps,
    eventsTabProps,
    settingsTabProps
  } = useTabProps(taskSettings, accountsTab, logsTab, queueTab, eventsTab, settingsTab);

  return (
    <div className="main">
      <QuickActionsBar
        {...quickActions}
      />
      <NowStatusCard
        {...nowStatus}
      />
      <TestRunCard
        testRun={testRun}
        onRunSafe={quickActions.runTestSafe}
        onRunLive={runTestLive}
      />
      <ChecklistCard
        {...checklist}
      />
      <MainTabs
        {...tabs}
      />
      <MainTabContent
        activeTab={tabs.activeTab}
        TaskSettingsTab={TaskSettingsTab}
        AccountsTab={AccountsTab}
        LogsTab={LogsTab}
        QueueTab={QueueTab}
        EventsTab={EventsTab}
        SettingsTab={SettingsTab}
        taskSettingsProps={taskSettingsProps}
        accountsTabProps={accountsTabProps}
        logsTabProps={logsTabProps}
        queueTabProps={queueTabProps}
        eventsTabProps={eventsTabProps}
        settingsTabProps={settingsTabProps}
      />
    </div>
  );
}
