Skip to content

Conversation

@codeunia-dev
Copy link
Owner

@codeunia-dev codeunia-dev commented Sep 12, 2025

Summary by CodeRabbit

  • New Features
    • Public Events hub: browse, search, filter, and view featured events.
    • Event details page with rich info, share link, and registration (free or paid via Razorpay).
    • Dedicated registration page with checkout for paid events and capacity/deadline awareness.
    • User dashboards: view/manage my event and hackathon registrations, with unregister support.
    • Admin: create, edit, and delete events with a unified dialog and actions.
  • Bug Fixes
    • Clearer username error when database setup is incomplete.
    • Paid event registrations auto-complete via Razorpay webhook.
  • Chores
    • Backend APIs, caching, and database migration to support profiles, events, and registrations.

Deepak Pandey and others added 4 commits September 12, 2025 14:32
- Fix update_username function to use proper schema references (public.profiles)
- Add comprehensive database migration for profiles table and functions
- Improve error handling in UsernameField component for database issues
- Add database diagnostic and testing SQL scripts

Fixes: relation 'profiles' does not exist error in username updates
Resolves: Username update functionality not working due to missing schema references
…e-function

Fix: Resolve username update database function error
…n improvements

🚀 Major Features Added:
- Complete events management system with registration and payment
- Master registration system for unified user tracking
- Enhanced admin dashboard with events management
- Improved user profile and dashboard functionality

🐛 Database Fixes:
- Fixed username update function schema references (public.profiles)
- Resolved 'relation profiles does not exist' error
- Added comprehensive database migration and diagnostic tools

