import 'dart:collection';

import 'package:aitrainer_app/util/app_language.dart';

class Faq {
  late int faqId;
  late String name;
  late String description;
  int? sort;

  HashMap<String, String> nameTranslations = HashMap();
  HashMap<String, String> descriptionTranslations = HashMap();

  Faq.fromJson(Map json) {
    this.faqId = json['faqId'];
    this.name = json['name'];
    this.description = json['description'];
    this.sort = json['sort'];

    nameTranslations['en'] = name;
    descriptionTranslations['en'] = description;
    if (json['translations'] != null && json['translations'].length > 0) {
      json['translations'].forEach((translation) {
        nameTranslations[translation['languageCode']] = translation['nameTranslation'];
        descriptionTranslations[translation['languageCode']] = translation['descriptionTranslation'];
      });
    }
  }

  Map<String, dynamic> toJson() => {
        "faqId": this.faqId,
        "name": this.name,
        "description": this.description,
        "nameTranslation": this.nameTranslations.toString(),
      };

  @override
  String toString() => this.toJson().toString();
}
