fix: align Flutter API repositories with backend routes (Fase 3 prep)
- api_service_repository: use correct endpoints (services/me, services/professional,
professional/requests, professional/history, professional/calendar, etc.)
instead of generic /services?userId= query params
- api_service_repository: fix status conversion string↔enum, createService DTO fields,
handle paginated {data,meta} response, stub setProfessionalScored/setUserScored
(backend sets these automatically on POST /comments)
- api_score_repository: fix comment endpoints to /comments/user/:id and
/comments/professional/:id; handle paginated response
- api_professional_repository + api_user_repository: handle paginated {data,meta}
response from GET /professionals
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
e3e9509222
commit
130e52ddcd
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user