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

part 'equipment_list_dto.freezed.dart';
part 'equipment_list_dto.g.dart';

@freezed
class EquipmentListDto with _$EquipmentListDto {
  const factory EquipmentListDto({
    required int id,
    @JsonKey(name: 'companies_id') int? companiesId,
    @JsonKey(name: 'company_name') String? companyName,
    @JsonKey(name: 'models_id') int? modelsId,
    @JsonKey(name: 'model_name') String? modelName,
    @JsonKey(name: 'vendor_name') String? vendorName,
    @JsonKey(name: 'serial_number') String? serialNumber,
    String? barcode,
    @JsonKey(name: 'purchased_at') DateTime? purchasedAt,
    @JsonKey(name: 'purchase_price') int? purchasePrice,
    @JsonKey(name: 'warranty_number') String? warrantyNumber,
    @JsonKey(name: 'warranty_started_at') DateTime? warrantyStartedAt,
    @JsonKey(name: 'warranty_ended_at') DateTime? warrantyEndedAt,
    String? remark,
    @JsonKey(name: 'is_deleted') bool? isDeleted,
    @JsonKey(name: 'registered_at') DateTime? registeredAt,
    @JsonKey(name: 'updated_at') DateTime? updatedAt,
    ModelDto? model,
  }) = _EquipmentListDto;

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

/// 장비 목록 응답 DTO
@freezed
class EquipmentListResponseDto with _$EquipmentListResponseDto {
  const factory EquipmentListResponseDto({
    required List<EquipmentListDto> items,
    required int total,
    required int page,
    @JsonKey(name: 'per_page') required int perPage,
    @JsonKey(name: 'total_pages') required int totalPages,
  }) = _EquipmentListResponseDto;

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