Skip to content

Conversation

@codeunia-dev
Copy link
Owner

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

  • Add effectiveSlug variable that uses currentCompany.slug as fallback when companySlug from params is undefined
  • Update all sidebar navigation URLs to use effectiveSlug instead of companySlug for consistent routing
  • Enhance company_members query to fetch related company slug data
  • Add active status filter to company membership query for data integrity
  • Improve student route redirect logic to use company slug when available, with fallback to generic company dashboard
  • Prevents routing errors when companySlug parameter is missing from URL params

Authored by: @akshay0611

Summary by CodeRabbit

  • Bug Fixes
    • Improved company dashboard navigation with fallback slug handling to ensure consistent access.
    • Enhanced company member routing to direct users to their specific company dashboard with improved membership validation.

…ce role protection redirect

- Add effectiveSlug variable that uses currentCompany.slug as fallback when companySlug from params is undefined
- Update all sidebar navigation URLs to use effectiveSlug instead of companySlug for consistent routing
- Enhance company_members query to fetch related company slug data
- Add active status filter to company membership query for data integrity
- Improve student route redirect logic to use company slug when available, with fallback to generic company dashboard
- Prevents routing errors when companySlug parameter is missing from URL params
@vercel
Copy link

vercel bot commented Nov 17, 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 17, 2025 9:36am

@codeunia-dev codeunia-dev merged commit 81c610f into main Nov 17, 2025
3 of 4 checks passed
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 17, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

The PR introduces fallback slug handling in the company dashboard layout and enhances role protection routing logic to use nested company membership data. All dashboard sidebar URLs now resolve to an effective slug with fallback support, while the role protection hook retrieves company slugs from membership relationships for improved redirect consistency.

Changes

Cohort / File(s) Summary
Company Dashboard Layout
app/dashboard/company/layout.tsx
Adds effectiveSlug fallback that prioritizes companySlug parameter, then falls back to currentCompany.slug. Updates all sidebar navigation URLs (Overview, Events, Hackathons, Team, Analytics, Settings, Subscription) to use the fallback slug for URL construction.
Role Protection Hook
lib/hooks/useRoleProtection.ts
Improves company membership query to select nested company slug and filters for active memberships. Updates student route redirect logic to use retrieved company slug from membership data, with fallback to generic /dashboard/company route if slug is unavailable.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Route as Student Route
    participant Hook as useRoleProtection
    participant DB as Membership Data
    participant Dashboard

    User->>Route: Access /dashboard
    Route->>Hook: Check role protection
    activate Hook
    Hook->>DB: Query active company membership<br/>(with nested company.slug)
    DB-->>Hook: Return membership + slug
    alt Slug available
        Hook->>Dashboard: Redirect to /dashboard/company/[slug]
    else Slug unavailable
        Hook->>Dashboard: Fallback to /dashboard/company
    end
    deactivate Hook
    Dashboard-->>User: Render dashboard with<br/>effectiveSlug fallback
    Note over Dashboard: All sidebar URLs use<br/>effectiveSlug = companySlug || currentCompany.slug
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Query changes in useRoleProtection.ts: Verify the company membership query correctly nests slug selection and that the active status filter aligns with business logic.
  • Redirect fallback logic: Ensure the redirect chain (student → company dashboard with slug → generic dashboard) handles all edge cases and doesn't create redirect loops.
  • Sidebar URL consistency: Confirm all seven sidebar navigation links properly use effectiveSlug and that no URLs were missed in the layout file.

Possibly related PRs

Poem

🐰 A slug fallback hops through the code,
When paths grow uncertain, it eases the load,
Dashboard and hooks now dance in sync,
With nested queries and smart redirect links! ✨

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

📜 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 46433c5 and af7b5f9.

📒 Files selected for processing (2)
  • app/dashboard/company/layout.tsx (4 hunks)
  • lib/hooks/useRoleProtection.ts (2 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