Fixes for build ready
This commit is contained in:
@ -2,16 +2,21 @@
|
||||
|
||||
import { prisma } from "@/lib/prisma";
|
||||
|
||||
export async function isDescendant(tagId: string, possibleAncestorId: string) {
|
||||
export async function isDescendant(tagId: string, possibleAncestorId: string): Promise<boolean> {
|
||||
// Walk upwards from possibleAncestorId; if we hit tagId, it's a cycle.
|
||||
let current: string | null = possibleAncestorId;
|
||||
|
||||
while (current) {
|
||||
if (current === tagId) return true;
|
||||
const t = await prisma.artTag.findUnique({
|
||||
where: { id: current },
|
||||
select: { parentId: true },
|
||||
});
|
||||
|
||||
const t: { parentId: string | null } | null =
|
||||
await prisma.artTag.findUnique({
|
||||
where: { id: current },
|
||||
select: { parentId: true },
|
||||
});
|
||||
|
||||
current = t?.parentId ?? null;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user