Skip to content

Conversation

@codeunia-dev
Copy link
Owner

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

  • Add 'delete' action support to hackathon moderation endpoint alongside approve/reject
  • Implement permanent deletion of hackathons with cache invalidation
  • Update moderation queue to display both pending and deleted hackathons
  • Extend event moderation to include deleted events in retrieval
  • Add deletion capability to HackathonModerationQueue component UI
  • Update moderation service to filter by pending and deleted approval statuses
  • Refactor indentation and code formatting in moderation route handlers
  • Update type definitions to support delete action in moderation workflows
  • Enable admins to permanently remove flagged or problematic content from the platform

Authored by: @akshay0611

Summary by CodeRabbit

  • New Features

    • Introduced soft delete for approved events and hackathons, requiring admin approval before permanent deletion
    • Hard delete remains available for draft and pending items
    • New "Deleted" status badge displays in dashboards for items pending approval
    • Admin moderation queue now manages deleted items with dedicated delete action
  • Chores

    • Improved cache invalidation following deletion operations

✏️ Tip: You can customize this high-level summary in your review settings.

…n panel

- Add 'delete' action support to hackathon moderation endpoint alongside approve/reject
- Implement permanent deletion of hackathons with cache invalidation
- Update moderation queue to display both pending and deleted hackathons
- Extend event moderation to include deleted events in retrieval
- Add deletion capability to HackathonModerationQueue component UI
- Update moderation service to filter by pending and deleted approval statuses
- Refactor indentation and code formatting in moderation route handlers
- Update type definitions to support delete action in moderation workflows
- Enable admins to permanently remove flagged or problematic content from the platform
@vercel
Copy link

vercel bot commented Nov 20, 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 20, 2025 4:22am

@codeunia-dev codeunia-dev merged commit 495ae02 into main Nov 20, 2025
2 of 4 checks passed
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 20, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR adds soft-delete functionality for events and hackathons with admin approval workflows. It introduces a 'deleted' approval status, updates dashboards to exclude deleted items from statistics, adds delete action to the moderation queue, modifies delete APIs to support both hard and soft deletes with admin notifications, and updates related types and services accordingly.

Changes

Cohort / File(s) Summary
Type Definitions
types/events.ts, types/hackathons.ts
Extended approval_status union to include 'draft' and 'deleted' statuses for both Event and Hackathon types.
Event API & Service
app/api/events/[slug]/route.ts, lib/services/events.ts
Modified DELETE handler to capture soft-delete result and return detailed response with soft_delete flag and contextual message. Service now performs soft-delete for approved events (mark as deleted, notify admins) and hard-delete for draft/pending items; return type changed to Promise<{ soft_delete: boolean }>.
Hackathon API & Service
app/api/hackathons/[id]/route.ts
Replaced hard-delete path for approved hackathons with soft-delete workflow (mark approval_status as 'deleted', send admin notifications). Maintains hard-delete for draft/pending items; returns soft_delete flag in response.
Admin Moderation Routes
app/api/admin/moderation/hackathons/route.ts, app/api/admin/moderation/hackathons/[id]/route.ts, app/api/admin/moderation/events/route.ts
Updated hackathons list filter to include both pending and deleted items. Added delete action support to hackathon moderation endpoint; broadened events pending filter to include deleted items.
Moderation Service
lib/services/moderation-service.ts
Updated getPendingEvents to include items with approval_status 'deleted' alongside 'pending'.
Moderation UI Component
components/moderation/HackathonModerationQueue.tsx
Added delete action type to ModerationAction; updated UI to conditionally render delete button for deleted items and approve/reject buttons for others. Enhanced dialogs and toast messaging to handle delete workflow; added Trash2 icon import.
Dashboard Pages
app/dashboard/company/[slug]/events/page.tsx, app/dashboard/company/[slug]/hackathons/page.tsx
Introduced filtering to exclude deleted items when computing summary statistics. Added deleted approval status badge rendering (gray with Trash icon). Updated stats computations to use filtered active items only.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant EventAPI as Event API<br/>(DELETE /[slug])
    participant EventService as Events Service
    participant DB as Database
    participant AdminService as Admin Notifier
    participant Cache as Cache

    User->>EventAPI: DELETE request
    EventAPI->>EventService: deleteEvent(id, userId)
    
    alt Event is Approved
        EventService->>DB: UPDATE approval_status to 'deleted'
        DB-->>EventService: Success
        EventService->>AdminService: Notify admins of soft-delete
        EventService->>Cache: Invalidate cache
        EventService-->>EventAPI: { soft_delete: true }
        EventAPI-->>User: 200 + "Event marked for deletion.<br/>Admin approval required."
    else Event is Draft/Pending
        EventService->>DB: DELETE event record
        DB-->>EventService: Success
        EventService->>Cache: Invalidate cache
        EventService-->>EventAPI: { soft_delete: false }
        EventAPI-->>User: 200 + "Event deleted successfully"
    end
