diff --git a/src/controllers/03-customer-controller.ts b/src/controllers/03-customer-controller.ts index 2a1aab2..bef51e3 100644 --- a/src/controllers/03-customer-controller.ts +++ b/src/controllers/03-customer-controller.ts @@ -20,6 +20,7 @@ import HttpStatus from "../interfaces/http-status"; import HttpError from "../interfaces/http-error"; import { isSystem } from "../utils/keycloak"; import { + branchActiveOnlyCond, branchRelationPermInclude, createPermCheck, createPermCondition, @@ -163,6 +164,7 @@ export class CustomerController extends Controller { @Query() pageSize: number = 30, @Query() includeBranch: boolean = false, @Query() company: boolean = false, + @Query() activeBranchOnly?: boolean, ) { const where = { OR: queryOrNot(query, [ @@ -179,9 +181,11 @@ export class CustomerController extends Controller { customerType, ...filterStatus(status), registeredBranch: isSystem(req.user) - ? undefined + ? branchActiveOnlyCond(activeBranchOnly) : { - OR: company ? permissionCondCompany(req.user) : permissionCond(req.user), + OR: company + ? permissionCondCompany(req.user, { activeOnly: activeBranchOnly }) + : permissionCond(req.user, { activeOnly: activeBranchOnly }), }, }, } satisfies Prisma.CustomerWhereInput;