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 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
ce11aa813e
commit
dc99169ef1
@@ -107,10 +107,19 @@ class _CitaScreenState extends State<CitaScreen> {
|
||||
}
|
||||
}
|
||||
|
||||
static const _toBackendStatus = {
|
||||
'pendiente': 'pending',
|
||||
'aprobado': 'accepted',
|
||||
'denegado': 'cancelled',
|
||||
'iniciado': 'active',
|
||||
'terminado': 'completed',
|
||||
};
|
||||
|
||||
Future<void> _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<CitaScreen> {
|
||||
),
|
||||
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<CitaScreen> {
|
||||
: 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<CitaScreen> {
|
||||
),
|
||||
],
|
||||
)
|
||||
: 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<CitaScreen> {
|
||||
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<CitaScreen> {
|
||||
],
|
||||
),
|
||||
),
|
||||
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<CitaScreen> {
|
||||
),
|
||||
)
|
||||
: 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<CitaScreen> {
|
||||
),
|
||||
)
|
||||
: const SizedBox(),
|
||||
widget.evento.status == 'iniciado' || ver == false
|
||||
widget.evento.status == 'active' || ver == false
|
||||
? Padding(
|
||||
padding: const EdgeInsets.only(bottom: 30),
|
||||
child: Column(
|
||||
|
||||
@@ -32,8 +32,8 @@ class _MyServicesScreenState extends State<MyServicesScreen> {
|
||||
|
||||
Future<void> _load() async {
|
||||
try {
|
||||
final List<dynamic> data = await ApiService.instance.get(
|
||||
'/services?userId=$uid&status=aprobado,denegado,iniciado,terminado,pendiente');
|
||||
final raw = await ApiService.instance.get('/services/me');
|
||||
final List<dynamic> data = raw is Map ? (raw['data'] ?? []) : (raw as List);
|
||||
final List<Event> loaded = [];
|
||||
for (final e in data) {
|
||||
final event = Event.fromJson(e as Map<String, dynamic>);
|
||||
|
||||
@@ -32,8 +32,8 @@ class _MyServicesProScreenState extends State<MyServicesProScreen> {
|
||||
|
||||
Future<void> _load() async {
|
||||
try {
|
||||
final List<dynamic> data = await ApiService.instance.get(
|
||||
'/services?professionalId=$uid&status=aprobado,denegado,iniciado,terminado');
|
||||
final raw = await ApiService.instance.get('/services/professional');
|
||||
final List<dynamic> data = raw is Map ? (raw['data'] ?? []) : (raw as List);
|
||||
final List<Event> loaded = [];
|
||||
for (final e in data) {
|
||||
final event = Event.fromJson(e as Map<String, dynamic>);
|
||||
|
||||
@@ -73,7 +73,8 @@ class _ProfessionalScreenState extends State<ProfessionalScreen> {
|
||||
final String query = widget.profession.isNotEmpty
|
||||
? '/professionals?profession=${Uri.encodeComponent(widget.profession)}'
|
||||
: '/professionals';
|
||||
final List<dynamic> data = await ApiService.instance.get(query);
|
||||
final raw = await ApiService.instance.get(query);
|
||||
final List<dynamic> data = raw is Map ? (raw['data'] ?? []) : (raw as List);
|
||||
|
||||
final List<Professional> loaded = [];
|
||||
for (final e in data) {
|
||||
|
||||
@@ -30,7 +30,7 @@ class _SolicitudScreenState extends State<SolicitudScreen> {
|
||||
Future<void> _load() async {
|
||||
try {
|
||||
final List<dynamic> data = await ApiService.instance
|
||||
.get('/services?professionalId=$myUid&status=pendiente');
|
||||
.get('/services/professional/requests');
|
||||
final List<Event> loaded = [];
|
||||
for (final e in data) {
|
||||
final event = Event.fromJson(e as Map<String, dynamic>);
|
||||
|
||||
Reference in New Issue
Block a user