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

class Description {
  late int descriptionId;
  late String name;
  late String description;
  int? version;
  DateTime? validFrom;
  DateTime? validTo;

  String? descriptionTranslation;

  Description.fromJson(Map json) {
    this.descriptionId = json['descriptionId'];
    this.name = json['name'];
    this.description = json['description'];
    this.version = json['version'];
    this.validFrom = json['validFrom'];
    this.validTo = json['validTo'];

    if (json['translations'] != null && json['translations'].length > 0) {
      this.descriptionTranslation =
          AppLanguage().appLocal == Locale('hu') ? json['translations'][0]['descriptionTranslation'] : json['description'];
    }
  }

  Map<String, dynamic> toJson() => {
        "descriptionId": this.descriptionId,
        "name": this.name,
        "description": this.description,
        "version": this.version,
        "validFrom": this.validFrom,
        "validTo": this.validTo,
        "descriptionTranslation": this.descriptionTranslation
      };

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