This commit is contained in:
Stefan Lazic committed 2026-08-03 21:15:24 +01:00
1 parent ec5583f972
commit 546613e677
189 files changed
+9873 -655

No files matched your search

+20
View File
@@ -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);
}