Skip to content

[Phase 2.4] Implement upvoting system #12

@Andreas-Froyland

Description

@Andreas-Froyland

Goal

Let users upvote feedback items. One vote per user/session. Toggle on/off.

Depends on: #13 (detail view) - upvoting shows on both listing cards and detail page

Backend

  • POST /api/feedback/[id]/vote — toggle vote
    • If not voted: insert vote, return { voted: true, count: N }
    • If already voted: remove vote, return { voted: false, count: N }
  • Auth: authenticated user OR anonymous session required
  • Unique constraint: one vote per (feedback_id, user_id OR session_id)
  • Vote count is always computed (not cached) for consistency — optimize later if needed

Frontend

  • Vote button on feedback cards (listing) and detail view
  • Visual states: default (outline) vs voted (filled, accent color)
  • Optimistic UI update on click, revert on error
  • Show total vote count next to button
  • User's own voted items are visually distinct in the listing

Notes

  • Votes by anonymous sessions persist across visits (tied to session cookie)
  • If anonymous user signs in, their votes carry over to their GitHub account

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions