import 'package:equatable/equatable.dart';
import 'coverage_worker.dart';

/// Domain entity representing a shift in the coverage view.
///
/// This is a feature-specific domain entity that encapsulates shift information
/// including scheduling details and assigned workers.
class CoverageShift extends Equatable {
  /// Creates a [CoverageShift].
  const CoverageShift({
    required this.id,
    required this.title,
    required this.location,
    required this.startTime,
    required this.workersNeeded,
    required this.date,
    required this.workers,
  });

  /// The unique identifier for the shift.
  final String id;

  /// The title or role of the shift.
  final String title;

  /// The location where the shift takes place.
  final String location;

  /// The start time of the shift (e.g., "16:00").
  final String startTime;

  /// The number of workers needed for this shift.
  final int workersNeeded;

  /// The date of the shift.
  final DateTime date;

  /// The list of workers assigned to this shift.
  final List<CoverageWorker> workers;

  /// Calculates the coverage percentage for this shift.
  int get coveragePercent {
    if (workersNeeded == 0) return 0;
    return ((workers.length / workersNeeded) * 100).round();
  }

  @override
  List<Object?> get props => <Object?>[
        id,
        title,
        location,
        startTime,
        workersNeeded,
        date,
        workers,
      ];
}
