- Auth: phone login → POST /auth/phone (direct, no OTP); link phone → POST /auth/verify-phone; add email → POST /auth/link-email
- Services: replace query-param paths with dedicated role endpoints (/services/me, /services/professional/requests, /services/professional, etc.)
- Services: PATCH /services/:id → PATCH /services/:id/status
- Calendar: → GET /services/professional/calendar
- Professionals: /users/professionals → /professionals (handles {data:[...]} response)
- Professional info: /professional-info/:id → /professionals/:id; PATCH → /professionals/me
- Comments: /comments?... → /comments/user/:id and /comments/professional/:id
- Chat: /chats → /chat; start chat → POST /chat/start/:professionalId; poll GET /chat/:chatId/messages; send → POST /chat/:chatId/message
- Cities: /cities → GET /locations/countries (parse nested countries→regions→cities)
- Profesional.fromDocument: null-safe fields; convert schedules array→Schedules, specializations array→name/picture lists, payment_methods object/array
- Usuario.fromDocument: null-safe professional_state and id
- UsuarioProfesional.fromDocument: handle backend format (users nested, professional at top level)
- ScheduleEntity.parseTime: handle ISO8601 time strings from backend
- MessageEntity.fromDocument: accept sender_id (backend) or owner_id (legacy)
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
61 lines
1.6 KiB
Dart
61 lines
1.6 KiB
Dart
import 'package:flutter/widgets.dart';
|
|
import 'package:prosapp_web_app/models/location_preferences.dart';
|
|
import 'package:prosapp_web_app/models/payment_method_entity.dart';
|
|
import 'package:prosapp_web_app/models/profesional.dart';
|
|
import 'package:prosapp_web_app/models/schedules.dart';
|
|
import 'package:prosapp_web_app/services/api_service.dart';
|
|
|
|
class ProfessionalProvider extends ChangeNotifier {
|
|
Profesional? profesional;
|
|
bool _isProModeActive = false;
|
|
final _api = ApiService.instance;
|
|
|
|
bool get isProModeActive => _isProModeActive;
|
|
|
|
Future<Profesional> getProfessional(String uid) async {
|
|
try {
|
|
final data = await _api.get('/professionals/$uid');
|
|
profesional = Profesional.fromDocument(data as Map<String, dynamic>);
|
|
} catch (e) {
|
|
profesional = Profesional(
|
|
id: uid,
|
|
identification: '',
|
|
address: '',
|
|
aditionalAddress: '',
|
|
profession: '',
|
|
ratePreferences: false,
|
|
rate: '',
|
|
locationPreferences: LocationPreferences.office,
|
|
bannerPicture: '',
|
|
identificationPicture: '',
|
|
certificatePicture: '',
|
|
latitude: 0,
|
|
longitude: 0,
|
|
specializations: [],
|
|
specializationsPictures: [],
|
|
schedules: Schedules.empty,
|
|
paymentMethods: PaymentMethodEntity.empty,
|
|
);
|
|
}
|
|
notifyListeners();
|
|
return profesional!;
|
|
}
|
|
|
|
void logout() {
|
|
_isProModeActive = false;
|
|
notifyListeners();
|
|
}
|
|
|
|
void toggleProMode() {
|
|
_isProModeActive = !_isProModeActive;
|
|
notifyListeners();
|
|
}
|
|
|
|
void setIsProModeActive(bool value) {
|
|
_isProModeActive = value;
|
|
notifyListeners();
|
|
}
|
|
|
|
sendProfessionalToReview() {}
|
|
}
|