class UserModel { final String uid; final String firstName; final String lastName; final String role; final String profilePhotoUrl; final String email; final String phoneNumber; UserModel({ required this.uid, required this.firstName, required this.lastName, required this.role, required this.profilePhotoUrl, required this.email, required this.phoneNumber, }); // Convertit une Map (Firestore) en UserModel factory UserModel.fromMap(Map data, String uid) { return UserModel( uid: uid, firstName: data['firstName'] ?? '', lastName: data['lastName'] ?? '', role: data['role'] ?? 'USER', profilePhotoUrl: data['profilePhotoUrl'] ?? '', email: data['email'] ?? '', phoneNumber: data['phoneNumber'] ?? '', ); } // Convertit un UserModel en Map pour Firestore Map toMap() { return { 'firstName': firstName, 'lastName': lastName, 'role': role, 'profilePhotoUrl': profilePhotoUrl, 'email': email, 'phoneNumber': phoneNumber, }; } UserModel copyWith({ String? firstName, String? lastName, String? role, String? profilePhotoUrl, String? email, String? phoneNumber, }) { return UserModel( uid: uid, // L'UID ne change pas firstName: firstName ?? this.firstName, lastName: lastName ?? this.lastName, role: role ?? this.role, profilePhotoUrl: profilePhotoUrl ?? this.profilePhotoUrl, email: email ?? this.email, phoneNumber: phoneNumber ?? this.phoneNumber, ); } }