Skip to content

Adjust Invites API#541

Merged
mlsmaycon merged 2 commits intomainfrom
feature/adjust-invites-api
Jan 26, 2026
Merged

Adjust Invites API#541
mlsmaycon merged 2 commits intomainfrom
feature/adjust-invites-api

Conversation

@braginini
Copy link
Copy Markdown
Contributor

@braginini braginini commented Jan 26, 2026

Summary by CodeRabbit

  • Refactor
    • Enhanced internal architecture for user invitation management, including improved data structure consistency and API alignment across invitation features.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jan 26, 2026

📝 Walkthrough

Walkthrough

TypeScript interfaces for user invitations are refactored to consolidate UserInviteCreateResponse and UserInviteListItem into a unified UserInvite interface. New request/response interfaces (UserInviteRegenerateRequest, UserInviteRegenerateResponse) are introduced, and all consuming components are updated with corresponding type and field reference changes.

Changes

Cohort / File(s) Summary
Interface Definitions
src/interfaces/User.ts
Renamed UserInviteCreateResponse to UserInvite with restructured properties (added expires_at, created_at, expired, invite_token?; removed status, invite_link, invite_expires_at). Removed UserInviteListItem. Added UserInviteRegenerateRequest and UserInviteRegenerateResponse interfaces.
Component Type Updates
src/modules/users/UserInviteModal.tsx, src/modules/users/UserInvitesTable.tsx
Updated type signatures and imports to use UserInvite instead of UserInviteCreateResponse/UserInviteListItem. Introduced UserInviteRegenerateResponse for regenerate operations. Updated field references: invite_linkinvite_token, invite_expires_atexpires_at. Modified all cell component signatures in table to accept UserInvite.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 The interfaces hop and dance,
UserInviteListItem takes its last stance,
Now unified in UserInvite's embrace,
Token and expires_at find their place,
Refactored with care, the types align—
A cleaner design, simply divine!

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Adjust Invites API' accurately summarizes the main change: refactoring the Invites API interfaces and updating all dependent code to use the new types and structure.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/modules/users/UserInviteModal.tsx`:
- Around line 57-61: The getInviteFullUrl function can return a URL with
token=undefined because successData.invite.invite_token is optional; update
getInviteFullUrl to first verify isInviteSuccess and that
successData?.invite?.invite_token is a non-empty string, short-circuiting to ""
if absent, and when present use
encodeURIComponent(successData.invite.invite_token) to build the URL (keep the
existing origin handling using window.location.origin).

Comment on lines 57 to 61
const getInviteFullUrl = () => {
if (!isInviteSuccess) return "";
const origin = typeof window !== "undefined" ? window.location.origin : "";
return `${origin}/invite?token=${successData.invite.invite_link}`;
return `${origin}/invite?token=${successData.invite.invite_token}`;
};
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Guard against missing invite_token when building the URL.

invite_token is optional in UserInvite, so this can generate token=undefined and a broken invite link. Consider short‑circuiting if the token is absent (and encode it when present).

🛠️ Proposed fix
-  const getInviteFullUrl = () => {
+  const getInviteFullUrl = () => {
     if (!isInviteSuccess) return "";
     const origin = typeof window !== "undefined" ? window.location.origin : "";
-    return `${origin}/invite?token=${successData.invite.invite_token}`;
+    const token = successData.invite.invite_token;
+    if (!token) return "";
+    return `${origin}/invite?token=${encodeURIComponent(token)}`;
   };
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
const getInviteFullUrl = () => {
if (!isInviteSuccess) return "";
const origin = typeof window !== "undefined" ? window.location.origin : "";
return `${origin}/invite?token=${successData.invite.invite_link}`;
return `${origin}/invite?token=${successData.invite.invite_token}`;
};
const getInviteFullUrl = () => {
if (!isInviteSuccess) return "";
const origin = typeof window !== "undefined" ? window.location.origin : "";
const token = successData.invite.invite_token;
if (!token) return "";
return `${origin}/invite?token=${encodeURIComponent(token)}`;
};
🤖 Prompt for AI Agents
In `@src/modules/users/UserInviteModal.tsx` around lines 57 - 61, The
getInviteFullUrl function can return a URL with token=undefined because
successData.invite.invite_token is optional; update getInviteFullUrl to first
verify isInviteSuccess and that successData?.invite?.invite_token is a non-empty
string, short-circuiting to "" if absent, and when present use
encodeURIComponent(successData.invite.invite_token) to build the URL (keep the
existing origin handling using window.location.origin).

@mlsmaycon mlsmaycon merged commit d7d44b5 into main Jan 26, 2026
4 checks passed
@mlsmaycon mlsmaycon deleted the feature/adjust-invites-api branch January 26, 2026 18:25
@coderabbitai coderabbitai Bot mentioned this pull request Mar 29, 2026
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