import 'package:freezed_annotation/freezed_annotation.dart';
import 'company_dto.dart';

part 'company_list_dto.freezed.dart';
part 'company_list_dto.g.dart';

@freezed
class CompanyListDto with _$CompanyListDto {
  const factory CompanyListDto({
    required int id,
    required String name,
    String? address,
    @JsonKey(name: 'contact_name') String? contactName,
    @JsonKey(name: 'contact_phone') String? contactPhone,
    @JsonKey(name: 'contact_email') String? contactEmail,
    @JsonKey(name: 'company_types') List<String>? companyTypes,
    @JsonKey(name: 'is_active') required bool isActive,
    @JsonKey(name: 'is_partner') @Default(false) bool isPartner,
    @JsonKey(name: 'is_customer') @Default(false) bool isCustomer,
    @JsonKey(name: 'parent_company_id') int? parentCompanyId,
    @JsonKey(name: 'registered_at') DateTime? registeredAt,
    @JsonKey(name: 'child_count') @Default(0) int childCount,
  }) = _CompanyListDto;

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

@freezed
class CompanyWithChildren with _$CompanyWithChildren {
  const factory CompanyWithChildren({
    required CompanyDto company,
    @Default([]) List<CompanyDto> children,
  }) = _CompanyWithChildren;

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