Loading
sequenceDiagram
    participant Admin
    participant ModerationUI as Moderation UI
    participant ModerationAPI as Moderation API<br/>(/admin/moderation)
    participant HackathonAPI as Hackathon API
    participant DB as Database

    Admin->>ModerationUI: View pending hackathons
    ModerationUI->>ModerationAPI: GET /admin/moderation/hackathons
    ModerationAPI->>DB: Query status IN ('pending', 'deleted')
    DB-->>ModerationAPI: Hackathons list
    ModerationAPI-->>ModerationUI: Results
    ModerationUI-->>Admin: Render with conditional actions

    alt Hackathon status = 'deleted'
        Admin->>ModerationUI: Click delete button
        ModerationUI->>ModerationAPI: POST /admin/moderation/hackathons/[id]<br/>{ action: 'delete' }
        ModerationAPI->>HackathonAPI: Trigger permanent delete
        HackathonAPI->>DB: DELETE hackathon
        DB-->>HackathonAPI: Success
        HackathonAPI-->>ModerationAPI: Confirmed
        ModerationAPI-->>ModerationUI: Success response
        ModerationUI-->>Admin: Toast "Hackathon<br/>permanently deleted"
    else Hackathon status = 'pending'
        Admin->>ModerationUI: Click approve/reject
        ModerationUI->>ModerationAPI: POST action
        ModerationAPI-->>ModerationUI: Updated status
        ModerationUI-->>Admin: Updated UI
    end
Loading

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

  • Service layer changes: Return type modification to deleteEvent and new soft-delete logic with admin notifications require careful review to ensure state consistency.
  • Type system updates: Approval status extensions across multiple interfaces need verification for all consuming code paths and new status handling branches.
  • API route modifications: Multiple delete endpoint changes with branching logic for soft vs. hard delete; conditional responses and cache invalidation require thorough tracing.
  • Dashboard filtering logic: New filtering patterns for excluded deleted items in statistics; verify all aggregations use correct subsets.
  • Moderation component state: New action type and conditional rendering; ensure delete confirmation dialog and toast messaging are wired correctly.
  • Related features across files: Changes span services, APIs, types, and UI; interconnected logic requires understanding full flow from API to UI to database.

Possibly related PRs

Poem

🐰 Soft deletes bloom in springtime's glow,
Admin approvals orchestrate the flow,
No more hard purges—just a gentle mark,
Deleted items leave a trackable spark! ✨

✨ 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 fix/rbac

📜 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 5016b0c and 109b91b.

📒 Files selected for processing (12)
  • app/api/admin/moderation/events/route.ts (1 hunks)
  • app/api/admin/moderation/hackathons/[id]/route.ts (1 hunks)
  • app/api/admin/moderation/hackathons/route.ts (1 hunks)
  • app/api/events/[slug]/route.ts (4 hunks)
  • app/api/hackathons/[id]/route.ts (1 hunks)
  • app/dashboard/company/[slug]/events/page.tsx (2 hunks)
  • app/dashboard/company/[slug]/hackathons/page.tsx (8 hunks)
  • components/moderation/HackathonModerationQueue.tsx (7 hunks)
  • lib/services/events.ts (2 hunks)
  • lib/services/moderation-service.ts (1 hunks)
  • types/events.ts (1 hunks)
  • types/hackathons.ts (1 hunks)

Tip

📝 Customizable high-level summaries are now available in beta!

You can now customize how CodeRabbit generates the high-level summary in your pull requests — including its content, structure, tone, and formatting.

  • Provide your own instructions using the high_level_summary_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. 📝 Description — Summarize the main change in 50–60 words, explaining what was done.
  2. 📓 References — List relevant issues, discussions, documentation, or related PRs.
  3. 📦 Dependencies & Requirements — Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. 📊 Contributor Summary — Include a Markdown table showing contributions:
    | Contributor | Lines Added | Lines Removed | Files Changed |
  5. ✔️ Additional Notes — Add any extra reviewer context.
    Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."

Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.


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.

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