refacto GET officeFolder for admin & super-admin

This commit is contained in:
OxSaitama 2023-10-09 12:02:28 +02:00
parent 94e1eb24d4
commit 23ba2672dd
2 changed files with 13 additions and 14 deletions

View File

@ -58,10 +58,10 @@ export default class OfficeFoldersController extends ApiController {
};
}
const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
if(!query.where) query.where = { office: officeWhereInput};
query.where.office = officeWhereInput;
const userId: string = req.body.user.userId;
if (query.where?.stakeholders) delete query.where.stakeholders;
const officeFoldersWhereInput: Prisma.OfficeFoldersWhereInput = { ...query.where, stakeholders: { some: { uid: userId } } };
query.where = officeFoldersWhereInput;
//call service to get prisma entity
const officeFolderEntities: OfficeFolders[] = await this.officeFoldersService.get(query);

View File

@ -44,12 +44,10 @@ export default class OfficeFoldersController extends ApiController {
{
customers: {
some: {
contact: {
OR: [
{ first_name: { contains: filter, mode: "insensitive" } },
{ last_name: { contains: filter, mode: "insensitive" } },
],
},
OR: [
{ contact: { first_name: { contains: filter, mode: "insensitive" } } },
{ contact: { last_name: { contains: filter, mode: "insensitive" } } },
],
},
},
},
@ -57,10 +55,11 @@ export default class OfficeFoldersController extends ApiController {
},
};
}
const officeId: string = req.body.user.office_Id;
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId };
if (!query.where) query.where = { office: officeWhereInput };
query.where.office = officeWhereInput;
const userId: string = req.body.user.userId;
if (query.where?.stakeholders) delete query.where.stakeholders;
const officeFoldersWhereInput: Prisma.OfficeFoldersWhereInput = { ...query.where, stakeholders: { some: { uid: userId } } };
query.where = officeFoldersWhereInput;
//call service to get prisma entity
const officeFolderEntities: OfficeFolders[] = await this.officeFoldersService.get(query);