import 'package:freezed_annotation/freezed_annotation.dart';

part 'vendor_dto.freezed.dart';
part 'vendor_dto.g.dart';

@freezed
class VendorDto with _$VendorDto {
  const VendorDto._(); // Private constructor for getters
  
  const factory VendorDto({
    int? id,
    required String name,
    @JsonKey(name: 'is_deleted') 
    @Default(false) bool isDeleted,
    @JsonKey(name: 'registered_at')
    DateTime? createdAt,
    @JsonKey(name: 'updated_at')
    DateTime? updatedAt,
  }) = _VendorDto;

  // isActive 계산 속성 (is_deleted의 반대)
  bool get isActive => !isDeleted;

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

// API 응답 래퍼
@freezed
class VendorListResponse with _$VendorListResponse {
  const factory VendorListResponse({
    @JsonKey(name: 'data')
    required List<VendorDto> items,
    @JsonKey(name: 'total')
    required int totalCount,
    @JsonKey(name: 'page')
    required int currentPage,
    @JsonKey(name: 'total_pages')
    required int totalPages,
    @JsonKey(name: 'page_size')
    int? pageSize,
  }) = _VendorListResponse;

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