🔨 fix wrong concatenation of query where in get documents
This commit is contained in:
parent
97ccd8deee
commit
510fe26f1e
@ -35,15 +35,15 @@ export default class DocumentsController extends ApiController {
|
|||||||
let query: Prisma.DocumentsFindManyArgs = {};
|
let query: Prisma.DocumentsFindManyArgs = {};
|
||||||
if (req.query["q"]) {
|
if (req.query["q"]) {
|
||||||
query = JSON.parse(req.query["q"] as string);
|
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");
|
this.httpBadRequest(response, "You can't filter by uid");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const officeId: string = req.body.user.office_Id;
|
const officeId: string = req.body.user.office_Id;
|
||||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId };
|
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
|
//call service to get prisma entity
|
||||||
const documentEntities = await this.documentsService.get(query);
|
const documentEntities = await this.documentsService.get(query);
|
||||||
@ -124,7 +124,7 @@ export default class DocumentsController extends ApiController {
|
|||||||
return;
|
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");
|
this.httpForbidden(response, "You are not allowed to update a VALIDATED or REFUSED document");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -186,11 +186,9 @@ export default class DocumentsController extends ApiController {
|
|||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
const documentEntityUpdated: Documents = await this.documentsService.refuse(uid, documentEntity, req.body.refused_reason);
|
const documentEntityUpdated: Documents = await this.documentsService.refuse(uid, documentEntity, req.body.refused_reason);
|
||||||
|
|
||||||
|
|
||||||
//create email for asked document
|
//create email for asked document
|
||||||
await this.emailBuilder.sendDocumentEmails(documentEntityUpdated);
|
await this.emailBuilder.sendDocumentEmails(documentEntityUpdated);
|
||||||
|
|
||||||
|
|
||||||
//Hydrate ressource with prisma entity
|
//Hydrate ressource with prisma entity
|
||||||
const document = Document.hydrate<Document>(documentEntityUpdated, { strategy: "excludeAll" });
|
const document = Document.hydrate<Document>(documentEntityUpdated, { strategy: "excludeAll" });
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user