/// Configuration centralisée des routes de l'application
/// 
/// Gère toutes les routes et la navigation de l'application UnionFlow
library app_router;

import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../features/authentication/presentation/bloc/auth_bloc.dart';
import '../../features/authentication/presentation/pages/login_page.dart';
import '../../features/about/presentation/pages/about_page.dart';
import '../../features/help/presentation/pages/help_support_page.dart';
import '../../features/profile/presentation/pages/profile_page_wrapper.dart';
import '../../features/organizations/presentation/pages/organizations_page.dart';
import '../../features/members/presentation/pages/members_page_wrapper.dart';
import '../../features/events/presentation/pages/events_page_wrapper.dart';
import '../../features/solidarity/presentation/pages/demandes_aide_page_wrapper.dart';
import '../../features/contributions/presentation/pages/contributions_page_wrapper.dart';
import '../../features/reports/presentation/pages/reports_page_wrapper.dart';
import '../../features/adhesions/presentation/pages/adhesions_page_wrapper.dart';
import '../../features/settings/presentation/pages/system_settings_page.dart';
import '../../features/dashboard/presentation/pages/advanced_dashboard_page.dart';
import '../../features/admin/presentation/pages/user_management_page.dart';
import '../../features/communication/presentation/pages/conversations_page.dart';
import '../../features/finance_workflow/presentation/pages/pending_approvals_page.dart';
import '../../features/finance_workflow/presentation/pages/budgets_list_page.dart';
import '../../core/navigation/main_navigation_layout.dart';

/// Configuration des routes de l'application
class AppRouter {
  /// Routes principales de l'application
  static Map<String, WidgetBuilder> get routes => {
    '/': (context) => BlocBuilder<AuthBloc, AuthState>(
      builder: (context, state) {
        if (state is AuthLoading) {
          return const Scaffold(
            body: Center(
              child: CircularProgressIndicator(),
            ),
          );
        } else if (state is AuthAuthenticated) {
          return const MainNavigationLayout();
        } else {
          return const LoginPage();
        }
      },
    ),
    '/dashboard': (context) => const MainNavigationLayout(),
    '/login': (context) => const LoginPage(),
    '/about': (context) => const AboutPage(),
    '/help': (context) => const HelpSupportPage(),
    '/profile': (context) => const ProfilePageWrapper(),
    '/organizations': (context) => const OrganizationsPage(),
    '/members': (context) => const MembersPageWrapper(),
    '/events': (context) => const EventsPageWrapper(),
    '/solidarity': (context) => const DemandesAidePageWrapper(),
    '/reports': (context) => const ReportsPageWrapper(),
    '/finances': (context) => const ContributionsPageWrapper(),
    '/my-finances': (context) => const ContributionsPageWrapper(),
    '/moderation': (context) => const AdhesionsPageWrapper(),
    '/communication': (context) => const ConversationsPage(),
    '/org-settings': (context) => const SystemSettingsPage(),
    '/analytics': (context) => const AdvancedDashboardPage(organizationId: '', userId: ''),
    '/security': (context) => const SystemSettingsPage(),
    '/system-admin': (context) => const MainNavigationLayout(),
    '/global-users': (context) => const UserManagementPage(),
    '/messages': (context) => const ConversationsPage(),
    '/public-events': (context) => const EventsPageWrapper(),
    '/contact': (context) => const HelpSupportPage(),
    '/approvals': (context) => const PendingApprovalsPage(),
    '/budgets': (context) => const BudgetsListPage(),
  };

  /// Route initiale de l'application
  static const String initialRoute = '/';
}
