refacto GET officeFolder for admin & super-admin
This commit is contained in:
parent
94e1eb24d4
commit
23ba2672dd
@ -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);
|
||||
|
@ -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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user