import 'package:equatable/equatable.dart';

class AlertListBO extends Equatable {
  final int total;
  final AlertListTabCountBO tabCount;
  final List<AlertListItemBO> rows;

  const AlertListBO({
    required this.total,
    required this.tabCount,
    required this.rows,
  });

  factory AlertListBO.fromJson(Map<String, dynamic> json) {
    return AlertListBO(
      total: json['total'] as int? ?? 0,
      tabCount: AlertListTabCountBO.fromJson(
        json['tabCount'] as Map<String, dynamic>? ?? {},
      ),
      rows: (json['rows'] as List<dynamic>?)
              ?.map(
                  (e) => AlertListItemBO.fromJson(e as Map<String, dynamic>))
              .toList() ??
          [],
    );
  }

  @override
  List<Object?> get props => [total, tabCount, rows];
}

class AlertListTabCountBO extends Equatable {
  final int all;
  final int pending;
  final int processed;
  final int falseAlarm;

  const AlertListTabCountBO({
    required this.all,
    required this.pending,
    required this.processed,
    required this.falseAlarm,
  });

  factory AlertListTabCountBO.fromJson(Map<String, dynamic> json) {
    return AlertListTabCountBO(
      all: json['all'] as int? ?? 0,
      pending: json['pending'] as int? ?? 0,
      processed: json['processed'] as int? ?? 0,
      falseAlarm: json['falseAlarm'] as int? ?? 0,
    );
  }

  @override
  List<Object?> get props => [all, pending, processed, falseAlarm];
}

class AlertListItemBO extends Equatable {
  final int alertId;
  final String alertTitle;
  final String alertIcon;
  final String deviceLocationText;
  final String alertTime;
  final String handleTime;
  final String alertLevel;
  final String alertStatus;

  const AlertListItemBO({
    required this.alertId,
    required this.alertTitle,
    required this.alertIcon,
    required this.deviceLocationText,
    required this.alertTime,
    required this.handleTime,
    required this.alertLevel,
    required this.alertStatus,
  });

  factory AlertListItemBO.fromJson(Map<String, dynamic> json) {
    return AlertListItemBO(
      alertId: json['alertId'] as int? ?? 0,
      alertTitle: json['alertTitle'] as String? ?? '',
      alertIcon: json['alertIcon'] as String? ?? '',
      deviceLocationText: json['deviceLocationText'] as String? ?? '',
      alertTime: json['alertTime'] as String? ?? '',
      handleTime: json['handleTime'] as String? ?? '',
      alertLevel: json['alertLevel'] as String? ?? '',
      alertStatus: json['alertStatus'] as String? ?? '',
    );
  }

  @override
  List<Object?> get props => [
        alertId,
        alertTitle,
        alertIcon,
        deviceLocationText,
        alertTime,
        handleTime,
        alertLevel,
        alertStatus,
      ];
}