fix: align Flutter endpoints and model parsing with actual NestJS backend
- 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>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
60216fd0e3
commit
0ecca498ad
@@ -49,23 +49,21 @@ class ScheduleEntity {
|
||||
return ScheduleEntity(
|
||||
enabled: doc['habilitado'] as bool,
|
||||
continuousDay: doc['continuous_day'] as bool,
|
||||
range1Hour1: _parseTime(doc['range1Hour1']),
|
||||
range1Hour2: _parseTime(doc['range1Hour2']),
|
||||
range2Hour1: _parseTime(doc['range2Hour1']),
|
||||
range2Hour2: _parseTime(doc['range2Hour2']),
|
||||
range1Hour1: parseTime(doc['range1Hour1']),
|
||||
range1Hour2: parseTime(doc['range1Hour2']),
|
||||
range2Hour1: parseTime(doc['range2Hour1']),
|
||||
range2Hour2: parseTime(doc['range2Hour2']),
|
||||
);
|
||||
}
|
||||
|
||||
static TimeOfDay? _parseTime(String? time) {
|
||||
static TimeOfDay? parseTime(String? time) {
|
||||
try {
|
||||
if (time == null) return null;
|
||||
final components = time.split(':');
|
||||
if (components.length != 2) {
|
||||
return null;
|
||||
}
|
||||
final hour = int.parse(components[0]);
|
||||
final minutes = int.parse(components[1]);
|
||||
return TimeOfDay(hour: hour, minute: minutes);
|
||||
// Handle ISO8601 from backend (e.g. "1970-01-01T08:30:00.000Z")
|
||||
final t = time.contains('T') ? time.split('T')[1] : time;
|
||||
final components = t.split(':');
|
||||
if (components.length < 2) return null;
|
||||
return TimeOfDay(hour: int.parse(components[0]), minute: int.parse(components[1]));
|
||||
} catch (e) {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user