Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
Guru Updesh Singh <guruupdeshsingh@gmail.com>
Guru Updesh Singh <guruupdeshsingh@gmail.com>
Guru Updesh Singh <guruupdeshsingh@gmail.com>
Guru Updesh Singh <guruupdeshsingh@gmail.com>
10 changes: 6 additions & 4 deletions src/actions/delete-actions.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
"use server";

import { db } from "~/server/db";
import { projects } from "~/server/db/schema";
import { revalidatePath } from "next/cache";
import { projects, usersToProjects } from "~/server/db/schema";
import { eq } from "drizzle-orm";
import { redirect } from "next/navigation";

export async function handleDeleteProject(formData: FormData) {
const projectId = formData.get("projectId");
Expand All @@ -24,6 +24,8 @@ export async function handleDeleteProject(formData: FormData) {
return { success: false, message: "Project not found" };
}
await db.delete(projects).where(eq(projects.id, projectData.id));
revalidatePath("/");
return { success: true, message: "Project deleted" };
await db
.delete(usersToProjects)
.where(eq(usersToProjects.projectId, projectData.id));
redirect("/");
}