Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
📝 WalkthroughSummary by CodeRabbit
WalkthroughThe changes refactor member invitations handling across the hook and UI layer. The Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 📝 Coding Plan
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. Comment |
Pull Request Test Coverage Report for Build 23193189067Details
💛 - Coveralls |
There was a problem hiding this comment.
🧹 Nitpick comments (3)
web/sdk/react/hooks/useOrganizationMembers.ts (2)
9-9: Type relaxation may break downstream type safety.Changing
MemberWithInvitetoPartial<User> & Partial<Invitation>makes all fields optional, includingidwhich is required for actual users. Downstream consumers (e.g.,MembersActionsaccessingmember.idfor policy queries) lose compile-time guarantees thatidexists for non-invitation members.Consider a discriminated union to preserve type safety:
♻️ Suggested type definition
-export type MemberWithInvite = Partial<User> & Partial<Invitation> & { invited?: boolean }; +export type MemberWithInvite = + | (User & { invited?: false }) + | (Invitation & { email: string; invited: true });
77-86: The email mapping is correct; consider removing the unsafe cast.The logic to map
userIdtoas unknown as MemberWithInvite[]cast bypasses type checking entirely.If the type definition is adjusted to a discriminated union (as suggested above), this cast becomes unnecessary and the code gains full type safety:
♻️ Suggested refactor
const updatedUsers = useMemo(() => { - const invitations = (invitationsData?.invitations || []).map(user => { - return { - ...user, - email: user.userId, - invited: true - }; - }); - return [...users, ...invitations] as unknown as MemberWithInvite[]; + const invitations: MemberWithInvite[] = (invitationsData?.invitations || []).map(inv => ({ + ...inv, + email: inv.userId, + invited: true as const + })); + const userMembers: MemberWithInvite[] = users.map(u => ({ ...u, invited: false as const })); + return [...userMembers, ...invitations]; }, [users, invitationsData?.invitations]);web/sdk/react/views/members/member-columns.tsx (1)
67-67: Email access may be undefined with the relaxed type.Since
MemberWithInvitenow usesPartial<User>,undefined.Consider adding a fallback for defensive rendering:
🛡️ Suggested defensive fallback
- const email = row.original.email; + const email = row.original.email ?? row.original.userId ?? '';
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: ef980a3d-3185-4fbc-8ae0-16a0a005ff1f
📒 Files selected for processing (2)
web/sdk/react/hooks/useOrganizationMembers.tsweb/sdk/react/views/members/member-columns.tsx
This PR fixes the search issue of invitations in the Members table.
When we show the members list, we merge it with invitations. so table can render both. But both the member and invitation have different fields, thus the search was not working.
The organization invitations api returns the user email in the
userIdfield; thus, the search was not working.This PR adds a field called
emailin invitations and maps it to the invitationuserId.