Skip to content

Add task deletion with confirmation modal#7

Merged
shobhit2603 merged 3 commits into
mainfrom
copilot/add-delete-task-feature
May 22, 2026
Merged

Add task deletion with confirmation modal#7
shobhit2603 merged 3 commits into
mainfrom
copilot/add-delete-task-feature

Conversation

Copilot AI commented May 22, 2026

Copy link
Copy Markdown
Contributor

Implements task deletion functionality allowing users to remove tasks from the database. Includes a custom confirmation modal with proper error handling and ownership verification.

Changes

Backend

  • Added deleteTaskById in task DAO using findOneAndDelete with user ownership check
  • Added deleteTask controller handling DELETE requests with 404/500 error responses
  • Registered DELETE route at /:taskId in task router

Frontend

  • Delete button appears on task hover with trash icon
  • Custom confirmation modal replaces native confirm() for consistent styling
  • performDeleteTask makes API call and updates local state on success
  • Error messages displayed on failed deletion via existing toast pattern

Error Handling

  • Try-catch wrapping API call with user feedback on network/server failures
  • Ownership verification on backend prevents unauthorized deletion
  • Validates both HTTP status and response success field

Example Usage

// Frontend: User clicks delete button, sees confirmation modal
<button onClick={(e) => deleteTask(task._id, e)}>
  <Trash size={20} weight="bold" />
</button>

// Backend: Secure deletion with authorization
const task = await Task.findOneAndDelete({ _id: taskId, userId });

@vercel

vercel Bot commented May 22, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
momentum Ready Ready Preview, Comment May 22, 2026 6:37pm

…on modal

Agent-Logs-Url: https://github.com/shobhit2603/Momentum/sessions/85ed2e0f-097d-414a-98c6-0f9a3e265067

Co-authored-by: shobhit2603 <149822769+shobhit2603@users.noreply.github.com>
Copilot AI changed the title [WIP] Add delete task feature for user tasks Add task deletion with confirmation modal May 22, 2026
Copilot AI requested a review from shobhit2603 May 22, 2026 18:37

@shobhit2603 shobhit2603 left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I think every thing looks fine we can go with it

@shobhit2603 shobhit2603 marked this pull request as ready for review May 22, 2026 20:23
Copilot AI review requested due to automatic review settings May 22, 2026 20:23
@shobhit2603 shobhit2603 merged commit 46e5bf7 into main May 22, 2026
2 of 3 checks passed
@shobhit2603 shobhit2603 deleted the copilot/add-delete-task-feature branch May 22, 2026 20:24
Copilot AI removed the request for review from Copilot May 22, 2026 20:46
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.

issue: Delete task feature

2 participants