import { useApp } from './context/AppContext';
import { AppLayout } from './components/layout/AppLayout';
import { GuildSelect } from './pages/GuildSelect';
import { Dashboard } from './pages/Dashboard';
import { Tickets } from './pages/Tickets';
import { SupportLogin } from './pages/SupportLogin';
import { Automod } from './pages/Automod';
import { Welcome } from './pages/Welcome';
import { DynamicVoice } from './pages/DynamicVoice';
import { Birthday } from './pages/Birthday';
import { ReactionRoles } from './pages/ReactionRoles';
import { Statuspage } from './pages/Statuspage';
import { ServerStats } from './pages/ServerStats';
import { Register } from './pages/Register';
import { MusicPage } from './pages/Music';
import { SettingsPage } from './pages/Settings';
import { ModulesPage } from './pages/Modules';
import { Events } from './pages/Events';
import { Admin } from './pages/Admin';

function AppContent() {
  const { guilds, currentGuildId, section } = useApp();

  if (!guilds.length) {
    return <GuildSelect />;
  }

  if (!currentGuildId) {
    return <GuildSelect />;
  }

  switch (section) {
    case 'overview': return <Dashboard />;
    case 'tickets': return <Tickets />;
    case 'supportlogin': return <SupportLogin />;
    case 'automod': return <Automod />;
    case 'welcome': return <Welcome />;
    case 'dynamicvoice': return <DynamicVoice />;
    case 'birthday': return <Birthday />;
    case 'reactionroles': return <ReactionRoles />;
    case 'statuspage': return <Statuspage />;
    case 'serverstats': return <ServerStats />;
    case 'register': return <Register />;
    case 'music': return <MusicPage />;
    case 'settings': return <SettingsPage />;
    case 'modules': return <ModulesPage />;
    case 'events': return <Events />;
    case 'admin': return <Admin />;
    default: return <Dashboard />;
  }
}

function App() {
  return (
    <AppLayout>
      <AppContent />
    </AppLayout>
  );
}

export default App;
