cleaner code

This commit is contained in:
daniel31x13
2024-06-28 09:14:09 -04:00
parent 39422e54df
commit 8a901ba0e9
8 changed files with 118 additions and 121 deletions
+2 -5
View File
@@ -3,14 +3,12 @@ import { prisma } from "@/lib/api/db";
type Props = {
userId: number;
collectionId?: number;
collectionName?: string;
linkId?: number;
};
export default async function getPermission({
userId,
collectionId,
collectionName,
linkId,
}: Props) {
if (linkId) {
@@ -26,11 +24,10 @@ export default async function getPermission({
});
return check;
} else if (collectionId || collectionName) {
} else if (collectionId) {
const check = await prisma.collection.findFirst({
where: {
id: collectionId || undefined,
name: collectionName || undefined,
id: collectionId,
OR: [{ ownerId: userId }, { members: { some: { userId } } }],
},
include: { members: true },