import 'package:freezed_annotation/freezed_annotation.dart';
import 'company_dto.dart';
import 'branch_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,
    required String address,
    @JsonKey(name: 'contact_name') String? contactName,
    @JsonKey(name: 'contact_phone') String? contactPhone,
    @JsonKey(name: 'contact_email') String? contactEmail,
    @JsonKey(name: 'is_active') required bool isActive,
    @JsonKey(name: 'created_at') DateTime? createdAt,
    @JsonKey(name: 'branch_count') @Default(0) int branchCount,
  }) = _CompanyListDto;

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

@freezed
class CompanyWithBranches with _$CompanyWithBranches {
  const factory CompanyWithBranches({
    required CompanyResponse company,
    @Default([]) List<BranchListDto> branches,
  }) = _CompanyWithBranches;

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