From d551739d0c406c4593fb0045c0044a3a8c29fd67 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Sun, 28 Jun 2026 17:20:35 -0500 Subject: [PATCH] Fix upsert: create professional record if none exists PATCH /professionals/me now works for first-time submissions. Creates the record with pro_state=1 if user has no professional entry. Co-Authored-By: Claude Sonnet 4.6 --- backend/src/professionals/professionals.service.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/backend/src/professionals/professionals.service.ts b/backend/src/professionals/professionals.service.ts index cc31842..0236776 100644 --- a/backend/src/professionals/professionals.service.ts +++ b/backend/src/professionals/professionals.service.ts @@ -68,8 +68,12 @@ export class ProfessionalsService { } async upsert(userId: string, data: any) { - const prof = await this.prisma.professionals.findUnique({ where: { user_id: userId } }); - if (!prof) throw new NotFoundException('Debes solicitar ser profesional primero'); + const existing = await this.prisma.professionals.findUnique({ where: { user_id: userId } }); + + if (!existing) { + await this.prisma.users.update({ where: { id: userId }, data: { pro_state: 1 } }); + return this.prisma.professionals.create({ data: { user_id: userId, ...data } }); + } return this.prisma.professionals.update({ where: { user_id: userId }, data }); }