fix: professional profile fetch uses /me endpoint and re-fetches after save
- Use GET /professionals/me (JWT-authenticated) instead of /professionals/{uid}
to avoid silent failures when the user_id lookup fails
- After save, re-fetch from server so fp.profesional reflects confirmed server state
on the next page navigation
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
b31ff13657
commit
ee678b26ff
@@ -85,6 +85,12 @@ class ProfessionalFormProvider with ChangeNotifier {
|
||||
Future<bool> updateProfesionalProfileInfo(String userId) async {
|
||||
if (!_validProfileForm()) return false;
|
||||
await _api.patch('/professionals/me', profesional!.toDocument());
|
||||
// Re-fetch from server to confirm saved data is reflected in the form
|
||||
try {
|
||||
final data = await _api.get('/professionals/me');
|
||||
profesional = Profesional.fromDocument(data as Map<String, dynamic>);
|
||||
notifyListeners();
|
||||
} catch (_) {}
|
||||
NotificationsService.showSnackbar('Información actualizada');
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -14,9 +14,10 @@ class ProfessionalProvider extends ChangeNotifier {
|
||||
|
||||
Future<Profesional> getProfessional(String uid) async {
|
||||
try {
|
||||
final data = await _api.get('/professionals/$uid');
|
||||
final data = await _api.get('/professionals/me');
|
||||
profesional = Profesional.fromDocument(data as Map<String, dynamic>);
|
||||
} catch (e) {
|
||||
} catch (_) {
|
||||
// Professional profile doesn't exist yet — return empty so the form shows blank
|
||||
profesional = Profesional(
|
||||
id: uid,
|
||||
identification: '',
|
||||
|
||||
Reference in New Issue
Block a user