import 'package:flutter/material.dart';
import 'package:equatable/equatable.dart';

class InspectionDeviceState extends Equatable {
  final String deviceId;
  final String deviceName;
  final String deviceType;
  final String deviceStatus;
  final String deviceModel;
  final String installLocation;
  final String area;
  final String responsiblePerson;
  final String lastInspectionTime;
  final List<InspectionHistoryItem> inspectionHistory;
  final List<InspectionItem> inspectionItems;
  final IconData icon;
  final bool isLoading;
  final String? error;

  const InspectionDeviceState({
    required this.deviceId,
    required this.deviceName,
    required this.deviceType,
    required this.deviceStatus,
    required this.deviceModel,
    required this.installLocation,
    required this.area,
    required this.responsiblePerson,
    required this.lastInspectionTime,
    required this.inspectionHistory,
    required this.inspectionItems,
    required this.icon,
    this.isLoading = false,
    this.error,
  });

  InspectionDeviceState copyWith({
    String? deviceId,
    String? deviceName,
    String? deviceType,
    String? deviceStatus,
    String? deviceModel,
    String? installLocation,
    String? area,
    String? responsiblePerson,
    String? lastInspectionTime,
    List<InspectionHistoryItem>? inspectionHistory,
    List<InspectionItem>? inspectionItems,
    IconData? icon,
    bool? isLoading,
    String? error,
  }) {
    return InspectionDeviceState(
      deviceId: deviceId ?? this.deviceId,
      deviceName: deviceName ?? this.deviceName,
      deviceType: deviceType ?? this.deviceType,
      deviceStatus: deviceStatus ?? this.deviceStatus,
      deviceModel: deviceModel ?? this.deviceModel,
      installLocation: installLocation ?? this.installLocation,
      area: area ?? this.area,
      responsiblePerson: responsiblePerson ?? this.responsiblePerson,
      lastInspectionTime: lastInspectionTime ?? this.lastInspectionTime,
      inspectionHistory: inspectionHistory ?? this.inspectionHistory,
      inspectionItems: inspectionItems ?? this.inspectionItems,
      icon: icon ?? this.icon,
      isLoading: isLoading ?? this.isLoading,
      error: error,
    );
  }

  @override
  List<Object?> get props => [
        deviceId,
        deviceName,
        deviceType,
        deviceStatus,
        deviceModel,
        installLocation,
        area,
        responsiblePerson,
        lastInspectionTime,
        inspectionHistory,
        inspectionItems,
        icon,
        isLoading,
        error,
      ];
}

class InspectionHistoryItem extends Equatable {
  final String inspectorName;
  final String inspectionTime;
  final String result;
  final String remark;

  const InspectionHistoryItem({
    required this.inspectorName,
    required this.inspectionTime,
    required this.result,
    required this.remark,
  });

  @override
  List<Object?> get props => [
        inspectorName,
        inspectionTime,
        result,
        remark,
      ];
}

class InspectionItem extends Equatable {
  final String name;
  final String value;
  final String result;

  const InspectionItem({
    required this.name,
    required this.value,
    required this.result,
  });

  @override
  List<Object?> get props => [
        name,
        value,
        result,
      ];
}