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 userId: string = req.body.user.userId;
|
||||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId } ;
|
if (query.where?.stakeholders) delete query.where.stakeholders;
|
||||||
if(!query.where) query.where = { office: officeWhereInput};
|
const officeFoldersWhereInput: Prisma.OfficeFoldersWhereInput = { ...query.where, stakeholders: { some: { uid: userId } } };
|
||||||
query.where.office = officeWhereInput;
|
query.where = officeFoldersWhereInput;
|
||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
const officeFolderEntities: OfficeFolders[] = await this.officeFoldersService.get(query);
|
const officeFolderEntities: OfficeFolders[] = await this.officeFoldersService.get(query);
|
||||||
|
@ -44,23 +44,22 @@ export default class OfficeFoldersController extends ApiController {
|
|||||||
{
|
{
|
||||||
customers: {
|
customers: {
|
||||||
some: {
|
some: {
|
||||||
contact: {
|
|
||||||
OR: [
|
OR: [
|
||||||
{ first_name: { contains: filter, mode: "insensitive" } },
|
{ contact: { first_name: { contains: filter, mode: "insensitive" } } },
|
||||||
{ last_name: { contains: filter, mode: "insensitive" } },
|
{ contact: { last_name: { contains: filter, mode: "insensitive" } } },
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const officeId: string = req.body.user.office_Id;
|
|
||||||
const officeWhereInput: Prisma.OfficesWhereInput = { uid: officeId };
|
const userId: string = req.body.user.userId;
|
||||||
if (!query.where) query.where = { office: officeWhereInput };
|
if (query.where?.stakeholders) delete query.where.stakeholders;
|
||||||
query.where.office = officeWhereInput;
|
const officeFoldersWhereInput: Prisma.OfficeFoldersWhereInput = { ...query.where, stakeholders: { some: { uid: userId } } };
|
||||||
|
query.where = officeFoldersWhereInput;
|
||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
const officeFolderEntities: OfficeFolders[] = await this.officeFoldersService.get(query);
|
const officeFolderEntities: OfficeFolders[] = await this.officeFoldersService.get(query);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user