Skip to content

Conversation

@codeunia-dev
Copy link
Owner

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

Implement approved event count for companies and update event status badges to reflect approval status.

Authored by: @akshay0611

Summary by CodeRabbit

  • New Features
    • Added approval status badges for events: Pending Review, Rejected, and Changes Requested.
    • Event counts now display approved events when available, with fallback to total events.
    • Enhanced event status visibility on the dashboard.

@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 4:21am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 19, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adding an approved_events_count field to the Company type, fetching this count via database queries, and surfacing it throughout the UI with fallback logic to display approved event counts instead of total events in company listings and cards.

Changes

Cohort / File(s) Summary
Type Definition
types/company.ts
Added optional approved_events_count?: number field to the Company interface.
Data Layer
app/api/companies/[slug]/route.ts
Queries database to fetch count of approved events for the company and augments the company object with approved_events_count before caching and returning.
Service Layer
lib/services/company-service.ts
Enriches each company in listCompanies with approved_events_count via per-company database queries for events with approval_status = 'approved'.
UI Components
components/companies/CompanyCard.tsx, components/companies/CompanyProfile.tsx
Updated to display approved_events_count with fallback chain: approved_events_count → total_events → 0. Minor JSX formatting adjustments.
Dashboard Events Page
app/dashboard/company/events/page.tsx
Enhanced getStatusBadge function to accept approvalStatus parameter and render new badge variants (Pending Review, Rejected, Changes Requested) based on approval state; all call sites updated to pass event.approval_status.

Sequence Diagram

sequenceDiagram
    participant Client
    participant API as API Route
    participant DB as Database
    participant Service as Company Service
    participant Component as UI Component

    Client->>API: GET /api/companies/[slug]
    API->>DB: Query company
    DB-->>API: company data
    API->>DB: COUNT events WHERE approval_status='approved'
    DB-->>API: count
    API->>API: Augment company with approved_events_count
    API-->>Client: company + approved_events_count

    Client->>Service: listCompanies()
    Service->>DB: Query all companies
    loop For each company
        Service->>DB: COUNT approved events
        DB-->>Service: count
        Service->>Service: Attach approved_events_count
    end
    Service-->>Client: enriched companies[]

    Client->>Component: Render CompanyCard/Profile
    Component->>Component: Use approved_events_count ?? total_events ?? 0
    Component-->>Client: Display event count
Loading

Estimated Code Review Effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

  • API endpoint modification: New database query added for approved events count; verify query correctness and caching behavior with the augmented object.
  • Service layer enrichment: Multiple per-company database queries in listCompanies; review for performance implications and null-safety of the enrichment logic.
  • Function signature change: getStatusBadge signature updated; ensure all call sites pass the new approvalStatus parameter correctly.
  • Approval status badge logic: New conditional rendering for Pending Review, Rejected, and Changes Requested states; verify logic prioritizes approval status appropriately over publication status.

Possibly Related PRs

Poem

🐰 Approved events now counted true,
No more guessing what's been through,
Badges shine with status bright—
Pending, Rejected, Green for Right!
Companies wear their approval crown,
The most graceful count in town! 🎉

✨ 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 23c3e1d and edbaf55.

📒 Files selected for processing (6)
  • app/api/companies/[slug]/route.ts (1 hunks)
  • app/dashboard/company/events/page.tsx (6 hunks)
  • components/companies/CompanyCard.tsx (2 hunks)
  • components/companies/CompanyProfile.tsx (10 hunks)
  • lib/services/company-service.ts (1 hunks)
  • types/company.ts (1 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 328957b 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