Phase 7
This commit is contained in:
189 files changed
+9873
-655
No files matched your search
@@ -0,0 +1,20 @@
|
||||
import type { PrismaClient } from "@/generated/prisma/client";
|
||||
import { Permission } from "@/generated/prisma/enums";
|
||||
|
||||
/**
|
||||
* There's no `Business.ownerUserId` column — "owner" is whoever holds a
|
||||
* role with VIEW_REPORTING (the permission that gates the owner
|
||||
* dashboard, see schema.prisma), which can be more than one active staff
|
||||
* member. Every OWNER_* notification goes to all of them, not just one.
|
||||
*/
|
||||
export async function getOwnerUserIds(prisma: PrismaClient, businessId: string): Promise<string[]> {
|
||||
const staff = await prisma.staffProfile.findMany({
|
||||
where: {
|
||||
businessId,
|
||||
status: "ACTIVE",
|
||||
role: { permissions: { some: { permission: Permission.VIEW_REPORTING } } },
|
||||
},
|
||||
select: { userId: true },
|
||||
});
|
||||
return staff.map((s) => s.userId);
|
||||
}
|
||||
Reference in new issue
Block a user