This commit is contained in:
Jared Palmer 2023-05-19 12:33:56 -04:00
commit a04776256d
56 changed files with 6808 additions and 0 deletions

25
app/actions.ts Normal file
View file

@ -0,0 +1,25 @@
"use server";
import { getServerSession } from "next-auth";
import { prisma } from "@/lib/prisma";
import { revalidatePath } from "next/cache";
import { authOptions } from "@/app/api/auth/[...nextauth]/route";
export async function removeChat({ id, path }: { id: string; path: string }) {
const session = await getServerSession(authOptions);
const userId = session?.user?.email;
if (!userId || !id) {
throw new Error("Unauthorized");
}
await prisma.chat.delete({
where: {
id,
// TODO: Add scoping
// userId,
},
});
revalidatePath("/");
revalidatePath("/chat/[id]");
}