
import 'package:prosapp_web_app/models/city_entity.dart';

class RegionEntity  {
  final String name;
  final List<CityEntity> cities;

  const RegionEntity({
    required this.name,
    required this.cities,
  });

  Map<String, Object?> toDocument() {
    return {
      'name': name,
      'cities': cities,
    };
  }

  static RegionEntity fromDocument(Map<String, dynamic> doc) {
    return RegionEntity(
      name: doc['name'] as String,
      cities: (doc['cities'] as List)
          .map((city) => CityEntity.fromDocument(city))
          .toList(),
    );
  }

  @override
  String toString() {
    return '''RegionEntity {
      name: $name
      cities: $cities
    }''';
  }
}
