Skip to content

Conversation

@codeunia-dev
Copy link
Owner

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

This PR delivers two major enhancements to the company events module:

  1. Event Statistics Integration (views + registrations)
  2. Full Event Registrations Management System (API + UI + CSV Export)

Both features are now integrated seamlessly into the company dashboard.


📊 1. Event Statistics: Views & Registrations

New Capabilities

  • Added backend logic to fetch total views, total clicks, and total registrations per event.
  • Stats are now displayed in the company dashboard.
  • These values are real data pulled from the analytics tables.

UI Enhancements

  • Events list now shows accurate counts.
  • Registration count becomes clickable when greater than 0.

📝 2. Event Registrations Management System

New API Endpoints

GET /api/events/[slug]/registrations

  • Fetch all registrations for an event
  • Search by name/email/phone
  • Filters for status & payment status
  • Pagination
  • Enriched user profile data
  • Company-level authorization

PATCH /api/events/[slug]/registrations

  • Update registration status (attended, no_show, cancelled, etc.)
  • Update payment status
  • Role checks for owner/admin/editor

GET /api/events/[slug]/registrations/export

  • Export all event registrations to CSV
  • Includes full participant details
  • Auto-generated filename

🎨 Frontend: Registrations Management UI

Added page

/dashboard/company/[slug]/events/[eventSlug]/registrations

Features

  • Stats card for total registrations

  • Search input

  • Status + Payment filters

  • Responsive table with detailed participant info:

    • Name, email, phone
    • Institution, department, year
    • Status + payment badges
    • Registered date
  • Actions dropdown to update status

  • Export CSV button

  • Loading and empty states

  • Back navigation

Events list update

  • registered column is now a clickable link when count > 0
  • Better UX, hover effects, and visual cues

🗄️ Database Integration

Uses existing master_registrations table:

  • Activity-based filtering (activity_type = 'event')
  • Matches registrations via activity_id
  • No DB schema changes required

🔐 Authorization

  • Ensures user belongs to the event’s company
  • Update operations restricted to owner/admin/editor
  • View & export allowed for all company members

📁 Files Added

  • app/api/events/[slug]/registrations/route.ts
  • app/api/events/[slug]/registrations/export/route.ts
  • app/dashboard/company/[slug]/events/[eventSlug]/registrations/page.tsx

Files Modified

  • app/dashboard/company/[slug]/events/page.tsx
  • Analytics-related modules that compute views+registrations

🚀 Next Improvements (Optional)

  • Bulk update actions
  • Email triggers for status updates
  • Registration analytics charts
  • Participant certificate generation

Summary

This PR significantly improves the company event experience by:

  • Adding accurate views and registrations statistics
  • Providing a complete registration management workflow
  • Strengthening UI/UX with new pages and interactions
  • Implementing CSV export, filtering, search, and role-based updates

Authored by: @akshay0611

Summary by CodeRabbit

  • New Features
    • Export event registrations to CSV for easy reporting and management.
    • Dedicated registrations management page with search, filtering by status and payment, and inline status updates.
    • Event dashboard now displays total views and registration statistics.
    • Events table links directly to registrations when available.

…nt dashboard and refine the stats card layout.
…fetching, filtering, searching, updating, and exporting registrations, alongside a new dashboard page.
@vercel
Copy link

vercel bot commented Nov 19, 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 19, 2025 5:38am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 19, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This pull request introduces comprehensive event registration management functionality. It adds a CSV export endpoint for registrations, creates a new API route for retrieving and updating event registrations with filtering and search capabilities, and builds a new dashboard page for viewing and managing registrations with inline status updates and CSV export functionality. The events dashboard is also updated to display registration counts and total views.

Changes

Cohort / File(s) Summary
Registration API Endpoints
app/api/events/[slug]/registrations/export/route.ts, app/api/events/[slug]/registrations/route.ts
New GET endpoint for exporting event registrations as CSV with proper authentication and authorization checks. New API route with GET (retrieves registrations with search, status, and payment filters) and PATCH (updates registration status/payment status) methods, including company-level authorization verification and enriched profile data.
Registration Management Dashboard
app/dashboard/company/[slug]/events/[eventSlug]/registrations/page.tsx
New client-side page for displaying, searching, and managing event registrations. Includes CSV export functionality, inline status/payment updates, filtering by search term and status/payment state, and responsive table layout with loading/empty states.
Events Dashboard Updates
app/dashboard/company/[slug]/events/page.tsx
Added aggregated stats (totalViews, totalRegistrations) displayed in new stat cards. Registrations table column now links to registrations page when count > 0. Minor UI refinements including pointer-events-none styling on badges and stats grid layout adjustments.

Sequence Diagrams

sequenceDiagram
    participant User
    participant Dashboard as Registrations Page
    participant API as API Routes
    participant DB as Supabase
    
    User->>Dashboard: Load registrations page
    Dashboard->>API: GET /events/[slug]/registrations?search=...&status=...
    API->>DB: Authenticate & verify authorization
    alt Unauthorized
        API-->>Dashboard: 401/403
    else Authorized
        API->>DB: Query master_registrations filtered
        DB-->>API: Registrations + user profiles
        API->>DB: Enrich with profile data
        API-->>Dashboard: Registrations array + metadata
        Dashboard-->>User: Display table with registrations
    end
    
    User->>Dashboard: Update registration status
    Dashboard->>API: PATCH /events/[slug]/registrations
    API->>DB: Verify user authorization
    API->>DB: Update master_registrations record
    DB-->>API: Updated registration
    API-->>Dashboard: Success response
    Dashboard->>Dashboard: Refresh registrations list
    
    User->>Dashboard: Export registrations
    Dashboard->>API: GET /events/[slug]/registrations/export
    API->>DB: Verify auth & fetch registrations
    API->>API: Build CSV from registrations
    API-->>Dashboard: CSV file (blob)
    Dashboard->>User: Download CSV file
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Authentication & Authorization Logic: Both new API endpoints implement multi-layer security checks (user authentication, company membership verification, role-based authorization for PATCH). Review the authorization logic in route.ts files to ensure company-level access control is correctly enforced.
  • Data Enrichment: The GET endpoint enriches registrations with user profile data (profile_name, profile_avatar, email). Verify the join logic and fallback behavior when profile data is unavailable.
  • CSV Export Implementation: Review CSV generation in the export endpoint for proper escaping of string fields and correct header mapping.
  • State Management & Side Effects: The registrations page manages multiple pieces of state (filters, loading, export status). Verify useEffect dependencies and state update sequences to avoid stale data or infinite loops.

Possibly related PRs

Poem

🐰 A dash of exports, a sprinkle of filters,
Registrations now dance in the dashboard with glitters,
CSV streams flow like carrots in spring,
And status updates bring joy to everything! 🥕✨

✨ 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/event

📜 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 328957b and 4e738c8.

📒 Files selected for processing (4)
  • app/api/events/[slug]/registrations/export/route.ts (1 hunks)
  • app/api/events/[slug]/registrations/route.ts (1 hunks)
  • app/dashboard/company/[slug]/events/[eventSlug]/registrations/page.tsx (1 hunks)
  • app/dashboard/company/[slug]/events/page.tsx (8 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 a9cb289 into main Nov 19, 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