21 lines
970 B
TypeScript
21 lines
970 B
TypeScript
import { NextResponse } from "next/server";
|
|
import { prisma } from "@/lib/db";
|
|
import { currentUser } from "@/lib/auth/current-user";
|
|
|
|
export async function PATCH(req: Request, context: { params: Promise<{ id: string }> }) {
|
|
const params = await context.params;
|
|
const user = await currentUser();
|
|
if (!user) return NextResponse.json({ error: "UNAUTHORIZED" }, { status: 401 });
|
|
const body = await req.json();
|
|
await prisma.savedFolder.updateMany({ where: { id: params.id, userId: user.id }, data: { name: body.name, color: body.color } });
|
|
return NextResponse.json({ ok: true });
|
|
}
|
|
|
|
export async function DELETE(_: Request, context: { params: Promise<{ id: string }> }) {
|
|
const params = await context.params;
|
|
const user = await currentUser();
|
|
if (!user) return NextResponse.json({ error: "UNAUTHORIZED" }, { status: 401 });
|
|
await prisma.savedFolder.deleteMany({ where: { id: params.id, userId: user.id } });
|
|
return NextResponse.json({ ok: true });
|
|
}
|