📁 New API Endpoints:
- /api/events/* - Complete events CRUD operations
- /api/events/[slug]/register - Event registration with payment
- /api/events/[slug]/payment - Payment processing for events
- /api/registrations/* - Master registration system
- /api/user/events/* - User-specific event data
- /api/register - User registration endpoint

🎨 New Pages & Components:
- /events - Public events listing page
- /events/[slug] - Individual event pages with registration
- /protected/events - User's registered events
- /protected/hackathons - Enhanced hackathons page
- Enhanced admin events management interface

🔧 Services & Hooks:
- useEvents - Events data management hook
- useEventRegistrations - Event registration management
- useMasterRegistrations - Master registration system
- events.ts - Events service layer
- master-registrations.ts - Registration service layer

📊 Admin Improvements:
- Enhanced events management in admin panel
- Improved dashboard content and user experience
- Better webhook handling for payments

🛠️ Technical Improvements:
- TypeScript types for events system
- Improved error handling and validation
- Better database schema and function management
- Enhanced security and permissions

This comprehensive update includes all recent development work including
the critical database function fix for username updates.
…es-and-fixes

🚀 Comprehensive Updates: Events System, Database Fixes & Admin Improvements
@vercel
Copy link

vercel bot commented Sep 12, 2025

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

Project Deployment Preview Comments Updated (UTC)
codeunia Ready Ready Preview Comment Sep 12, 2025 10:09am

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 12, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds a full events system: admin CRUD UI and service-role API; public events APIs with caching; user registration flows (free and paid via Razorpay) with related pages and hooks; master registrations service and user-facing dashboards; Razorpay webhook enhancements; type definitions; multiple SQL migrations/utilities for profiles and username functions; minor UI/component tweaks.

Changes

Cohort / File(s) Summary
Admin Events UI
app/admin/events/page.tsx
Expands event fields and implements full CRUD in the admin page with create/edit dialog, actions, form state, toasts, and stats.
Admin Events API (service role)
app/api/admin/events/route.ts
Switches to service-scoped Supabase client; simplifies GET; adds create/update/delete with slug checks, payment normalization, admin checks, and error handling.
Public Events API (cache-first)
app/api/events/route.ts, app/api/events/[slug]/route.ts, app/api/events/featured/route.ts
Introduces GET with filters and caching, single-event GET with cache, featured GET; adds POST (admin-only) to create events with cache invalidation.
Event Registration APIs (free & paid)
app/api/events/[slug]/register/route.ts, app/api/events/[slug]/payment/route.ts
Adds free-register/unregister endpoints and Razorpay order/create-verify flow with pending payments, capacity checks, and activity logging.
User Registration Aggregation APIs
app/api/register/route.ts, app/api/registrations/route.ts, app/api/registrations/[activityType]/[activityId]/route.ts, app/api/user/events/route.ts, app/api/user/registrations/route.ts
Adds universal register endpoint; per-user listings and CRUD on registrations; enriches user event registrations with event data; returns grouped stats across activities.
Razorpay Webhook Enhancements
app/api/webhooks/razorpay/route.ts
Extends order.paid handling to update event/hackathon/internship registrations based on notes; adds helper and detailed logging.
Public Event Pages
app/events/page.tsx, app/events/[slug]/page.tsx, app/events/[slug]/register/page.tsx
Adds events catalog with featured carousel; event details page with register/unregister; dedicated registration page handling free and paid (Razorpay) flows.
Protected Dashboards
app/protected/events/page.tsx, app/protected/hackathons/page.tsx
Adds user-centric pages listing event and hackathon participations with filters, stats, and actions (e.g., unregister).
Hooks (Events & Registrations)
hooks/useEvents.ts, hooks/useEventRegistrations.ts, hooks/useMasterRegistrations.ts
Adds hooks for fetching events, featured, single; managing user event registrations; master registrations listing, status, CRUD, and stats.
Services (Server-side)
lib/services/events.ts, lib/services/master-registrations.ts
Adds singleton services for events (CRUD, cached queries) and master registrations (register, list, stats, activity joins) using service-role Supabase.
Types
types/events.ts
Introduces Event, EventsFilters, and EventsResponse interfaces for consistent typing.
UI Components Updates
components/UsernameField.tsx, components/dashboard/DashboardContent.tsx
Adds database-missing profiles error branch; adds dashboard Quick Actions (events/hackathons links).
SQL: Migration & Functions
supabase/migrations/...create_profiles_table_and_functions.sql, fix-username-function.sql
Adds profiles table, triggers, username management functions and policies; redefines update_username with SECURITY DEFINER and grants.
SQL: Diagnostics & Tests
check-database-status.sql, check-schema-permissions.sql, test-username-function.sql, test-fixed-function.sql
Adds scripts to verify schema, permissions, function presence/behavior, and basic table access.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor U as User
  participant P as Event Register Page (/events/[slug]/register)
  participant API as /api/events/[slug]/payment (POST)
  participant RZ as Razorpay
  participant V as /api/events/[slug]/payment (PUT)
  participant S as Supabase+DB

  U->>P: Click "Pay & Register"
  P->>API: Create order (POST)
  API->>S: Validate user/event, capacity, pending
  S-->>API: OK + order record
  API-->>P: { orderId, key, amount, notes }
  P->>RZ: Open Checkout (orderId)
  RZ-->>P: payment_id + signature
  P->>V: Verify (PUT)
  V->>S: Verify pending, update registration, mark paid
  S-->>V: Updated
  V-->>P: success: true
  P-->>U: Show success and redirect
Loading
sequenceDiagram
  autonumber
  actor U as User
  participant P as Event Page (/events/[slug])
  participant API as /api/events/[slug]/register (POST/DELETE)
  participant S as Supabase+DB

  U->>P: Click "Register" (free)
  P->>API: POST register
  API->>S: Auth, capacity, isRegistered?
  S-->>API: Insert registration, inc count
  API-->>P: success
  P-->>U: Status updated

  U->>P: Click "Unregister"
  P->>API: DELETE unregister
  API->>S: Delete registration, dec count
  API-->>P: success
  P-->>U: Status updated
Loading
sequenceDiagram
  autonumber
  participant C as Client
  participant E as /api/events (GET)
  participant Cache as UnifiedCache
  participant Svc as eventsService
  participant DB as Supabase

  C->>E: GET with filters
  E->>Cache: Read key(filters)
  alt Cache hit
    Cache-->>E: Cached response
    E-->>C: Return cached
  else Cache miss
    E->>Svc: getEvents(filters)
    Svc->>DB: Query with filters + count
    DB-->>Svc: rows, total
    Svc-->>E: { events, total, hasMore }
    E->>Cache: Write key(filters)
    E-->>C: Return fresh
  end
Loading

Estimated code review effort

🎯 5 (Critical) | ⏱️ ~120 minutes

Poem

I thump my paws—new events to see!
Carousels spin, and queues agree.
Free hops here, paid hops there—
Razorpay rings in autumn air.
Caches purr, migrations bloom,
Registrations fill the room—
A happy hare in shipping zoom! 🐇✨

Tip

👮 Agentic pre-merge checks are now available in preview!

Pro plan users can now enable pre-merge checks in their settings to enforce checklists before merging PRs.

  • Built-in checks – Quickly apply ready-made checks to enforce title conventions, require pull request descriptions that follow templates, validate linked issues for compliance, and more.
  • Custom agentic checks – Define your own rules using CodeRabbit’s advanced agentic capabilities to enforce organization-specific policies and workflows. For example, you can instruct CodeRabbit’s agent to verify that API documentation is updated whenever API schema files are modified in a PR. Note: Upto 5 custom checks are currently allowed during the preview period. Pricing for this feature will be announced in a few weeks.

Please see the documentation for more information.

Example:

reviews:
  pre_merge_checks:
    custom_checks:
      - name: "Undocumented Breaking Changes"
        mode: "warning"
        instructions: |
          Pass/fail criteria: All breaking changes to public APIs, CLI flags, environment variables, configuration keys, database schemas, or HTTP/GraphQL endpoints must be documented in the "Breaking Change" section of the PR description and in CHANGELOG.md. Exclude purely internal or private changes (e.g., code not exported from package entry points or explicitly marked as internal).

Please share your feedback with us on this Discord post.


📜 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 b6843fc and 2a2cf2c.

📒 Files selected for processing (32)
  • app/admin/events/page.tsx (6 hunks)
  • app/api/admin/events/route.ts (8 hunks)
  • app/api/events/[slug]/payment/route.ts (1 hunks)
  • app/api/events/[slug]/register/route.ts (1 hunks)
  • app/api/events/[slug]/route.ts (1 hunks)
  • app/api/events/featured/route.ts (1 hunks)
  • app/api/events/route.ts (1 hunks)
  • app/api/register/route.ts (1 hunks)
  • app/api/registrations/[activityType]/[activityId]/route.ts (1 hunks)
  • app/api/registrations/route.ts (1 hunks)
  • app/api/user/events/route.ts (1 hunks)
  • app/api/user/registrations/route.ts (1 hunks)
  • app/api/webhooks/razorpay/route.ts (2 hunks)
  • app/events/[slug]/page.tsx (1 hunks)
  • app/events/[slug]/register/page.tsx (1 hunks)
  • app/events/page.tsx (1 hunks)
  • app/protected/events/page.tsx (1 hunks)
  • app/protected/hackathons/page.tsx (1 hunks)
  • check-database-status.sql (1 hunks)
  • check-schema-permissions.sql (1 hunks)
  • components/UsernameField.tsx (1 hunks)
  • components/dashboard/DashboardContent.tsx (2 hunks)
  • fix-username-function.sql (1 hunks)
  • hooks/useEventRegistrations.ts (1 hunks)
  • hooks/useEvents.ts (1 hunks)
  • hooks/useMasterRegistrations.ts (1 hunks)
  • lib/services/events.ts (1 hunks)
  • lib/services/master-registrations.ts (1 hunks)
  • supabase/migrations/20241201000003_create_profiles_table_and_functions.sql (1 hunks)
  • test-fixed-function.sql (1 hunks)
  • test-username-function.sql (1 hunks)
  • types/events.ts (1 hunks)
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/zenith-hall-transformation

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.

2 participants