import { useState } from 'react';
import { ActivationSettings } from '../components/admin/ActivationSettings';
import { ExitPolicySettings } from '../components/admin/ExitPolicySettings';
import { AlertSettings } from '../components/admin/AlertSettings';
import { SentimentProviderSettings } from '../components/admin/SentimentProviderSettings';
import { DataCleanup } from '../components/admin/DataCleanup';
import { JobControls } from '../components/admin/JobControls';
import { FundamentalsParityPanel } from '../components/admin/FundamentalsParityPanel';
import { FundamentalsCutoverSettings } from '../components/admin/FundamentalsCutoverSettings';
import { PerformanceSettings } from '../components/admin/PerformanceSettings';
import { PipelineReadinessPanel } from '../components/admin/PipelineReadinessPanel';
import { SystemEventsPanel } from '../components/admin/SystemEventsPanel';
import { RecommendationSettings } from '../components/admin/RecommendationSettings';
import { ScheduleSettings } from '../components/admin/ScheduleSettings';
import { SettingsForm } from '../components/admin/SettingsForm';
import { TickerManagement } from '../components/admin/TickerManagement';
import { TickerUniverseBootstrap } from '../components/admin/TickerUniverseBootstrap';
import { UserTable } from '../components/admin/UserTable';
import { PageHeader } from '../components/ui/PageHeader';
import { Tabs } from '../components/ui/Tabs';

const tabs = ['Users', 'Tickers', 'Settings', 'Jobs', 'Alerts', 'Cleanup'] as const;
type Tab = (typeof tabs)[number];

export default function AdminPage() {
  const [activeTab, setActiveTab] = useState<Tab>('Users');

  return (
    <div className="space-y-6 animate-slide-up">
      <PageHeader title="Admin" subtitle="System management" />

      <Tabs tabs={tabs} active={activeTab} onChange={setActiveTab} />

      {/* Tab content */}
      <div className="animate-fade-in">
        {activeTab === 'Users' && <UserTable />}
        {activeTab === 'Tickers' && <TickerManagement />}
        {activeTab === 'Settings' && (
          <div className="space-y-4">
            <FundamentalsCutoverSettings />
            <ActivationSettings />
            <ExitPolicySettings />
            <PerformanceSettings />
            <AlertSettings />
            <SentimentProviderSettings />
            <TickerUniverseBootstrap />
            <RecommendationSettings />
            <SettingsForm />
          </div>
        )}
        {activeTab === 'Jobs' && (
          <div className="space-y-4">
            <ScheduleSettings />
            <FundamentalsParityPanel />
            <JobControls />
            <PipelineReadinessPanel />
          </div>
        )}
        {activeTab === 'Alerts' && (
          <div className="space-y-4">
            <SystemEventsPanel />
          </div>
        )}
        {activeTab === 'Cleanup' && <DataCleanup />}
      </div>
    </div>
  );
}
