feat: accept param active branch only

This commit is contained in:
Methapon2001 2024-12-06 18:11:33 +07:00
parent cb9c9cef68
commit 9630d02924
2 changed files with 19 additions and 2 deletions

View file

@ -18,6 +18,17 @@ export function branchRelationPermInclude(user: RequestWithUser["user"]) {
};
}
export function branchActiveOnlyCond(activeOnly?: boolean) {
return activeOnly
? {
OR: [
{ headOffice: { status: { not: Status.INACTIVE } } },
{ headOffice: null, status: { not: Status.INACTIVE } },
],
}
: undefined;
}
export function createPermCondition(
globalAllow: (user: RequestWithUser["user"]) => boolean,
): (