fetchUser function
Fetches user from Firebase and returns a promise.
Implementation
Future<Map<String, dynamic>> fetchUser(
FirebaseFirestore instance,
String userId,
String usersCollectionName, {
String? role,
}) async {
final doc = await instance.collection(usersCollectionName).doc(userId).get();
final data = doc.data()!;
data['createdAt'] = data['createdAt']?.millisecondsSinceEpoch;
data['id'] = doc.id;
data['lastSeen'] = data['lastSeen']?.millisecondsSinceEpoch;
data['role'] = role;
data['updatedAt'] = data['updatedAt']?.millisecondsSinceEpoch;
return data;
}