@@ -7,9 +7,10 @@ import UserForm from "@flanksource-ui/components/Users/UserForm";
77import { SearchLayout } from "@flanksource-ui/ui/Layout/SearchLayout" ;
88import { useQuery } from "@tanstack/react-query" ;
99import { useRef , useState } from "react" ;
10+ import { FaCopy } from "react-icons/fa" ;
1011import { ImUserPlus } from "react-icons/im" ;
1112import { getRegisteredUsers } from "../api/services/users" ;
12- import { Modal } from "../components" ;
13+ import { Button , Modal } from "../components" ;
1314import { AuthorizationAccessCheck } from "../components/Permissions/AuthorizationAccessCheck" ;
1415import { toastError , toastSuccess } from "../components/Toast/toast" ;
1516import { UserList } from "../components/Users/UserList" ;
@@ -25,6 +26,7 @@ export function UsersPage() {
2526 const [ isOpen , setIsOpen ] = useState ( false ) ;
2627 const [ editUser , setEditUser ] = useState < RegisteredUser > ( ) ;
2728 const containerRef = useRef < HTMLDivElement > ( null ) ;
29+ const [ inviteLink , setInviteLink ] = useState < string > ( ) ;
2830
2931 const {
3032 isLoading,
@@ -41,10 +43,10 @@ export function UsersPage() {
4143 } ) ;
4244
4345 const { mutate : inviteUserFunction , isLoading : isInviting } = useInviteUser ( {
44- onSuccess : ( ) => {
46+ onSuccess : ( data ) => {
4547 refetch ( ) ;
46- toastSuccess ( `user invited successfully` ) ;
4748 setIsOpen ( false ) ;
49+ setInviteLink ( data . link ) ;
4850 } ,
4951 onError : ( error ) => {
5052 toastError ( error . message ) ;
@@ -146,6 +148,48 @@ export function UsersPage() {
146148 />
147149 </ Modal >
148150
151+ { inviteLink && (
152+ < Modal
153+ title = "Invite Link"
154+ onClose = { ( ) => {
155+ setInviteLink ( undefined ) ;
156+ } }
157+ open = { ! ! inviteLink }
158+ bodyClass = ""
159+ >
160+ < div className = "flex flex-col gap-2 bg-white p-4 text-sm" >
161+ < p >
162+ User has been invited successfully. Please share the link with
163+ the user.
164+ </ p >
165+ < div className = "relative flex flex-col space-y-4 py-3 text-blue-500" >
166+ < Button
167+ className = "btn-white absolute right-0 top-0 whitespace-pre-line bg-white text-black"
168+ onClick = { ( ) => {
169+ navigator . clipboard . writeText ( inviteLink ! ) ;
170+ toastSuccess ( "Link copied to clipboard" ) ;
171+ } }
172+ title = "Copy Invite Link"
173+ >
174+ < FaCopy />
175+ </ Button >
176+
177+ { inviteLink }
178+ </ div >
179+ < div className = "flex flex-row justify-end gap-2" >
180+ < Button
181+ className = "btn-white"
182+ onClick = { ( ) => {
183+ setInviteLink ( undefined ) ;
184+ } }
185+ >
186+ Close
187+ </ Button >
188+ </ div >
189+ </ div >
190+ </ Modal >
191+ ) }
192+
149193 { editUser && (
150194 < Modal
151195 title = "Edit User"
0 commit comments