Fix resetRejected: always reset pro_state even without professional record
Previous code deleted the professional record; if pro_state=3 but no record exists, the 404 blocked the retry. Now we unconditionally reset pro_state=0. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
5f02c45759
commit
b0e3467565
@@ -179,9 +179,7 @@ export class ProfessionalsService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async resetRejected(userId: string) {
|
async resetRejected(userId: string) {
|
||||||
const prof = await this.prisma.professionals.findUnique({ where: { user_id: userId } });
|
// Always reset pro_state regardless of whether a professional record exists
|
||||||
if (!prof) throw new NotFoundException('No se encontró solicitud');
|
|
||||||
// Reset to 0 without deleting — avoids FK constraint errors from services/reputations
|
|
||||||
await this.prisma.users.update({ where: { id: userId }, data: { pro_state: 0 } });
|
await this.prisma.users.update({ where: { id: userId }, data: { pro_state: 0 } });
|
||||||
return { message: 'Solicitud reiniciada' };
|
return { message: 'Solicitud reiniciada' };
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user