/// Modèle de données pour un membre
class MembreModel {
  final String id;
  final String nom;
  final String prenom;
  final String email;
  final String? telephone;
  final String? statut;
  final String? role;
  final OrganisationModel? organisation;

  const MembreModel({
    required this.id,
    required this.nom,
    required this.prenom,
    required this.email,
    this.telephone,
    this.statut,
    this.role,
    this.organisation,
  });

  factory MembreModel.fromJson(Map<String, dynamic> json) {
    return MembreModel(
      id: json['id'] as String,
      nom: json['nom'] as String,
      prenom: json['prenom'] as String,
      email: json['email'] as String,
      telephone: json['telephone'] as String?,
      statut: json['statut'] as String?,
      role: json['role'] as String?,
      organisation: json['organisation'] != null
          ? OrganisationModel.fromJson(json['organisation'] as Map<String, dynamic>)
          : null,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'id': id,
      'nom': nom,
      'prenom': prenom,
      'email': email,
      'telephone': telephone,
      'statut': statut,
      'role': role,
      'organisation': organisation?.toJson(),
    };
  }
}

/// Modèle pour une organisation
class OrganisationModel {
  final String? nom;

  const OrganisationModel({this.nom});

  factory OrganisationModel.fromJson(Map<String, dynamic> json) {
    return OrganisationModel(
      nom: json['nom'] as String?,
    );
  }

  Map<String, dynamic> toJson() {
    return {
      'nom': nom,
    };
  }
}
