Skip to content

Conversation

@codeunia-dev
Copy link
Owner

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

  • Replace 'member' role with 'viewer' role across member management APIs
  • Add usePendingInvitationRedirect hook for handling pending team invitations
  • Integrate pending invitation redirect logic into analytics, events, and hackathons pages
  • Add loading states while checking invitation status on company dashboard pages
  • Update team invitation email template with improved formatting
  • Enhance TeamManagement component with role-based access controls
  • Update company member service to support new viewer role permissions
  • Fix brand name capitalization from "CodeUnia" to "Codeunia" in invitation messaging
  • Add comprehensive role documentation in company FAQ
  • Improve company layout with better context management and loading states

Authored by: @akshay0611

Summary by CodeRabbit

Release Notes

  • New Features

    • Added pending invitation handling with automatic redirect to acceptance flow.
  • Bug Fixes

    • Corrected product branding from "CodeUnia" to "Codeunia" across email templates and UI.
    • Fixed team member invitation status display from "Invited" to "Pending."
  • Updates

    • Renamed "Member" role to "Viewer" for improved clarity on read-only permissions.
    • Enhanced access controls to properly manage users with pending invitations.

…on handling

- Replace 'member' role with 'viewer' role across member management APIs
- Add usePendingInvitationRedirect hook for handling pending team invitations
- Integrate pending invitation redirect logic into analytics, events, and hackathons pages
- Add loading states while checking invitation status on company dashboard pages
- Update team invitation email template with improved formatting
- Enhance TeamManagement component with role-based access controls
- Update company member service to support new viewer role permissions
- Fix brand name capitalization from "CodeUnia" to "Codeunia" in invitation messaging
- Add comprehensive role documentation in company FAQ
- Improve company layout with better context management and loading states
@vercel
Copy link

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Nov 15, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

This PR updates the company membership system by replacing "member" role terminology with "viewer," changing "invited" status to "pending," introducing a new usePendingInvitationRedirect hook for invitation flow control, adding access guards for pending memberships, and correcting brand name casing from "CodeUnia" to "Codeunia" across email and UI text.

Changes

Cohort / File(s) Summary
Type Definitions
types/company.ts
Updated CompanyMember type: role union changed from 'member' to 'viewer'; status union changed from 'invited' to 'pending'.
API Validation Routes
app/api/companies/[slug]/members/[userId]/route.ts, app/api/companies/[slug]/members/invite/route.ts
Updated validation schemas and error messages to reflect role options as ['admin', 'editor', 'viewer'] instead of ['admin', 'editor', 'member'].
Pending Invitation Hook
lib/hooks/usePendingInvitationRedirect.ts
New React hook that detects pending invitation status for the current company from user's membership list and redirects to accept-invitation page if pending. Returns boolean indicating pending status.
Member Service Logic
lib/services/company-member-service.ts
Updated method signatures and validation logic to use 'viewer' role instead of 'member'; corrected brand name from "CodeUnia" to "Codeunia" in email templates and messages.
Dashboard Pages with Pending Guard
app/dashboard/company/[slug]/page.tsx, app/dashboard/company/[slug]/analytics/page.tsx, app/dashboard/company/[slug]/events/page.tsx, app/dashboard/company/[slug]/hackathons/page.tsx, app/dashboard/company/[slug]/settings/page.tsx, app/dashboard/company/[slug]/team/page.tsx
Added usePendingInvitationRedirect() hook and incorporated isPendingInvitation into loading state checks, rendering spinner while pending invitation resolves.
Company Layout & Subscription
app/dashboard/company/layout.tsx, app/dashboard/company/[slug]/subscription/page.tsx
Layout: suppresses sidebar when user has pending invitation to current company; Subscription: removed status filter from query and added access guards to redirect on pending or missing membership.
UI Components & Text
components/dashboard/TeamManagement.tsx, app/dashboard/company/[slug]/accept-invitation/page.tsx, components/help/CompanyFAQ.tsx, lib/email/templates/team-invitation.tsx
Updated role/status terminology from "member"/"invited" to "viewer"/"pending" in dialogs; corrected brand casing "CodeUnia" → "Codeunia" in email and UI text; updated FAQ role references.

Sequence Diagram

sequenceDiagram
    participant User
    participant Dashboard as Dashboard Page
    participant Hook as usePendingInvitationRedirect
    participant Context as Company Context
    participant Router as Next.js Router

    User->>Dashboard: Navigate to dashboard page
    Dashboard->>Hook: Call usePendingInvitationRedirect()
    Hook->>Context: Read currentCompany, userCompanies, loading
    alt Loading in progress
        Hook->>Dashboard: Return false (still loading)
        Dashboard->>User: Render spinner
    else Company exists & loaded
        Hook->>Hook: Find membership for current company
        alt Membership status === 'pending'
            Hook->>Router: Redirect to accept-invitation
            Hook->>Dashboard: Return true (pending)
            Dashboard->>User: Render spinner
            Router->>User: Navigate to accept-invitation page
        else Membership not pending
            Hook->>Dashboard: Return false
            Dashboard->>User: Render page content normally
        end
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Homogeneous patterns: Six dashboard pages follow the identical pattern of adding the pending invitation hook to their loading state checks, reducing cognitive overhead.
  • Repetitive terminology updates: "member" → "viewer" and "invited" → "pending" applied consistently across types, validation, components, and services.
  • New hook logic: The usePendingInvitationRedirect hook is straightforward but requires verification of redirect guards and dependency array correctness.
  • Attention areas:
    • Verify the redirect logic in usePendingInvitationRedirect.ts correctly handles all loading states and edge cases.
    • Confirm membership query changes in subscription/page.tsx don't inadvertently expose restricted data.
    • Check that all six dashboard pages consistently apply the new guard without missing any branches.

Possibly related PRs

  • PR #313: Adds membership "check-invitation" API and updates accept-invitation logic; complements this PR's pending-invitation gating and hook introduction.

Poem

🐰 A viewer role hops into sight,
Where "pending" blooms in clearer light,
Codeunia's name now spelled just right,
Invitations caught in gentle flight,
The dashboard waits with patient might! ✨

✨ 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/company-team-roles-and-invite-flow

📜 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 df2d5f7 and ff12f08.

📒 Files selected for processing (17)
  • app/api/companies/[slug]/members/[userId]/route.ts (1 hunks)
  • app/api/companies/[slug]/members/invite/route.ts (1 hunks)
  • app/dashboard/company/[slug]/accept-invitation/page.tsx (1 hunks)
  • app/dashboard/company/[slug]/analytics/page.tsx (3 hunks)
  • app/dashboard/company/[slug]/events/page.tsx (3 hunks)
  • app/dashboard/company/[slug]/hackathons/page.tsx (3 hunks)
  • app/dashboard/company/[slug]/page.tsx (2 hunks)
  • app/dashboard/company/[slug]/settings/page.tsx (3 hunks)
  • app/dashboard/company/[slug]/subscription/page.tsx (1 hunks)
  • app/dashboard/company/[slug]/team/page.tsx (2 hunks)
  • app/dashboard/company/layout.tsx (2 hunks)
  • components/dashboard/TeamManagement.tsx (6 hunks)
  • components/help/CompanyFAQ.tsx (1 hunks)
  • lib/email/templates/team-invitation.tsx (1 hunks)
  • lib/hooks/usePendingInvitationRedirect.ts (1 hunks)
  • lib/services/company-member-service.ts (5 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.

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