Skip to content

feat(project): add project deletion functionality with confirmation dialog#209

Open
Sithumli wants to merge 3 commits into
IIT-SDGP:version-2-releasefrom
Sithumli:feat/project-delete-v2
Open

feat(project): add project deletion functionality with confirmation dialog#209
Sithumli wants to merge 3 commits into
IIT-SDGP:version-2-releasefrom
Sithumli:feat/project-delete-v2

Conversation

@Sithumli
Copy link
Copy Markdown

What changed


  • Added DELETE API endpoint at /api/admin/projects/[projectId]/delete
  • Added cascade deletion of all related records (details, status, associations, slides, team, social links)
  • Added Azure blob storage cleanup for project images (cover, logo, team profiles)
  • Added DeleteProjectDialog confirmation component with warning message
  • Added useDeleteProject hook for delete state management
  • Added trash icon button in RejectedProjectsTable (visible to ADMIN only)
  • Integrated delete flow in admin projects page with toast notifications

Why


  • Rejected projects currently remain in the database indefinitely
  • Administrators need a way to clean up rejected submissions and free storage
  • Related blob storage images were never cleaned up, causing unnecessary storage costs

Scope


  • Admin projects management page (/admin/projects)
  • Rejected projects tab and table component
  • New API endpoint for project deletion
  • Blob storage cleanup utility

Addressed Review Comments (from PR #204)


  • API uses session.user.role for authorization (version-2 pattern)
  • Only REJECTED projects can be deleted (status validation)
  • Server-only env vars for Azure SAS token
  • Blob name extraction handles virtual folders (slice(1).join('/'))
  • Promise.allSettled for reliable blob cleanup in serverless
  • Dialog prevents dismiss while delete is in progress
  • aria-label on delete button for accessibility
  • DialogDescription uses asChild with <div> for valid HTML
  • Try/catch in handleConfirmDelete for error handling

Testing performed


  • Verified delete button appears only for ADMIN users
  • Confirmed project and all related records removed from database
  • Verified blob storage cleanup triggers correctly
  • Tested dialog cannot be dismissed during deletion
  • Verified UI updates after successful deletion

Closes #54

Copilot AI review requested due to automatic review settings April 21, 2026 09:20
@vercel
Copy link
Copy Markdown
Contributor

vercel Bot commented Apr 21, 2026

@Sithumli is attempting to deploy a commit to the Agzaiyenths's Projects Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds an admin-only “delete rejected project” flow across the admin UI and backend API, including database cleanup and Azure Blob Storage image deletion, to allow permanent removal of rejected submissions.

Changes:

  • Introduces DELETE /api/admin/projects/[projectId]/delete to delete a rejected project and related records, plus blob cleanup.
  • Adds a reusable DeleteProjectDialog confirmation modal and a useDeleteProject hook to manage delete state.
  • Wires the delete action into the rejected-projects table (trash button) and the admin projects page with toast feedback.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
hooks/project/useDeleteProject.ts New hook to call the admin delete endpoint and expose loading/error state.
components/tables/RejectedProjectsTable.tsx Adds optional delete action button (admin-only via props) with tooltip + aria-label.
components/dialogs/DeleteProjectDialog.tsx New confirmation dialog that blocks dismissal while deletion is in progress.
app/api/admin/projects/[projectId]/delete/route.ts New DELETE route: validates admin + rejected status, deletes related DB rows, and cleans up Azure blobs.
app/(admin)/admin/projects/page.tsx Integrates delete dialog + hook into the rejected tab with toast notifications and refresh.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread app/api/admin/projects/[projectId]/delete/route.ts Outdated
Comment thread app/api/admin/projects/[projectId]/delete/route.ts
Comment thread app/api/admin/projects/[projectId]/delete/route.ts
Copy link
Copy Markdown
Member

@agzaiyenth agzaiyenth left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also add audit logging?

Comment thread app/api/admin/projects/[projectId]/delete/route.ts Outdated
Comment thread app/api/admin/projects/[projectId]/delete/route.ts Outdated
Comment thread app/(admin)/admin/projects/page.tsx Outdated
@agzaiyenth
Copy link
Copy Markdown
Member

can we also add audit logging?
Not as logs, rather as a audit itself.

@Sithumli Sithumli requested a review from agzaiyenth April 23, 2026 21:45
@zionashirwada
Copy link
Copy Markdown
Collaborator

@agzaiyenth isn't this ready to merge ?

@agzaiyenth
Copy link
Copy Markdown
Member

agzaiyenth commented Apr 29, 2026

@agzaiyenth isn't this ready to merge ?

nah zion, not 100% comfortable merging this yet tbh
main concerns:
what if a moderator accidentally deletes a project
what if we delete a project and later there’s a ticket raised on it (like submission issue, rejection, etc.)

thinking better approach is:
only allow delete for REJECTED projects
and only if rejected date > 2 weeks

also with the new portal coming, students can edit their own projects anyway, so this whole delete/edit pressure should reduce a lot 👍

@zionashirwada wdyt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants