Skip to content

Conversation

@codeunia-dev
Copy link
Owner

@codeunia-dev codeunia-dev commented Nov 7, 2025

  • Implement comprehensive reply system for support tickets
  • Add new API endpoint for sending ticket replies
  • Enable automatic status update from "open" to "in_progress" when replying
  • Create UI components for sending replies with character limit and validation
  • Add error handling and toast notifications for reply process
  • Include tip message about status change when sending first reply
  • Enhance ticket management workflow with direct communication feature

Summary by CodeRabbit

  • New Features

    • Added ability for admins to reply directly to support tickets with character limit enforcement and real-time feedback.
    • Automatic status updates when replying to open tickets.
  • Improvements

    • Enhanced authorization and status validation for ticket management.
    • Clarified that internal notes are admin-visible only.
    • Improved error handling and user notifications throughout ticket workflows.

… page

- Implement comprehensive reply system for support tickets
- Add new API endpoint for sending ticket replies
- Enable automatic status update from "open" to "in_progress" when replying
- Create UI components for sending replies with character limit and validation
- Add error handling and toast notifications for reply process
- Include tip message about status change when sending first reply
- Enhance ticket management workflow with direct communication feature
@vercel
Copy link

vercel bot commented Nov 7, 2025

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

Project Deployment Preview Comments Updated (UTC)
codeunia Building Building Preview Comment Nov 7, 2025 7:00am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 7, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request adds a "Reply to User" feature for support ticket management. A new POST API endpoint accepts admin replies, validates input, sends templated emails to users, and handles ticket status transitions. The client UI includes a reply form with character limits. Existing GET and PATCH endpoints are refactored to enforce admin authentication consistently and return normalized ticket data structures.

Changes

Cohort / File(s) Change Summary
Frontend UI Component
app/admin/support/[id]/page.tsx
Adds reply state management, sends reply function, and "Reply to User" UI card with textarea (2000-char limit), character counter, send/clear actions, and status-change tip. Updates import signatures to include Send from lucide-react. Clarifies Internal Notes description (admin-only visibility).
Backend: New Reply Endpoint
app/api/admin/support/tickets/[id]/reply/route.ts
New POST route handler that authenticates admin, validates reply message (non-empty, max 2000 chars), fetches ticket and user profile, composes templated email, and sends reply. Includes helper functions for email template generation. Logs key steps; includes TODO for database persistence.
Backend: Updated Ticket Endpoint
app/api/admin/support/tickets/[id]/route.ts
GET and PATCH flows now include explicit admin authorization checks. GET returns normalized { ticket: ticketWithUser } payload. PATCH enforces stricter status validation (must be one of ['open', 'in_progress', 'resolved', 'closed']), adds explicit updated_at timestamp, and updates return shape to { ticket, success: true }. Removes legacy email notification and oldStatus tracking logic.

Sequence Diagram

sequenceDiagram
    participant Admin as Admin (Browser)
    participant Client as Page Component
    participant API as POST /reply
    participant DB as Database
    participant Email as Email Service

    Admin->>Client: Fill reply form & click Send
    Client->>Client: Validate message (non-empty, ≤2000 chars)
    Client->>API: POST { message }
    
    rect rgb(220, 240, 255)
    Note over API: Authorization & Validation
    API->>API: Verify admin auth
    API->>API: Validate message
    end
    
    rect rgb(220, 240, 255)
    Note over API: Fetch & Compose
    API->>DB: Get ticket & user profile
    API->>API: Build email template
    end
    
    rect rgb(220, 240, 255)
    Note over API: Send & Update
    API->>Email: Send templated reply to user
    API->>DB: Update ticket status (open → in_progress)
    end
    
    API-->>Client: Success response
    Client->>Client: Clear reply, show toast
    Client->>DB: Refresh ticket data
    Client->>Admin: Show updated ticket with status change
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • New POST endpoint logic: Carefully review email template generation, admin authentication flow, and status transition conditions (open → in_progress). Verify validation (2000-char limit) is enforced consistently.
  • Frontend reply workflow: Verify state management (reply, sending states), character counter accuracy, form disabling during submission, and error handling/toast messaging.
  • Existing route refactoring: Confirm admin auth checks are comprehensive in both GET and PATCH. Verify status validation enum is correct and updated_at timestamp is always set. Ensure return shapes align with frontend expectations.
  • Database persistence TODO: Note that replies are sent but not yet persisted; clarify whether this is intentional or requires follow-up work.

Poem

🐰 An admin's voice, now swift and clear,
Replies compose, templates near,
With Lucide's Send and character count,
Tickets progress—all resolved in spades amount,
One hop, one click, users cheer! 🎉

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feat/adminsupport

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4a5846f and a8f6d7b.

📒 Files selected for processing (3)
  • app/admin/support/[id]/page.tsx (5 hunks)
  • app/api/admin/support/tickets/[id]/reply/route.ts (1 hunks)
  • app/api/admin/support/tickets/[id]/route.ts (5 hunks)

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codeunia-dev codeunia-dev merged commit 4fdda6e into main Nov 7, 2025
2 of 4 checks passed
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.

3 participants