From dc99169ef1b7e050dfe773befb0c9f76805a3499 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Thu, 18 Jun 2026 12:16:00 -0500 Subject: [PATCH] fix: correct remaining route mismatches and Spanish status strings in prosappweb - solicitudes: GET /services/professional/requests (not query params) - my_services: GET /services/me with paginated response handling - my_services_pro: GET /services/professional with paginated response handling - professional: handle paginated GET /professionals response - cita: PATCH /services/:id/status (not /services/:id); translate all Spanish status comparisons (pendiente/aprobado/iniciado/terminado) to backend English Co-Authored-By: Claude Sonnet 4.6 --- lib/src/presentation/screens/cita.dart | 29 ++++++++++++------- lib/src/presentation/screens/my_services.dart | 4 +-- .../presentation/screens/my_services_pro.dart | 4 +-- .../presentation/screens/professional.dart | 3 +- lib/src/presentation/screens/solicitudes.dart | 2 +- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/lib/src/presentation/screens/cita.dart b/lib/src/presentation/screens/cita.dart index 207266f..0389240 100644 --- a/lib/src/presentation/screens/cita.dart +++ b/lib/src/presentation/screens/cita.dart @@ -107,10 +107,19 @@ class _CitaScreenState extends State { } } + static const _toBackendStatus = { + 'pendiente': 'pending', + 'aprobado': 'accepted', + 'denegado': 'cancelled', + 'iniciado': 'active', + 'terminado': 'completed', + }; + Future _updateStatus(String status) async { try { + final backendStatus = _toBackendStatus[status] ?? status; await ApiService.instance - .patch('/services/${widget.evento.id}', {'status': status}); + .patch('/services/${widget.evento.id}/status', {'status': backendStatus}); } catch (e) { print('Error updating service status: $e'); } @@ -245,8 +254,8 @@ class _CitaScreenState extends State { ), widget.evento.userId == widget.evento.professionalId ? const SizedBox() - : widget.evento.status == 'aprobado' || - widget.evento.status == 'iniciado' + : widget.evento.status == 'accepted' || + widget.evento.status == 'active' ? const Padding( padding: EdgeInsets.symmetric(vertical: 20), child: Text( @@ -257,7 +266,7 @@ class _CitaScreenState extends State { : const SizedBox(height: 10), widget.evento.userId == widget.evento.professionalId ? const SizedBox() - : widget.evento.status == 'terminado' + : widget.evento.status == 'completed' ? pro == true ? widget.evento.professionalScored == true ? const SizedBox() @@ -339,8 +348,8 @@ class _CitaScreenState extends State { ), ], ) - : widget.evento.status == 'aprobado' || - widget.evento.status == 'iniciado' + : widget.evento.status == 'accepted' || + widget.evento.status == 'active' ? Row( children: [ const Expanded(child: SizedBox()), @@ -370,7 +379,7 @@ class _CitaScreenState extends State { const SizedBox(width: 20), ElevatedButton( onPressed: () async { - if (widget.evento.status != 'pendiente') { + if (widget.evento.status != 'pending') { // Start or retrieve chat via API try { await ApiService.instance.post( @@ -489,7 +498,7 @@ class _CitaScreenState extends State { ], ), ), - widget.evento.status == 'aprobado' + widget.evento.status == 'accepted' ? Padding( padding: const EdgeInsets.only(bottom: 30), child: Column( @@ -559,7 +568,7 @@ class _CitaScreenState extends State { ), ) : const SizedBox(), - widget.evento.status == 'pendiente' + widget.evento.status == 'pending' ? Padding( padding: const EdgeInsets.only(bottom: 30), child: Column( @@ -618,7 +627,7 @@ class _CitaScreenState extends State { ), ) : const SizedBox(), - widget.evento.status == 'iniciado' || ver == false + widget.evento.status == 'active' || ver == false ? Padding( padding: const EdgeInsets.only(bottom: 30), child: Column( diff --git a/lib/src/presentation/screens/my_services.dart b/lib/src/presentation/screens/my_services.dart index 2fd503a..b2141b9 100644 --- a/lib/src/presentation/screens/my_services.dart +++ b/lib/src/presentation/screens/my_services.dart @@ -32,8 +32,8 @@ class _MyServicesScreenState extends State { Future _load() async { try { - final List data = await ApiService.instance.get( - '/services?userId=$uid&status=aprobado,denegado,iniciado,terminado,pendiente'); + final raw = await ApiService.instance.get('/services/me'); + final List data = raw is Map ? (raw['data'] ?? []) : (raw as List); final List loaded = []; for (final e in data) { final event = Event.fromJson(e as Map); diff --git a/lib/src/presentation/screens/my_services_pro.dart b/lib/src/presentation/screens/my_services_pro.dart index 22cc4e9..06edaea 100644 --- a/lib/src/presentation/screens/my_services_pro.dart +++ b/lib/src/presentation/screens/my_services_pro.dart @@ -32,8 +32,8 @@ class _MyServicesProScreenState extends State { Future _load() async { try { - final List data = await ApiService.instance.get( - '/services?professionalId=$uid&status=aprobado,denegado,iniciado,terminado'); + final raw = await ApiService.instance.get('/services/professional'); + final List data = raw is Map ? (raw['data'] ?? []) : (raw as List); final List loaded = []; for (final e in data) { final event = Event.fromJson(e as Map); diff --git a/lib/src/presentation/screens/professional.dart b/lib/src/presentation/screens/professional.dart index e02c474..ec7e67c 100644 --- a/lib/src/presentation/screens/professional.dart +++ b/lib/src/presentation/screens/professional.dart @@ -73,7 +73,8 @@ class _ProfessionalScreenState extends State { final String query = widget.profession.isNotEmpty ? '/professionals?profession=${Uri.encodeComponent(widget.profession)}' : '/professionals'; - final List data = await ApiService.instance.get(query); + final raw = await ApiService.instance.get(query); + final List data = raw is Map ? (raw['data'] ?? []) : (raw as List); final List loaded = []; for (final e in data) { diff --git a/lib/src/presentation/screens/solicitudes.dart b/lib/src/presentation/screens/solicitudes.dart index 665be1f..421189b 100644 --- a/lib/src/presentation/screens/solicitudes.dart +++ b/lib/src/presentation/screens/solicitudes.dart @@ -30,7 +30,7 @@ class _SolicitudScreenState extends State { Future _load() async { try { final List data = await ApiService.instance - .get('/services?professionalId=$myUid&status=pendiente'); + .get('/services/professional/requests'); final List loaded = []; for (final e in data) { final event = Event.fromJson(e as Map);