"use server"; import { revalidatePath } from "next/cache"; import { prisma } from "@/lib/db"; import { requireUserId } from "@/lib/auth-helpers"; import { boardPath, categoryAccessFilter } from "@/lib/access"; import { GroupNoteContentSchema } from "@/lib/validation/group"; export async function updateGroupNote(groupId: string, noteContent: string): Promise { const userId = await requireUserId(); const parsed = GroupNoteContentSchema.parse(noteContent); const group = await prisma.group.findFirst({ where: { id: groupId, category: categoryAccessFilter(userId) }, select: { category: { select: { projectId: true } } }, }); if (!group) throw new Error("Group not found"); await prisma.group.update({ where: { id: groupId }, data: { noteContent: parsed } }); revalidatePath(boardPath(group.category.projectId)); }