import 'package:mitra_corporate/model/destination_model.dart';
import 'package:mitra_corporate/widgets/custom_text_field.dart';

class RegistrationFilterModel {
  List<CustomDropDownModel>? titles;
  List<CustomDropDownModel>? gender;
  List<RegionalModel>? regionals;

  RegistrationFilterModel({this.titles, this.gender, this.regionals});

  RegistrationFilterModel.fromJson(Map<String, dynamic> json) {
    if (json['titles'] != null) {
      titles = <CustomDropDownModel>[];
      json['titles'].forEach((v) {
        titles!.add(CustomDropDownModel.fromJson(v));
      });
    }
    if (json['gender'] != null) {
      gender = <CustomDropDownModel>[];
      json['gender'].forEach((v) {
        gender!.add(CustomDropDownModel.fromJson(v));
      });
    }
    if (json['regional'] != null) {
      regionals = <RegionalModel>[];
      json['regional'].forEach((v) {
        regionals!.add(RegionalModel.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    if (titles != null) {
      data['titles'] = titles!.map((v) => v.toJson()).toList();
    }
    if (gender != null) {
      data['gender'] = gender!.map((v) => v.toJson()).toList();
    }
    if (regionals != null) {
      data['regional'] = regionals!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class RegionalModel {
  String? regionalId;
  String? regionalName;
  List<DestinationModel>? branch;

  RegionalModel({this.regionalId, this.regionalName, this.branch});

  RegionalModel.fromJson(Map<String, dynamic> json) {
    regionalId = json['regional_id'];
    regionalName = json['regional_name'];
    if (json['branch'] != null) {
      branch = <DestinationModel>[];
      json['branch'].forEach((v) {
        branch!.add(DestinationModel.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = <String, dynamic>{};
    data['regional_id'] = regionalId;
    data['regional_name'] = regionalName;
    if (branch != null) {
      data['branch'] = branch!.map((v) => v.toJson()).toList();
    }
    return data;
  }
}
