-
Notifications
You must be signed in to change notification settings - Fork 800
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add invite link functionality to team #1168
base: main
Are you sure you want to change the base?
Conversation
@ShreyasLakhani is attempting to deploy a commit to the mftsio Team on Vercel. A member of the Team first needs to authorize it. |
@mfts I migration folder I change code because of veriable conflict. Initially I used "shareLink " in prisma but in code I used "inviteLink" . So i changed all name and use single name "inviteLink". Let me know, if any error occur. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great start! There are a couple of comments for improvement and changes.
One thing I didn't see is how the user actually signs up using the invite link. I think that part is missing or I missed it in the review somehow.
import { v4 as uuidv4 } from 'uuid'; | ||
|
||
const generateUniqueInviteLink = (): string => { | ||
return `https://papermark.com/teams/invite/${uuidv4()}`; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
could you use nanoid()
instead of uuid.
const newLink = generateUniqueInviteLink(); | ||
const updatedTeam = await prisma.team.update({ | ||
where: { id: teamId }, | ||
data: { inviteLink: newLink }, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also let's only store the unique code
for each team, not the full URL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this appears in several other places
pages/api/teams/[teamId]/invite.ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need to change this file. this is not related to the team invite link
-- AlterTable | ||
DO $$ | ||
BEGIN | ||
IF EXISTS (SELECT 1 FROM information_schema.columns WHERE table_name = 'Team' AND column_name = 'inviteLink') THEN | ||
ALTER TABLE "Team" DROP COLUMN "inviteLink"; | ||
END IF; | ||
END $$; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I understand that you changed the schema locally for yourself, but please remove this from the migration
prisma/schema.prisma
Outdated
@@ -84,6 +84,8 @@ model Team { | |||
|
|||
createdAt DateTime @default(now()) | |||
updatedAt DateTime @updatedAt | |||
|
|||
inviteLink String? @unique // Add this line for the unique share link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think a more appropriate field name is inviteCode
<div className="mb-4"> | ||
<Label className="opacity-80">Or share invite link</Label> | ||
<Input | ||
value={inviteLink || ""} | ||
readOnly | ||
className="mt-1 w-full" | ||
/> | ||
<div className="mt-2 flex justify-between"> | ||
<Button | ||
onClick={handleCopyInviteLink} | ||
disabled={!inviteLink || inviteLinkLoading} | ||
className="flex-1 mr-2" | ||
> | ||
Copy Link | ||
</Button> | ||
</DialogFooter> | ||
</form> | ||
<Button | ||
onClick={handleResetInviteLink} | ||
disabled={inviteLinkLoading} | ||
className="flex-1" | ||
> | ||
Reset Link | ||
</Button> | ||
</div> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add the invite by link as a separate dialog / modal
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfts
I made all changes but I did not understand last changes you told me.
"please add the invite by link as a separate dialog / modal".
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ShreyasLakhani instead of adding the button with the copy invite link on the add-team-member-modal.tsx, please create a new component only for copying the invite link. and that should be a separate button on the /people page.
/assign |
The /assign command can only be used on issues, not on pull requests. |
/assign |
The /assign command can only be used on issues, not on pull requests. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfts check my PR and give me feedback.
@mfts if anything missing or not done please tell me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Some changes requested. Let me know if you have a question :)
<div className="mb-4"> | ||
<Label className="opacity-80">Or share invite link</Label> | ||
<Input | ||
value={inviteLink || ""} | ||
readOnly | ||
className="mt-1 w-full" | ||
/> | ||
<div className="mt-2 flex justify-between"> | ||
<Button | ||
onClick={handleCopyInviteLink} | ||
disabled={!inviteLink || inviteLinkLoading} | ||
className="flex-1 mr-2" | ||
> | ||
Copy Link | ||
</Button> | ||
</DialogFooter> | ||
</form> | ||
<Button | ||
onClick={handleResetInviteLink} | ||
disabled={inviteLinkLoading} | ||
className="flex-1" | ||
> | ||
Reset Link | ||
</Button> | ||
</div> | ||
</div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ShreyasLakhani instead of adding the button with the copy invite link on the add-team-member-modal.tsx, please create a new component only for copying the invite link. and that should be a separate button on the /people page.
where: { id: teamId }, | ||
data: { inviteCode: newCode }, // Store the unique code in inviteCode | ||
}); | ||
return res.json({ inviteLink: `https://papermark.com/teams/invite/${newCode}` }); // Return the full invite link |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this should be app.papermark.io but better to use process.env.NEXTAUTH_URL
.
also there should be a page for the accepting the invite code as the url indicates. so pages/teams/invite/[code]/index.tsx
that's currently missing.
pages/api/auth/[...nextauth].ts
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't think this is relevant here if you let the user accept the invite on a dedicated page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mfts all changes you mentioned I have completed.
Let me know, If anything I miss.
@mfts can you please review my changes before end of hacktoberfest. |
@ShreyasLakhani will review your PR tomorrow. and don't worry will award before end of hacktoberfest :) |
@mfts Brother, I respect your time but You said that you will review. I request to review or proceed award. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mentioned a couple of things inline.
@ShreyasLakhani great progress, I mentioned the change requests inline. I'm happy to award you 50% of the points now for the work already done. would love to push this over the line with your help. /award 375 |
Awarding ShreyasLakhani: 375 points 🕹️ Well done! Check out your new contribution on oss.gg/ShreyasLakhani |
@mfts Look at the changes I made.
|
/award 375 Thanks @ShreyasLakhani awarding the second half. will review tomorrow and then hopefully can merge it in |
Awarding ShreyasLakhani: 375 points 🕹️ Well done! Check out your new contribution on oss.gg/ShreyasLakhani |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please check @mfts
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@mfts can you give me any updates regarding this PR? |
Summary: This PR introduces the ability for teams to invite members using a unique share link, secured by UUIDs. Previously, team invitations were sent individually via email. This update enhances the invitation process. #1049
Added a new
inviteLink
field to the Team table in the databaseImplemented functionality to generate and reset the invite link
Created API endpoints for:
Updated the UI to display and manage the team invite link
The invite link is unique to each team
Team administrators can reset the link if needed
The existing functionality to invite users individually by email is preserved
Thoroughly tested the invite link functionality using Postman:
2024-10-20.13-37-44.mp4