lista de servicios

This commit is contained in:
Felipe
2024-04-05 18:40:17 -05:00
parent e82c7c3afd
commit df9f44a8f2
12 changed files with 398 additions and 250 deletions
@@ -189,4 +189,21 @@ class FirebaseProfessionalRepository {
rethrow;
}
}
Future<List<ProfessionalEntity>> getProfessionsFromIds(
Iterable<String> ids) async {
try {
// Realizar una consulta única para obtener la información de todos los usuarios
final querySnapshot = await professionalCollection
.where(FieldPath.documentId, whereIn: ids)
.get();
return querySnapshot.docs
.map((e) => ProfessionalEntity.fromDocument(e.data()))
.toList();
} catch (e) {
log('getProfessionsFromIds ${e.toString()}');
rethrow;
}
}
}
@@ -11,6 +11,13 @@ class FirebaseServiceRepository {
return docRef.id;
}
Future<void> updateServiceStatus(
String serviceId, ServiceStatus newStatus) async {
await serviceCollection
.doc(serviceId)
.update({'status': enumToIntService(newStatus)});
}
Stream<ServiceEntity> getService(String serviceId) {
return serviceCollection.doc(serviceId).snapshots().map((snapshot) {
if (snapshot.exists) {
@@ -21,10 +28,12 @@ class FirebaseServiceRepository {
});
}
Future<void> updateServiceStatus(
String serviceId, ServiceStatus newStatus) async {
await serviceCollection
.doc(serviceId)
.update({'status': enumToIntService(newStatus)});
Stream<List<ServiceEntity>> getServicesForUser(String userId) {
return serviceCollection
.where('user_id', isEqualTo: userId)
.snapshots()
.map((querySnapshot) => querySnapshot.docs
.map((doc) => ServiceEntity.fromDocument(doc.data()))
.toList());
}
}
@@ -403,4 +403,20 @@ class FirebaseUserRepository implements UserRepository {
rethrow;
}
}
@override
Future<List<MyUser>> getUsersFromIds(Iterable<String> ids) async {
try {
// Realizar una consulta única para obtener la información de todos los usuarios
final querySnapshot =
await usersCollection.where(FieldPath.documentId, whereIn: ids).get();
return querySnapshot.docs
.map((e) => MyUser.fromEntity(MyUserEntity.fromDocument(e.data())))
.toList();
} catch (e) {
log('getUsersFromIds ${e.toString()}');
rethrow;
}
}
}
@@ -45,6 +45,8 @@ abstract class UserRepository {
Future<void> createUser(MyUser myUser);
Future<List<MyUser>> getUsersProfessionalActive();
Future<List<MyUser>> getUsersFromIds(Iterable<String> ids);
}
enum UpdatePassworErros { credentialsWrong, userNotFound, unknown }