fix: system user query shared product get mixed company
This commit is contained in:
parent
6b4e13e94d
commit
58389ed47f
2 changed files with 29 additions and 22 deletions
|
|
@ -33,11 +33,23 @@ export function createPermCondition(
|
|||
globalAllow: (user: RequestWithUser["user"]) => boolean,
|
||||
): (
|
||||
user: RequestWithUser["user"],
|
||||
opts?: { alwaysIncludeHead?: boolean; activeOnly?: boolean },
|
||||
opts?: { alwaysIncludeHead?: boolean; activeOnly?: boolean; targetBranchId?: string },
|
||||
) => Prisma.BranchWhereInput["OR"] {
|
||||
return (user, opts) =>
|
||||
isSystem(user)
|
||||
? undefined
|
||||
? opts?.targetBranchId
|
||||
? [
|
||||
{
|
||||
id: opts.targetBranchId,
|
||||
},
|
||||
{
|
||||
headOffice: { id: opts.targetBranchId },
|
||||
},
|
||||
{
|
||||
branch: { some: { id: opts.targetBranchId } },
|
||||
},
|
||||
]
|
||||
: undefined
|
||||
: [
|
||||
{
|
||||
AND: opts?.activeOnly ? { status: { not: Status.INACTIVE } } : undefined,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue