replace: swap prosappweb content for prosapp_web_app (more complete version)
prosapp_web_app has chat, dashboard, calendar, support, 13 providers and Fluro URL routing. Keep Dockerfile + nginx.conf from previous prosappweb. Upgrade google_fonts 6.2.1 → 8.1.0 (Dart 3.12 compat fix). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
74a4f41902
commit
15175c1b91
@@ -0,0 +1,72 @@
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:prosapp_web_app/models/comment_entity.dart';
|
||||
import 'package:prosapp_web_app/models/profesional.dart';
|
||||
import 'package:prosapp_web_app/models/usuario.dart';
|
||||
import 'package:prosapp_web_app/models/usuario_profesional.dart';
|
||||
|
||||
class ProfessionalDetailProvider extends ChangeNotifier {
|
||||
UsuarioProfesional? professional;
|
||||
bool isLoading = true;
|
||||
|
||||
Future<void> getProfessionalById(String uid) async {
|
||||
try {
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
|
||||
final userDoc =
|
||||
await FirebaseFirestore.instance.collection('users').doc(uid).get();
|
||||
|
||||
if (!userDoc.exists) {
|
||||
print('Profesional no encontrado.');
|
||||
return;
|
||||
}
|
||||
|
||||
final user = Usuario.fromDocument(userDoc.data()!);
|
||||
|
||||
final professionalDoc = await FirebaseFirestore.instance
|
||||
.collection('professional_info')
|
||||
.doc(uid)
|
||||
.get();
|
||||
|
||||
if (!professionalDoc.exists) {
|
||||
print('Información profesional no encontrada.');
|
||||
return;
|
||||
}
|
||||
|
||||
final professionalInfo =
|
||||
Profesional.fromDocument(professionalDoc.data()!);
|
||||
|
||||
final averageScore = await _getAverageScore(uid);
|
||||
|
||||
professional = UsuarioProfesional(
|
||||
user: user,
|
||||
professionalInfo: professionalInfo,
|
||||
averageScore: averageScore,
|
||||
);
|
||||
} catch (e) {
|
||||
print('Error obteniendo profesional: $e');
|
||||
} finally {
|
||||
isLoading = false;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
|
||||
Future<double> _getAverageScore(String userId) async {
|
||||
final querySnapshot = await FirebaseFirestore.instance
|
||||
.collection('comments')
|
||||
.where('destination_id', isEqualTo: userId)
|
||||
.where('is_from_user', isEqualTo: true)
|
||||
.get();
|
||||
|
||||
if (querySnapshot.docs.isEmpty) {
|
||||
return 0.0;
|
||||
}
|
||||
|
||||
final scores = querySnapshot.docs
|
||||
.map((e) => CommentEntity.fromDocument(e.data()).score)
|
||||
.toList();
|
||||
final averageScore = scores.reduce((a, b) => a + b) / scores.length;
|
||||
return averageScore;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user