feat: filter users by names (#52)
solve those tickets : - https://app.ora.pm/p/fb56ed95daa7456b888d266a050b9afa?v=86662&s=29580&t=k&c=07eae5bc771f49b7b67b898c11b325b6 - https://app.ora.pm/p/fb56ed95daa7456b888d266a050b9afa?v=86662&s=29580&t=k&c=e0a578d6ae624778b42a15908d9b2298
This commit is contained in:
commit
49d17ad14b
@ -27,9 +27,24 @@ export default class UsersController extends ApiController {
|
|||||||
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 (req.query["search"] && typeof req.query["search"] === "string") {
|
||||||
|
const filter = req.query["search"];
|
||||||
|
query = {
|
||||||
|
where: {
|
||||||
|
contact: {
|
||||||
|
OR: [
|
||||||
|
{ first_name: { contains: filter, mode: "insensitive" } },
|
||||||
|
{ last_name: { contains: filter, mode: "insensitive" } },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
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 = { office_membership: officeWhereInput};
|
if (!query.where) query.where = { office_membership: officeWhereInput };
|
||||||
query.where.office_membership = officeWhereInput;
|
query.where.office_membership = officeWhereInput;
|
||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
|
@ -27,6 +27,20 @@ export default class UsersController extends ApiController {
|
|||||||
query = JSON.parse(req.query["q"] as string);
|
query = JSON.parse(req.query["q"] as string);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (req.query["search"] && typeof req.query["search"] === "string") {
|
||||||
|
const filter = req.query["search"];
|
||||||
|
query = {
|
||||||
|
where: {
|
||||||
|
contact: {
|
||||||
|
OR: [
|
||||||
|
{ first_name: { contains: filter, mode: "insensitive" } },
|
||||||
|
{ last_name: { contains: filter, mode: "insensitive" } },
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
//call service to get prisma entity
|
//call service to get prisma entity
|
||||||
const usersEntities = await this.usersService.get(query);
|
const usersEntities = await this.usersService.get(query);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user