import 'package:freezed_annotation/freezed_annotation.dart';
import 'package:superport/core/utils/equipment_status_converter.dart';
import 'package:superport/data/models/model_dto.dart';

part 'equipment_response.freezed.dart';
part 'equipment_response.g.dart';

@freezed
class EquipmentResponse with _$EquipmentResponse {
  const factory EquipmentResponse({
    required int id,
    @JsonKey(name: 'equipment_number') required String equipmentNumber,
    // Sprint 3: Replaced category1/2/3, manufacturer, modelName with models_id and model
    @JsonKey(name: 'models_id') int? modelsId,
    @JsonKey(name: 'serial_number') String? serialNumber,
    String? barcode,
    @JsonKey(name: 'purchase_date') DateTime? purchaseDate,
    @JsonKey(name: 'purchase_price') String? purchasePrice,
    @EquipmentStatusJsonConverter() required String status,
    @JsonKey(name: 'company_id') int? companyId,
    @JsonKey(name: 'warehouse_location_id') int? warehouseLocationId,
    @JsonKey(name: 'last_inspection_date') DateTime? lastInspectionDate,
    @JsonKey(name: 'next_inspection_date') DateTime? nextInspectionDate,
    String? remark,
    @JsonKey(name: 'created_at') required DateTime createdAt,
    @JsonKey(name: 'updated_at') required DateTime updatedAt,
    // 추가 필드 (조인된 데이터)
    @JsonKey(name: 'company_name') String? companyName,
    @JsonKey(name: 'warehouse_name') String? warehouseName,
    // Sprint 3: Added model relationship (includes vendor info)
    ModelDto? model,
  }) = _EquipmentResponse;

  factory EquipmentResponse.fromJson(Map<String, dynamic> json) =>
      _$EquipmentResponseFromJson(json);
}