chore: remove Firebase dependencies and legacy code (Fase 4)
- Delete all firebase_*_repository.dart files (replaced by api_* equivalents) - Remove cloud_firestore, firebase_auth, firebase_storage, firebase_core from all package pubspecs - Remove cloud_firestore from main pubspec.yaml - Delete firebase_options.dart (no longer referenced) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
733384091c
commit
af91e0ba04
@@ -1,120 +0,0 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:service_repository/service_repository.dart';
|
||||
|
||||
class FirebaseServiceRepository {
|
||||
final serviceCollection = FirebaseFirestore.instance.collection('services');
|
||||
|
||||
Future<String> createService(ServiceEntity entity) async {
|
||||
DocumentReference<Map<String, dynamic>> docRef =
|
||||
await serviceCollection.add(entity.toDocument());
|
||||
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) {
|
||||
return ServiceEntity.fromDocument(snapshot.data()!, snapshot.id);
|
||||
} else {
|
||||
throw Exception('El servicio con ID $serviceId no existe');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Stream<List<ServiceEntity>> getServicesForUser(String userId) {
|
||||
return serviceCollection
|
||||
.where('user_id', isEqualTo: userId)
|
||||
.where('status', whereIn: [0, 1, 3])
|
||||
.snapshots()
|
||||
.map((querySnapshot) => querySnapshot.docs
|
||||
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
|
||||
.toList());
|
||||
}
|
||||
|
||||
Stream<List<ServiceEntity>> getServicesForProfessional(
|
||||
String professionalId) {
|
||||
return serviceCollection
|
||||
.where('professional_id', isEqualTo: professionalId)
|
||||
.where('status', whereIn: [1, 3])
|
||||
.snapshots()
|
||||
.map((querySnapshot) => querySnapshot.docs
|
||||
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
|
||||
.toList());
|
||||
}
|
||||
|
||||
Future<List<ServiceEntity>> getServicesForProfessionalforCalendar(
|
||||
String professionalId) async {
|
||||
QuerySnapshot<Map<String, dynamic>> query = await serviceCollection
|
||||
.where('professional_id', isEqualTo: professionalId)
|
||||
.where('status', whereIn: [0, 1, 2, 3, 6]).get();
|
||||
|
||||
return query.docs
|
||||
.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: [2, 4, 5])
|
||||
.snapshots()
|
||||
.map((querySnapshot) => querySnapshot.docs
|
||||
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
|
||||
.toList());
|
||||
}
|
||||
|
||||
Stream<List<ServiceEntity>> getServicesHistoryForProfessional(
|
||||
String professionalId) {
|
||||
return serviceCollection
|
||||
.where('professional_id', isEqualTo: professionalId)
|
||||
.where('status', whereIn: [2, 4, 5])
|
||||
.snapshots()
|
||||
.map((querySnapshot) => querySnapshot.docs
|
||||
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
|
||||
.toList());
|
||||
}
|
||||
|
||||
Stream<List<ServiceEntity>> getPendingServicesForProfessional(String professionalId) {
|
||||
return serviceCollection
|
||||
.where('professional_id', isEqualTo: professionalId)
|
||||
.where('status', whereIn: [0])
|
||||
.snapshots()
|
||||
.map((querySnapshot) => querySnapshot.docs
|
||||
.map((doc) => ServiceEntity.fromDocument(doc.data(), doc.id))
|
||||
.toList());
|
||||
}
|
||||
|
||||
Future<int> countPendingServicesForProfessional(String professionalId) async {
|
||||
QuerySnapshot<Map<String, dynamic>> query = await serviceCollection
|
||||
.where('professional_id', isEqualTo: professionalId)
|
||||
.where('status', isEqualTo: 0)
|
||||
.get();
|
||||
|
||||
return query.size;
|
||||
}
|
||||
|
||||
// actualizar professionalScored a true
|
||||
Future<void> setProfessionalScored(String serviceId) {
|
||||
return serviceCollection
|
||||
.doc(serviceId)
|
||||
.update({'professional_scored': true});
|
||||
}
|
||||
|
||||
Future<void> setUserScored(String serviceId) {
|
||||
return serviceCollection.doc(serviceId).update({'user_scored': true});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 0 - pending
|
||||
// 1 - acepted
|
||||
// 2 - denied
|
||||
// 3 - active
|
||||
// 4 - cancelled
|
||||
// 5 - completed
|
||||
Reference in New Issue
Block a user