From 510fe26f1e9fc0c8f32e28c2772097bf15c7e3ac Mon Sep 17 00:00:00 2001 From: Max S Date: Fri, 13 Sep 2024 13:08:08 +0200 Subject: [PATCH] :hammer: fix wrong concatenation of query where in get documents --- src/app/api/notary/DocumentsController.ts | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/app/api/notary/DocumentsController.ts b/src/app/api/notary/DocumentsController.ts index 7e866c8e..f4af409c 100644 --- a/src/app/api/notary/DocumentsController.ts +++ b/src/app/api/notary/DocumentsController.ts @@ -35,15 +35,15 @@ export default class DocumentsController extends ApiController { let query: Prisma.DocumentsFindManyArgs = {}; if (req.query["q"]) { query = JSON.parse(req.query["q"] as string); - if(query.where?.uid) { + if (query.where?.uid) { this.httpBadRequest(response, "You can't filter by uid"); return; } } const officeId: string = req.body.user.office_Id; const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId }; - if (!query.where) query.where = { document_type: { office: officeWhereInput } }; - query.where.document_type!.office = officeWhereInput; + + query.where = { ...query.where, document_type: { office: officeWhereInput } }; //call service to get prisma entity const documentEntities = await this.documentsService.get(query); @@ -124,7 +124,7 @@ export default class DocumentsController extends ApiController { return; } - if(documentFound.document_status === EDocumentStatus.REFUSED || documentFound.document_status === EDocumentStatus.VALIDATED) { + if (documentFound.document_status === EDocumentStatus.REFUSED || documentFound.document_status === EDocumentStatus.VALIDATED) { this.httpForbidden(response, "You are not allowed to update a VALIDATED or REFUSED document"); return; } @@ -186,11 +186,9 @@ export default class DocumentsController extends ApiController { //call service to get prisma entity const documentEntityUpdated: Documents = await this.documentsService.refuse(uid, documentEntity, req.body.refused_reason); - //create email for asked document await this.emailBuilder.sendDocumentEmails(documentEntityUpdated); - //Hydrate ressource with prisma entity const document = Document.hydrate(documentEntityUpdated, { strategy: "excludeAll" });