import 'package:flutter/material.dart';
import 'admin_ai_panel.dart';
import 'admin_database_panel.dart';
import 'admin_users_panel.dart';

enum AdminViewTab { users, database, ai }

extension AdminViewTabX on AdminViewTab {
  static AdminViewTab fromQuery(String? value) {
    return switch (value) {
      'database' => AdminViewTab.database,
      'ai' => AdminViewTab.ai,
      _ => AdminViewTab.users,
    };
  }

  String get queryValue => switch (this) {
        AdminViewTab.users => 'users',
        AdminViewTab.database => 'database',
        AdminViewTab.ai => 'ai',
      };
}

class AdminScreen extends StatelessWidget {
  final AdminViewTab initialTab;

  const AdminScreen({super.key, this.initialTab = AdminViewTab.users});

  @override
  Widget build(BuildContext context) {
    final activePanel = switch (initialTab) {
      AdminViewTab.users => const AdminUsersPanel(embedded: true),
      AdminViewTab.database => const AdminDatabasePanel(embedded: true),
      AdminViewTab.ai => const AdminAiPanel(embedded: true),
    };

    return Padding(
      padding: const EdgeInsets.fromLTRB(12, 8, 12, 8),
      child: activePanel,
    );
  }
}
