This commit is contained in:
Felipe
2024-04-09 21:28:16 -05:00
parent 60547febb6
commit ef06730840
12 changed files with 1440 additions and 230 deletions
@@ -21,7 +21,7 @@ class FirebaseServiceRepository {
Stream<ServiceEntity> getService(String serviceId) {
return serviceCollection.doc(serviceId).snapshots().map((snapshot) {
if (snapshot.exists) {
return ServiceEntity.fromDocument(snapshot.data()!);
return ServiceEntity.fromDocument(snapshot.data()!, snapshot.id);
} else {
throw Exception('El servicio con ID $serviceId no existe');
}
@@ -31,10 +31,10 @@ class FirebaseServiceRepository {
Stream<List<ServiceEntity>> getServicesForUser(String userId) {
return serviceCollection
.where('user_id', isEqualTo: userId)
.where('status', whereIn: [0, 1, 2])
.where('status', whereIn: [0, 1, 2, 3])
.snapshots()
.map((querySnapshot) => querySnapshot.docs
.map((doc) => ServiceEntity.fromDocument(doc.data()))
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
.toList());
}
@@ -42,20 +42,20 @@ class FirebaseServiceRepository {
String professionalId) {
return serviceCollection
.where('professional_id', isEqualTo: professionalId)
.where('status', whereIn: [0, 1, 2])
.where('status', whereIn: [0, 1, 2, 3])
.snapshots()
.map((querySnapshot) => querySnapshot.docs
.map((doc) => ServiceEntity.fromDocument(doc.data()))
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
.toList());
}
Stream<List<ServiceEntity>> getServicesHistoryForUser(String userId) {
return serviceCollection
.where('user_id', isEqualTo: userId)
.where('status', whereIn: [3, 4])
.where('status', whereIn: [4, 5])
.snapshots()
.map((querySnapshot) => querySnapshot.docs
.map((doc) => ServiceEntity.fromDocument(doc.data()))
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
.toList());
}
@@ -63,10 +63,18 @@ class FirebaseServiceRepository {
String professionalId) {
return serviceCollection
.where('professional_id', isEqualTo: professionalId)
.where('status', whereIn: [3, 4])
.where('status', whereIn: [4, 5])
.snapshots()
.map((querySnapshot) => querySnapshot.docs
.map((doc) => ServiceEntity.fromDocument(doc.data()))
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
.toList());
}
}
// 0 - pending
// 1 - acepted
// 2 - denied
// 3 - active
// 4 - cancelled
// 5 - completed