diff --git a/backend/src/professionals/professionals.service.ts b/backend/src/professionals/professionals.service.ts index 6e67701..5d60bcf 100644 --- a/backend/src/professionals/professionals.service.ts +++ b/backend/src/professionals/professionals.service.ts @@ -25,7 +25,8 @@ export class ProfessionalsService { } async findById(id: string) { - const prof = await this.prisma.professionals.findUnique({ + // Accept either the professional UUID or the user_id (legacy Flutter behavior) + let prof = await this.prisma.professionals.findUnique({ where: { id }, include: { users: { select: { id: true, name: true, picture: true, city: true } }, @@ -34,6 +35,17 @@ export class ProfessionalsService { payment_methods: true, }, }); + if (!prof) { + prof = await this.prisma.professionals.findUnique({ + where: { user_id: id }, + include: { + users: { select: { id: true, name: true, picture: true, city: true } }, + schedules: { orderBy: { day_of_week: 'asc' } }, + specializations: true, + payment_methods: true, + }, + }); + } if (!prof) throw new NotFoundException('Profesional no encontrado'); return prof; } diff --git a/backend/src/services/services.service.ts b/backend/src/services/services.service.ts index 706d9c8..120e9e8 100644 --- a/backend/src/services/services.service.ts +++ b/backend/src/services/services.service.ts @@ -21,12 +21,14 @@ export class ServicesService { longitude?: number; location_preference?: 'office' | 'delivery'; }) { - const prof = await this.prisma.professionals.findUnique({ where: { id: data.professional_id } }); + // Accept either professional UUID or user_id (legacy Flutter behavior) + let prof = await this.prisma.professionals.findUnique({ where: { id: data.professional_id } }); + if (!prof) prof = await this.prisma.professionals.findUnique({ where: { user_id: data.professional_id } }); if (!prof || !prof.is_active) throw new BadRequestException('Profesional no disponible'); return this.prisma.services.create({ data: { - professional_id: data.professional_id, + professional_id: prof.id, user_id: data.user_id, day: new Date(data.day), description: data.description,