import 'package:equatable/equatable.dart';
import '../../domain/ui_entities/coverage_entities.dart';

/// Enum representing the status of coverage data loading.
enum CoverageStatus {
  /// Initial state before any data is loaded.
  initial,

  /// Data is currently being loaded.
  loading,

  /// Data has been successfully loaded.
  success,

  /// An error occurred while loading data.
  failure,
}

/// State for the coverage feature.
final class CoverageState extends Equatable {
  /// Creates a [CoverageState].
  const CoverageState({
    this.status = CoverageStatus.initial,
    this.selectedDate,
    this.shifts = const <CoverageShift>[],
    this.stats,
    this.errorMessage,
  });

  /// The current status of data loading.
  final CoverageStatus status;

  /// The currently selected date.
  final DateTime? selectedDate;

  /// The list of shifts for the selected date.
  final List<CoverageShift> shifts;

  /// Coverage statistics for the selected date.
  final CoverageStats? stats;

  /// Error message if status is failure.
  final String? errorMessage;

  /// Creates a copy of this state with the given fields replaced.
  CoverageState copyWith({
    CoverageStatus? status,
    DateTime? selectedDate,
    List<CoverageShift>? shifts,
    CoverageStats? stats,
    String? errorMessage,
  }) {
    return CoverageState(
      status: status ?? this.status,
      selectedDate: selectedDate ?? this.selectedDate,
      shifts: shifts ?? this.shifts,
      stats: stats ?? this.stats,
      errorMessage: errorMessage ?? this.errorMessage,
    );
  }

  @override
  List<Object?> get props => <Object?>[
        status,
        selectedDate,
        shifts,
        stats,
        errorMessage,
      ];
}
