@@ -15,41 +15,25 @@ export interface UserInfoProps {
15
15
domains : number ;
16
16
links : number ;
17
17
} [ ] ;
18
- impersonateUrl : string ;
18
+ impersonateUrl : {
19
+ app : string ;
20
+ partners : string ;
21
+ } ;
19
22
}
20
23
21
24
export default function UserInfo ( { data } : { data : UserInfoProps } ) {
22
- const [ copied , copyToClipboard ] = useCopyToClipboard ( ) ;
23
-
24
25
return (
25
- < >
26
- < div className = "flex w-full items-center space-x-3" >
27
- < input
28
- type = "email"
29
- name = "email"
30
- id = "email"
31
- value = { data . email }
32
- readOnly
33
- className = "w-full rounded-md border-gray-300 text-sm text-gray-900 placeholder-gray-400 focus:border-gray-500 focus:outline-none focus:ring-gray-500"
34
- />
35
- < button
36
- type = "button"
37
- onClick = { ( ) =>
38
- toast . promise ( copyToClipboard ( data . impersonateUrl ) , {
39
- success : "Copied to clipboard" ,
40
- } )
41
- }
42
- className = "rounded-md border border-gray-300 p-2"
43
- >
44
- { copied ? (
45
- < Tick className = "h-5 w-5 text-gray-500" />
46
- ) : (
47
- < Copy className = "h-5 w-5 text-gray-500" />
48
- ) }
49
- </ button >
50
- </ div >
26
+ < div className = "grid gap-2" >
27
+ < LoginLinkCopyButton
28
+ text = "app.dub.co login link"
29
+ url = { data . impersonateUrl . app }
30
+ />
31
+ < LoginLinkCopyButton
32
+ text = "partners.dub.co login link"
33
+ url = { data . impersonateUrl . partners }
34
+ />
51
35
{ Object . keys ( data . defaultDomainLinks ) . length > 0 && (
52
- < div className = "mt-2 grid divide-y divide-gray-200" >
36
+ < div className = "grid divide-y divide-gray-200" >
53
37
{ Object . entries ( data . defaultDomainLinks ) . map ( ( [ domain , count ] ) => (
54
38
< div key = { domain } className = "flex justify-between py-2" >
55
39
< div className = "flex items-center space-x-2" >
@@ -61,7 +45,7 @@ export default function UserInfo({ data }: { data: UserInfoProps }) {
61
45
) ) }
62
46
</ div >
63
47
) }
64
- < div className = "mt-2 grid grid-cols-2 gap-4" >
48
+ < div className = "grid grid-cols-2 gap-4" >
65
49
{ data . workspaces . map ( ( workspace ) => (
66
50
< div
67
51
key = { workspace . slug }
@@ -100,6 +84,33 @@ export default function UserInfo({ data }: { data: UserInfoProps }) {
100
84
</ div >
101
85
) ) }
102
86
</ div >
103
- </ >
87
+ </ div >
104
88
) ;
105
89
}
90
+
91
+ const LoginLinkCopyButton = ( { text, url } : { text : string ; url : string } ) => {
92
+ const [ copied , copyToClipboard ] = useCopyToClipboard ( ) ;
93
+
94
+ return (
95
+ < div className = "flex w-full items-center space-x-3" >
96
+ < div className = "w-full rounded-md border border-gray-300 px-4 py-2 text-sm text-gray-900" >
97
+ { text }
98
+ </ div >
99
+ < button
100
+ type = "button"
101
+ onClick = { ( ) =>
102
+ toast . promise ( copyToClipboard ( url ) , {
103
+ success : "Copied to clipboard" ,
104
+ } )
105
+ }
106
+ className = "rounded-md border border-gray-300 p-2"
107
+ >
108
+ { copied ? (
109
+ < Tick className = "h-5 w-5 text-gray-500" />
110
+ ) : (
111
+ < Copy className = "h-5 w-5 text-gray-500" />
112
+ ) }
113
+ </ button >
114
+ </ div >
115
+ ) ;
116
+ } ;
0 commit comments