import 'package:equatable/equatable.dart';
import 'package:smart_hotel_app/models/bo/room_bo.dart';

class RoomReportState extends Equatable {
  static const _nothing = Object();

  final bool isLoading;
  final String? error;
  final RoomOverviewSummaryBO summary;
  final List<RoomFloorBO> floors;
  final int selectedFloorIndex;
  final List<RoomGridBO> roomGrid;
  final List<RoomDetailListBO> detailRooms;
  final int? selectedRoomId;

  const RoomReportState({
    this.isLoading = false,
    this.error,
    this.summary = const RoomOverviewSummaryBO(),
    this.floors = const [],
    this.selectedFloorIndex = 0,
    this.roomGrid = const [],
    this.detailRooms = const [],
    this.selectedRoomId,
  });

  RoomReportState copyWith({
    bool? isLoading,
    String? error,
    RoomOverviewSummaryBO? summary,
    List<RoomFloorBO>? floors,
    int? selectedFloorIndex,
    List<RoomGridBO>? roomGrid,
    List<RoomDetailListBO>? detailRooms,
    Object? selectedRoomId = _nothing,
    bool clearError = false,
  }) {
    return RoomReportState(
      isLoading: isLoading ?? this.isLoading,
      error: clearError ? null : (error ?? this.error),
      summary: summary ?? this.summary,
      floors: floors ?? this.floors,
      selectedFloorIndex: selectedFloorIndex ?? this.selectedFloorIndex,
      roomGrid: roomGrid ?? this.roomGrid,
      detailRooms: detailRooms ?? this.detailRooms,
      selectedRoomId: identical(selectedRoomId, _nothing) ? this.selectedRoomId : selectedRoomId as int?,
    );
  }

  @override
  List<Object?> get props => [
        isLoading,
        error,
        summary,
        floors,
        selectedFloorIndex,
        roomGrid,
        detailRooms,
        selectedRoomId,
      ];
}
