import 'package:flutter/material.dart';

class AdminListState extends StatelessWidget {
  final bool isLoading;
  final String? error;
  final bool isEmpty;
  final String emptyMessage;
  final Widget list;

  const AdminListState({
    super.key,
    required this.isLoading,
    required this.error,
    required this.isEmpty,
    required this.emptyMessage,
    required this.list,
  });

  @override
  Widget build(BuildContext context) {
    if (isLoading) {
      return const Expanded(
        child: Center(child: CircularProgressIndicator()),
      );
    }

    if (error != null) {
      return Expanded(
        child: Center(
          child: Text(
            'Erreur: $error',
            style: const TextStyle(color: Colors.red),
            textAlign: TextAlign.center,
          ),
        ),
      );
    }

    if (isEmpty) {
      return Expanded(
        child: Center(
          child: Text(emptyMessage),
        ),
      );
    }

    return Expanded(child: list);
  }
}
