feat: add support for active only employee

resolves https://github.com/Frappet/jws-frontend/issues/147
This commit is contained in:
Methapon2001 2024-12-18 17:25:30 +07:00
parent db3bdfb25d
commit 083c8fcc02

View file

@ -207,6 +207,7 @@ export class EmployeeController extends Controller {
@Query() query: string = "", @Query() query: string = "",
@Query() page: number = 1, @Query() page: number = 1,
@Query() pageSize: number = 30, @Query() pageSize: number = 30,
@Query() activeOnly?: boolean,
) { ) {
return this.listByCriteria( return this.listByCriteria(
req, req,
@ -220,6 +221,7 @@ export class EmployeeController extends Controller {
query, query,
page, page,
pageSize, pageSize,
activeOnly,
); );
} }
@ -237,6 +239,7 @@ export class EmployeeController extends Controller {
@Query() query: string = "", @Query() query: string = "",
@Query() page: number = 1, @Query() page: number = 1,
@Query() pageSize: number = 30, @Query() pageSize: number = 30,
@Query() activeOnly?: boolean,
@Body() @Body()
body?: { body?: {
passport?: string[]; passport?: string[];
@ -268,15 +271,17 @@ export class EmployeeController extends Controller {
] ]
: undefined, : undefined,
AND: { AND: {
...filterStatus(status), ...filterStatus(activeOnly ? Status.ACTIVE : status),
customerBranch: { customerBranch: {
...filterStatus(activeOnly ? Status.ACTIVE : status),
id: customerBranchId, id: customerBranchId,
customerId, customerId,
customer: isSystem(req.user) customer: isSystem(req.user)
? undefined ? filterStatus(activeOnly ? Status.ACTIVE : status)
: { : {
...filterStatus(activeOnly ? Status.ACTIVE : status),
registeredBranch: { registeredBranch: {
OR: permissionCond(req.user), OR: permissionCond(req.user, { activeOnly: activeOnly }),
}, },
}, },
}, },