Skip to content

Conversation

@codeunia-dev
Copy link
Owner

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

This PR introduces critical fixes and feature improvements to the hackathons module.
It resolves issues with event tracking, improves the reliability of click/view analytics, and adds full support for user registration and unregistration flows.


🔧 Key Fixes & Enhancements

1. Fix: Use slug instead of id for hackathon tracking

  • Updated all click and view tracking logic to rely on slug rather than the internal id.
  • Ensures stable, SEO-friendly, and consistent tracking across the platform.
  • Fixes misaligned analytics caused by ID-based references when cloning or importing hackathons.

2. Feature: Added user registration & unregistration endpoints

  • Introduced new API routes for:

    • Registering a user for a hackathon
    • Unregistering a user from a hackathon
  • Full validation and permission checks added.

  • Updates related counters/relations to ensure accurate tracking.

  • Prepares backend for upcoming UI integration in the dashboard.


📁 Files Updated

  • 5 files touched
  • 351 additions, 20 deletions

Includes updates in:

  • API routes
  • Hackathon service layer
  • Database interaction helpers
  • Tracking logic
  • Validation and type definitions

🧪 Testing & Validation

  • Manually tested registration/unregistration flow.
  • Verified view/click events record correctly using slug.
  • Confirmed no regressions in existing hackathon endpoints.

🚀 Impact

This update improves:

  • Consistency in analytics
  • Reliability of hackathon tracking
  • User engagement workflows
  • Backend readiness for new dashboard features

Authored by: @akshay0611

Summary by CodeRabbit

  • New Features
    • Users can now register and unregister for hackathons directly from hackathon pages.
    • Registration status updates in real-time with corresponding button state changes.
    • Toast notifications confirm successful registration actions.
    • Analytics tracking added for registration activities.

…ndpoints

- Update track-click endpoint to query hackathons by slug instead of id
- Update track-view endpoint to query hackathons by slug instead of id
- Clarify comments to indicate id param is actually the slug value
- Fix incorrect database queries that were using wrong field for lookup
- Create new POST endpoint for hackathon registration with capacity and approval checks
- Create new DELETE endpoint for hackathon unregistration with count decrement
- Add registration state management and UI controls to hackathon detail page
- Implement master_registrations table integration for tracking user registrations
- Add validation for hackathon approval status and live/published state before registration
- Update hackathon registered count on successful registration and unregistration
- Add user profile data capture (name, email, phone) during registration
- Implement duplicate registration prevention and capacity limit enforcement
- Add toast notifications for registration success and error states
- Change approved hackathon status from 'published' to 'live' for consistency
@vercel
Copy link

vercel bot commented Nov 18, 2025

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

Project Deployment Preview Comments Updated (UTC)
codeunia Ready Ready Preview Comment Nov 18, 2025 4:10am

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

coderabbitai bot commented Nov 18, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR implements hackathon registration functionality, adding backend endpoints for user registration and unregistration, updates analytics tracking to use slug-based lookups, refines the moderation approval status, and adds registration UI with state management to the hackathon detail page.

Changes

Cohort / File(s) Summary
Registration API Route
app/api/hackathons/[id]/register/route.ts
Adds new POST handler for user registration with authentication, hackathon validation, capacity checking, and duplicate prevention; adds new DELETE handler for unregistration with decrement logic. Both endpoints update master_registrations and hackathons tables accordingly.
Analytics Tracking Routes
app/api/hackathons/[id]/track-click/route.ts, app/api/hackathons/[id]/track-view/route.ts
Changes hackathon lookups from id-based to slug-based queries by updating filter from .eq('id', id) to .eq('slug', id).
Moderation Endpoint
app/api/admin/moderation/hackathons/[id]/route.ts
Updates approval path to set updateData.status to 'live' instead of 'published'.
Hackathon Detail Page
app/hackathons/[id]/page.tsx
Adds registration state flags (isRegistered, registering, checkingRegistration), implements useEffect to verify user registration via Supabase, adds handleRegister and handleUnregister functions with toast notifications, updates UI to show Register/Unregister buttons with appropriate loading states, and integrates analytics tracking on registration actions.

Sequence Diagram

sequenceDiagram
    participant User as User<br/>(Client)
    participant Page as Hackathon Page<br/>(app/hackathons/[id])
    participant RegAPI as Registration API<br/>(/register)
    participant DB as Database<br/>(Supabase)

    rect rgba(100, 150, 200, 0.1)
    Note over User,Page: User Registration Flow
    User->>Page: Click "Register Now"
    Page->>Page: Set registering = true
    Page->>RegAPI: POST /api/hackathons/[id]/register
    RegAPI->>DB: Verify user authenticated
    RegAPI->>DB: Check hackathon status (live/published)
    RegAPI->>DB: Verify capacity & no duplicate
    RegAPI->>DB: Create master_registrations entry
    RegAPI->>DB: Increment hackathon registered count
    DB-->>RegAPI: Success
    RegAPI-->>Page: 200 OK
    Page->>Page: Set isRegistered = true
    Page->>User: Show toast confirmation
    Page->>Page: Refresh hackathon data
    end

    rect rgba(200, 100, 100, 0.1)
    Note over User,Page: User Unregistration Flow
    User->>Page: Click "Unregister"
    Page->>Page: Set registering = true
    Page->>RegAPI: DELETE /api/hackathons/[id]/register
    RegAPI->>DB: Verify user authenticated
    RegAPI->>DB: Delete master_registrations entry
    RegAPI->>DB: Decrement hackathon registered count
    DB-->>RegAPI: Success
    RegAPI-->>Page: 200 OK
    Page->>Page: Set isRegistered = false
    Page->>User: Show toast confirmation
    Page->>Page: Refresh hackathon data
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Key areas requiring extra attention:

  • Registration API route (app/api/hackathons/[id]/register/route.ts): Verify authentication flow, capacity enforcement logic, duplicate registration prevention, and proper error handling for edge cases (e.g., race conditions on capacity checks).
  • Frontend registration state (app/hackathons/[id]/page.tsx): Confirm useEffect dependency array is correct, state management handles async operations properly, and loading states prevent duplicate submissions.
  • Status field consistency: Verify that changing moderation approval status from 'published' to 'live' aligns with the hackathon status checks in the new registration endpoint.
  • Analytics integration: Ensure trackClick is called with correct parameters on registration actions and doesn't conflict with existing tracking.

Possibly related PRs

Poem

🐰 A hop, a skip, the reg-form flies,
New endpoints dance 'neath autumn skies,
With slugs and states, we trace the path,
Users register—oh, what a laugh!
Live status gleams from dusk to dawn! ✨

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

📜 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 4357461 and 2aa4c07.

📒 Files selected for processing (5)
  • app/api/admin/moderation/hackathons/[id]/route.ts (1 hunks)
  • app/api/hackathons/[id]/register/route.ts (1 hunks)
  • app/api/hackathons/[id]/track-click/route.ts (1 hunks)
  • app/api/hackathons/[id]/track-view/route.ts (1 hunks)
  • app/hackathons/[id]/page.tsx (6 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