From 083c8fcc02a78e6b9c8894e04ceb83e95c1455c3 Mon Sep 17 00:00:00 2001 From: Methapon2001 <61303214+Methapon2001@users.noreply.github.com> Date: Wed, 18 Dec 2024 17:25:30 +0700 Subject: [PATCH] feat: add support for active only employee resolves https://github.com/Frappet/jws-frontend/issues/147 --- src/controllers/03-employee-controller.ts | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/controllers/03-employee-controller.ts b/src/controllers/03-employee-controller.ts index 7e0e45c..038f6bd 100644 --- a/src/controllers/03-employee-controller.ts +++ b/src/controllers/03-employee-controller.ts @@ -207,6 +207,7 @@ export class EmployeeController extends Controller { @Query() query: string = "", @Query() page: number = 1, @Query() pageSize: number = 30, + @Query() activeOnly?: boolean, ) { return this.listByCriteria( req, @@ -220,6 +221,7 @@ export class EmployeeController extends Controller { query, page, pageSize, + activeOnly, ); } @@ -237,6 +239,7 @@ export class EmployeeController extends Controller { @Query() query: string = "", @Query() page: number = 1, @Query() pageSize: number = 30, + @Query() activeOnly?: boolean, @Body() body?: { passport?: string[]; @@ -268,15 +271,17 @@ export class EmployeeController extends Controller { ] : undefined, AND: { - ...filterStatus(status), + ...filterStatus(activeOnly ? Status.ACTIVE : status), customerBranch: { + ...filterStatus(activeOnly ? Status.ACTIVE : status), id: customerBranchId, customerId, customer: isSystem(req.user) - ? undefined + ? filterStatus(activeOnly ? Status.ACTIVE : status) : { + ...filterStatus(activeOnly ? Status.ACTIVE : status), registeredBranch: { - OR: permissionCond(req.user), + OR: permissionCond(req.user, { activeOnly: activeOnly }), }, }, },