feat: dashboard city validation + professionals by location
- Professionals filtered by user city + proximity (lat/lng) to selected address - ProfessionalsProvider: setLocationContext(city, lat, lng) updates filter and reloads - Dashboard: detect city mismatch after reverse geocode, block booking if wrong city - Dashboard: autocomplete biased toward user's city - Dashboard: setLocationContext called before navigating to professionals list - Dashboard: keyboard no longer shifts map layout on tablet (MediaQuery viewInsets=0) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
e0982995e6
commit
f26b3d3c03
@@ -6,24 +6,40 @@ class ProfessionalsProvider extends ChangeNotifier {
|
||||
List<UsuarioProfesional> professionals = [];
|
||||
bool isLoading = true;
|
||||
bool _initialized = false;
|
||||
String? _locationCity;
|
||||
double? _locationLat;
|
||||
double? _locationLng;
|
||||
final _api = ApiService.instance;
|
||||
|
||||
void updateCity(String? city) {
|
||||
// Only used to trigger the initial load when auth becomes available.
|
||||
if (!_initialized) {
|
||||
_initialized = true;
|
||||
_locationCity = city;
|
||||
getProfessionals();
|
||||
}
|
||||
}
|
||||
|
||||
void setLocationContext({required String? city, required double lat, required double lng}) {
|
||||
if (city != null && city.isNotEmpty) _locationCity = city;
|
||||
_locationLat = lat;
|
||||
_locationLng = lng;
|
||||
getProfessionals();
|
||||
}
|
||||
|
||||
Future<void> getProfessionals({String? search}) async {
|
||||
isLoading = true;
|
||||
notifyListeners();
|
||||
try {
|
||||
final path = (search != null && search.trim().isNotEmpty)
|
||||
? '/professionals?search=${Uri.encodeComponent(search.trim())}'
|
||||
: '/professionals';
|
||||
final res = await _api.get(path);
|
||||
final params = <String, String>{};
|
||||
if (search != null && search.trim().isNotEmpty) params['search'] = search.trim();
|
||||
if (_locationCity != null && _locationCity!.isNotEmpty) params['city'] = _locationCity!.trim();
|
||||
if (_locationLat != null) params['lat'] = _locationLat.toString();
|
||||
if (_locationLng != null) params['lng'] = _locationLng.toString();
|
||||
|
||||
final query = params.isEmpty
|
||||
? ''
|
||||
: '?${params.entries.map((e) => '${e.key}=${Uri.encodeComponent(e.value)}').join('&')}';
|
||||
final res = await _api.get('/professionals$query');
|
||||
final list = (res is Map ? res['data'] : res) as List;
|
||||
professionals = list
|
||||
.map((e) => UsuarioProfesional.fromDocument(e as Map<String, dynamic>))
|
||||
|
||||
Reference in New Issue
Block a user