24 lines
849 B
TypeScript
24 lines
849 B
TypeScript
"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<void> {
|
|
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));
|
|
}
|