feat: add role that can view another branch

This commit is contained in:
Methapon Metanipat 2024-09-25 14:26:56 +07:00
parent ea72b1a1bb
commit 10aca80abe

View file

@ -38,6 +38,12 @@ function globalAllow(user: RequestWithUser["user"]) {
return MANAGE_ROLES.some((v) => user.roles?.includes(v));
}
function globalAllowView(user: RequestWithUser["user"]) {
return MANAGE_ROLES.concat("head_of_account", "head_of_sale").some((v) =>
user.roles?.includes(v),
);
}
type BranchCreate = {
status?: Status;
code: string;
@ -126,7 +132,7 @@ type BranchUpdate = {
}[];
};
const permissionCond = createPermCondition(globalAllow);
const permissionCond = createPermCondition(globalAllowView);
const permissionCheck = createPermCheck(globalAllow);
@Route("api/v1/branch")