From f3beea6c8c5e39bc9c30401300a8b4a495211fb5 Mon Sep 17 00:00:00 2001 From: OxSaitama Date: Thu, 13 Jul 2023 15:28:02 +0200 Subject: [PATCH] refacto GET method with search param for offices --- src/app/api/super-admin/OfficesController.ts | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/app/api/super-admin/OfficesController.ts b/src/app/api/super-admin/OfficesController.ts index d2c034b8..32f7aa34 100644 --- a/src/app/api/super-admin/OfficesController.ts +++ b/src/app/api/super-admin/OfficesController.ts @@ -26,6 +26,19 @@ export default class OfficesController extends ApiController { if (req.query["q"]) { query = JSON.parse(req.query["q"] as string); } + + if(req.query["search"] && typeof req.query["search"] === "string") { + const filter = req.query["search"]; + query = { + where : { + name: { + contains: filter, + mode: "insensitive", + } + } + } + } + //call service to get prisma entity const officesEntities: Offices[] = await this.officesService.get(query); //Hydrate ressource with prisma entity