Fix: Completion screen: personalized invite link for 'Invite a team member'#686
Fix: Completion screen: personalized invite link for 'Invite a team member'#686Kirtan-pc wants to merge 2 commits into
Conversation
|
@Kirtan-pc is attempting to deploy a commit to the codersogs-3057's projects Team on Vercel. A member of the Team first needs to authorize it. |
jakharmonika364
left a comment
There was a problem hiding this comment.
This is a great addition! Tying invites back to the inviter makes a lot of sense.
I've found a couple of edge cases that we should handle before merging this:
1. Async Clipboard API Error Handling
Calling navigator.clipboard.writeText() after an await network request can sometimes be blocked by browsers (especially Safari) if the network request takes too long, because it loses the "active user gesture" context. If it gets blocked or fails, writeText throws an error which currently isn't caught, leaving the button stuck in the "Generating..." state.
Could you wrap the clipboard logic in a try/catch block?
const link = `${process.env.NEXT_PUBLIC_APP_URL || 'https://mergeship.dev'}/invite?ref=${res.data}`;
try {
await navigator.clipboard.writeText(link);
setLinkCopied(true);
} catch (err) {
setError('Failed to copy to clipboard. Please try again.');
} finally {
setGeneratingLink(false);
setTimeout(() => {
setLinkCopied(false);
setError(null);
}, 2000);
}|
Hey @jakharmonika364, |
Summary
The "Invite a team member" / "Invite contributor" button now generates a personalized invite link (/invite?ref={handle}) that can be copied to clipboard, so whoever clicks it can be tied back to the inviter.
Type of Change
Related Issue
Closes #680
What was changed?
Checklist
npm run dev)