class RiskAndSuggestionsResponseModel {
  final List<RiskAndSuggestionsItemModel>? dataDetails;

  RiskAndSuggestionsResponseModel({this.dataDetails});

  factory RiskAndSuggestionsResponseModel.fromJson(Map<String, dynamic> json) {
    return RiskAndSuggestionsResponseModel(
      dataDetails:
          json['dataDetails'] != null ? (json['dataDetails'] as List).map((item) => RiskAndSuggestionsItemModel.fromJson(item)).toList() : null,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'dataDetails': dataDetails?.map((item) => item.toJson()).toList(),
    };
  }
}

class RiskAndSuggestionsItemModel {
  final String? id;
  final String? type;
  final String? name;
  final String? commonName;
  final String? nameAr;
  final String? commonNameAr;
  final String? language;

  RiskAndSuggestionsItemModel({
    this.id,
    this.type,
    this.name,
    this.commonName,
    this.nameAr,
    this.commonNameAr,
    this.language,
  });

  factory RiskAndSuggestionsItemModel.fromJson(Map<String, dynamic> json) {
    return RiskAndSuggestionsItemModel(
      id: json['id'],
      type: json['type'],
      name: json['name'],
      commonName: json['common_name'],
      nameAr: json['nameAr'],
      commonNameAr: json['common_nameAr'],
      language: json['language'],
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'type': type,
      'name': name,
      'common_name': commonName,
      'nameAr': nameAr,
      'common_nameAr': commonNameAr,
      'language': language,
    };
  }

  // Helper method to get display name based on locale
  String getDisplayName({bool isArabic = false}) {
    if (isArabic) {
      return commonNameAr ?? nameAr ?? commonName ?? name ?? '';
    }
    return commonName ?? name ?? '';
  }
}
