/// [FilterModel] is used for filter screen
/// for example name is [Brand] options are [Mavi, Koton etc ...]
/// [selectedOptions] is selected by user.
class FilterModel {
  late int id;
  late String code;
  late String name;
  late List<FilterOption> options;
  late List<FilterOption> selectedOptions;

  FilterModel({
    required this.id,
    required this.code,
    required this.name,
    required this.options,
    required this.selectedOptions,
  });

  FilterModel.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    code = json['code'];
    name = json['name'];
    selectedOptions = [];
    options = <FilterOption>[];
    if (json['options'] != null) {
      json['options'].forEach((v) {
        options.add(new FilterOption.fromJson(v));
      });
    }
  }
}

class FilterOption {
  late int id;
  late String name;
  late String label;
  late String swatchValue;
  late String queryValue;

  FilterOption({
    required this.id,
    required this.name,
    required this.label,
    required this.swatchValue,
    required this.queryValue,
  });

  FilterOption.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    name = json['admin_name'];
    label = json['label'];
    swatchValue = json['swatch_value'] ?? '';
    queryValue = json['id'].toString();
  }
}
