Skip to content

Conversation

@codeunia-dev
Copy link
Owner

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

This PR introduces multi-company–level improvements across events and notifications, strengthening both backend logic and admin visibility.

🧩 Key Updates

  • Events Module

    • Enhanced event creation flow to support company-specific usage tracking.
    • Refined approval and status display logic in admin views for clearer moderation insights.
    • Optimized filtering and data consistency across event listings.
  • Notifications System

    • Added a comprehensive Notifications Management Page for admins and company managers.
    • Standardized trigger logic to prevent duplicate notifications and improve debugging.
    • Improved messaging templates for clearer user communication on event approvals and updates.

⚙️ Technical Improvements

  • Unified trigger and function definitions for event approval notifications.
  • Reduced redundant queries and optimized data fetching for event lists.
  • Strengthened auditability with debug logging for event approval triggers.
  • Cleaned up migrations to ensure single-source notification behavior.

🧪 Testing

  • Verified event creation and approval workflows at both admin and company levels.
  • Confirmed single notification delivery after trigger refactor.
  • Regression-tested existing notification flows and admin dashboards.

🧍‍♂️ Review Notes

  • Focus on verifying trigger behavior and notification duplication resolution.
  • Review event approval flow under /admin/moderation.
  • Check Supabase logs for expected NOTICE outputs.

🔗 Closes

Closes internal tracking issues on event duplication and multi-company event management.

Authored by: @akshay0611

Summary by CodeRabbit

Release Notes

  • New Features

    • Added notifications page with filtering, mark as read, and delete capabilities
    • Company dashboard now displays monthly event usage with over-limit warning and dynamic progress bar
  • Bug Fixes

    • Event status values in admin table now properly capitalize first letter
  • Chores

    • Removed internal SQL utility scripts
    • Events now initialize in draft state by default

…ttings

- Add useSubscription hook to track event usage for current month
- Update event creation service to set default approval_status to 'draft'
- Modify company settings page to display dynamic event usage with limit warning
- Add visual indicator for exceeding monthly event creation limit
- Improve event usage tracking and display with more granular information
…ts page

- Capitalize first letter of event status in admin events table
- Update admin events API to filter out draft events
- Modify event query to only show events with specific approval statuses
- Enhance readability of event status display in table view
- Create new notifications page with dynamic filtering and interaction
- Implement tabs for viewing all and unread notifications
- Add notification statistics and summary cards
- Support marking individual and all notifications as read
- Include notification deletion functionality
- Enhance UI with responsive design and intuitive actions
- Integrate with existing useNotifications hook for data management
- Add visual indicators for notification status and type
- Implement time-based notification formatting
@vercel
Copy link

vercel bot commented Nov 13, 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 13, 2025 10:06am

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

coderabbitai bot commented Nov 13, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The pull request refactors event status handling from pending to draft states, introduces a new notifications page with filtering and actions, integrates subscription usage data into the dashboard, and removes legacy database utility scripts. Multiple components across events, notifications, and dashboard features are updated cohesively.

Changes

Cohort / File(s) Summary
Event Status & Approval Workflow
app/admin/events/page.tsx, app/api/admin/events/route.ts, lib/services/events.ts
Status display capitalization in Badge; approval_status filtering added to admin GET route; new events initialized as draft instead of pending, status field removed from payload, comments added about submission workflow
Dashboard & Company Settings
app/dashboard/company/[slug]/settings/page.tsx, components/dashboard/CompanyDashboard.tsx
Dashboard integrates useSubscription usage data to drive "Events Created (This Month)" display, progress bar styling, and over-limit warnings; UpcomingEventItem component removes companySlug prop and Link wrapper
Notifications Feature
app/protected/notifications/page.tsx, components/notifications/NotificationCenter.tsx
New NotificationsPage added with fetching, filter tabs (all/unread), summary stats, per-notification cards with actions (open link, mark read, delete), empty states, and loading UI; NotificationCenter adds Next.js Link integration for "View all notifications" action
Database Utility Cleanup
check-database-status.sql, check-schema-permissions.sql, test-fixed-function.sql, test-username-function.sql
Removal of entire database validation and test utility scripts

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant NotificationsPage
    participant useNotifications
    participant API

    User->>NotificationsPage: Visit /protected/notifications
    NotificationsPage->>useNotifications: Fetch notifications
    useNotifications->>API: GET /api/notifications
    API-->>useNotifications: Return notifications list
    useNotifications-->>NotificationsPage: notifications[], loading, unread count
    
    NotificationsPage->>NotificationsPage: Render cards with filter tabs
    
    alt Notification Card Action
        User->>NotificationsPage: Click action (open/read/delete)
        NotificationsPage->>API: Update notification state
        API-->>NotificationsPage: Success
        NotificationsPage->>NotificationsPage: Refresh display
    end
    
    alt Mark All as Read
        User->>NotificationsPage: Click "Mark all as read"
        NotificationsPage->>API: POST mark all as read
        API-->>NotificationsPage: Success
        NotificationsPage->>useNotifications: Refetch notifications
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • app/protected/notifications/page.tsx: Verify hook dependencies, loading state handling, and API integration; ensure all filter states and action handlers function correctly
  • app/dashboard/company/[slug]/settings/page.tsx: Validate useSubscription data structure, progress bar calculations, and conditional styling logic for over-limit states
  • lib/services/events.ts & related components: Confirm draft→pending approval workflow is properly enforced and no orphaned references to old status values remain

Possibly related PRs

Poem

🐰 Events draft now, pending submission's call,
Notifications bloom on a shiny new page,
Dashboard watches usage, warns when limits enthrall,
Old SQL scripts retire—a fresh age!
Hop on, dear changes, let features prevail! 🌱

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

📜 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 e5a6be4 and c434a78.

📒 Files selected for processing (11)
  • app/admin/events/page.tsx (1 hunks)
  • app/api/admin/events/route.ts (1 hunks)
  • app/dashboard/company/[slug]/settings/page.tsx (2 hunks)
  • app/protected/notifications/page.tsx (1 hunks)
  • check-database-status.sql (0 hunks)
  • check-schema-permissions.sql (0 hunks)
  • components/dashboard/CompanyDashboard.tsx (2 hunks)
  • components/notifications/NotificationCenter.tsx (2 hunks)
  • lib/services/events.ts (1 hunks)
  • test-fixed-function.sql (0 hunks)
  • test-username-function.sql (0 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.

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