Skip to content

Delete Flashcard is not working #106

Description

@Jils31

Delete Flashcard is Not Working

Describe the bug
When attempting to delete an individual flashcard from the saved flashcards view, the delete button does not perform any action. The flashcard remains in the list and is not removed from the database or the UI.

Root Cause Analysis
After reviewing the codebase, the delete API exists at src/app/api/decks/[id]/route.ts but only handles deck-level deletion. There is no API endpoint or UI handler for deleting individual flashcards within a deck. The FlashcardViewer.tsx component only has flip/navigation buttons — no delete action.

What Needs to Be Done

  1. Create a new API route: src/app/api/flashcards/[id]/route.ts with a DELETE handler
  2. Add a delete button/icon to src/components/flashcards/FlashcardViewer.tsx
  3. Implement confirmation dialog before deletion
  4. Add proper authorization check (only card owner can delete)
  5. Show success/error toast notification after deletion
  6. Update the UI optimistically to remove the card from the list

Tech Stack Reference

  • Database: Prisma ORM with PostgreSQL (Supabase)
  • Auth: Clerk v6 — use auth() to get userId
  • UI: shadcn/ui components, Tailwind CSS
  • Existing pattern: See src/app/api/decks/[id]/route.ts for delete API example

To Reproduce

  1. Sign in and generate flashcards
  2. Navigate to saved flashcards (/flashcards)
  3. Open a deck and try to delete an individual flashcard
  4. Observe: no delete option exists or the action fails

Expected behavior
Individual flashcards should be deletable with a confirmation dialog, and the UI should update immediately.

Acceptance Criteria

  • DELETE API endpoint for individual flashcards
  • Delete button in FlashcardViewer UI
  • Confirmation dialog before deletion
  • Toast notification on success/failure
  • Authorization check (only owner can delete)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions