fix: location preference bug and service detail 404
- When professional accepts 'both' modes, add office/delivery toggle so the patient can explicitly choose instead of defaulting to delivery. Reset _bookAsDelivery when a professional is selected; office-only professionals still force office, delivery-only force delivery. - Fix 'sin servicio' on ServiceView: getServiceForUser was calling /users/:professionalId using the professionals-table UUID (not user UUID), returning 404 and setting service=null. Use the embedded professionals.users data from findById instead. - Convert ServiceView to StatefulWidget; fetch in initState to avoid re-fetching on every parent rebuild. - Remove client-side FCM notification from _requestService; backend create() now notifies the professional directly with the server key. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
735d8c2ba0
commit
646e44d126
@@ -69,8 +69,15 @@ class ServicesProvider extends ChangeNotifier {
|
||||
final data = await _api.get('/services/$serviceId');
|
||||
final map = data as Map<String, dynamic>;
|
||||
final servicio = Service.fromJson(map, map['id'] as String);
|
||||
final userData = await _api.get('/users/${servicio.professionalId}');
|
||||
final user = Usuario.fromDocument(userData as Map<String, dynamic>);
|
||||
// findById embeds professionals.users — use it instead of a second /users/:id call
|
||||
// (professional_id is a professionals-table UUID, not a user UUID)
|
||||
final profDoc = map['professionals'] as Map<String, dynamic>?;
|
||||
final userDoc = profDoc?['users'] as Map<String, dynamic>?;
|
||||
final user = userDoc != null
|
||||
? Usuario.fromDocument(userDoc)
|
||||
: Usuario(id: servicio.professionalId, email: null, phone: null,
|
||||
name: '?', nickname: null, city: null, picture: null,
|
||||
birthday: null, gender: null, proState: ProState.inactive, token: null);
|
||||
service = ServicioProfesional(user: user, service: servicio);
|
||||
} catch (e) {
|
||||
service = null;
|
||||
@@ -86,8 +93,13 @@ class ServicesProvider extends ChangeNotifier {
|
||||
final data = await _api.get('/services/$serviceId');
|
||||
final map = data as Map<String, dynamic>;
|
||||
final servicio = Service.fromJson(map, map['id'] as String);
|
||||
final userData = await _api.get('/users/${servicio.userId}');
|
||||
final user = Usuario.fromDocument(userData as Map<String, dynamic>);
|
||||
// findById embeds users (the patient) directly — use it instead of a second /users/:id call
|
||||
final userDoc = map['users'] as Map<String, dynamic>?;
|
||||
final user = userDoc != null
|
||||
? Usuario.fromDocument(userDoc)
|
||||
: Usuario(id: servicio.userId, email: null, phone: null,
|
||||
name: '?', nickname: null, city: null, picture: null,
|
||||
birthday: null, gender: null, proState: ProState.inactive, token: null);
|
||||
service = ServicioProfesional(user: user, service: servicio);
|
||||
} catch (e) {
|
||||
service = null;
|
||||
|
||||
Reference in New Issue
Block a user