fix: professional profile not loading or saving correctly
- Fix typo aditional_address -> additional_address in toDocument() and fromDocument() - Clear ProfessionalFormProvider before fetch in initState() so TextFormField initialValue always applies to fresh data - Add clear() to ProfessionalFormProvider; call it on logout to avoid leaking data between users Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
732da2e475
commit
b31ff13657
@@ -132,7 +132,7 @@ class Profesional {
|
||||
rethusCode: (doc['rethus_code'] as String?) ?? '',
|
||||
rethusValidated: (doc['rethus_validated'] as bool?) ?? false,
|
||||
address: (doc['address'] as String?) ?? '',
|
||||
aditionalAddress: (doc['aditional_address'] as String?) ?? '',
|
||||
aditionalAddress: (doc['additional_address'] as String?) ?? '',
|
||||
profession: (doc['profession'] as String?) ?? '',
|
||||
ratePreferences: (doc['rate_preferences'] as bool?) ?? false,
|
||||
rate: (doc['rate'] as num?)?.toString() ?? '',
|
||||
@@ -202,7 +202,7 @@ class Profesional {
|
||||
'rethus_code': rethusCode,
|
||||
'rethus_validated': rethusValidated,
|
||||
'address': address,
|
||||
'aditional_address': aditionalAddress,
|
||||
'additional_address': aditionalAddress,
|
||||
'profession': profession,
|
||||
'rate_preferences': ratePreferences,
|
||||
'rate': double.tryParse(rate) ?? 0.0,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/scheduler.dart';
|
||||
import 'package:prosapp_web_app/models/usuario.dart';
|
||||
import 'package:prosapp_web_app/providers/professional_form_provider.dart';
|
||||
import 'package:prosapp_web_app/providers/professional_provider.dart';
|
||||
import 'package:prosapp_web_app/providers/services_provider.dart';
|
||||
import 'package:prosapp_web_app/router/router.dart';
|
||||
@@ -205,6 +206,7 @@ class AuthProvider extends ChangeNotifier {
|
||||
final ctx = NavigationService.navigatorKey.currentContext!;
|
||||
Provider.of<ServicesProvider>(ctx, listen: false).logout();
|
||||
Provider.of<ProfessionalProvider>(ctx, listen: false).logout();
|
||||
Provider.of<ProfessionalFormProvider>(ctx, listen: false).clear();
|
||||
|
||||
NavigationService.replaceTo(Flurorouter.phoneLoginRoute);
|
||||
}
|
||||
|
||||
@@ -60,6 +60,11 @@ class ProfessionalFormProvider with ChangeNotifier {
|
||||
bool _validForm() => formKey.currentState!.validate();
|
||||
bool _validProfileForm() => profileFormKey.currentState!.validate();
|
||||
|
||||
void clear() {
|
||||
profesional = null;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
setProfesional(Profesional p) {
|
||||
profesional = p;
|
||||
notifyListeners();
|
||||
|
||||
@@ -49,6 +49,7 @@ class _ProfessionalProfileViewState extends State<ProfessionalProfileView> {
|
||||
final pfp = Provider.of<ProfileFormProvider>(context, listen: false);
|
||||
final fp = Provider.of<ProfessionalFormProvider>(context, listen: false);
|
||||
pfp.user = auth.user;
|
||||
fp.clear(); // force spinner so TextFormField initialValue applies to fresh data
|
||||
Provider.of<ProfessionalProvider>(context, listen: false)
|
||||
.getProfessional(auth.user!.id)
|
||||
.then(fp.setProfesional);
|
||||
|
||||
Reference in New Issue
Block a user