1
1
import React , { useContext , useState } from 'react'
2
2
import Info from '@mui/icons-material/Info'
3
+ import LinkIcon from '@mui/icons-material/Link'
4
+ import PublicIcon from '@mui/icons-material/Public'
5
+ import { Button , Paper , Stack , Typography } from '@mui/material'
3
6
import { useTranslation } from 'react-i18next'
4
7
import { loginPage , sidInfoPage } from 'frontend/helpers'
5
8
import './index.css'
@@ -11,16 +14,24 @@ interface Props {
11
14
}
12
15
13
16
export default function SIDLogin ( { backdropClick } : Props ) {
17
+ const epicLoginUrl = 'https://legendary.gl/epiclogin'
18
+
14
19
const { epic } = useContext ( ContextProvider )
15
20
const { t } = useTranslation ( 'login' )
16
21
const [ input , setInput ] = useState ( '' )
17
22
const [ status , setStatus ] = useState ( {
18
23
loading : false ,
19
24
message : ''
20
25
} )
26
+ const [ linkCopied , setLinkCopied ] = useState ( false )
21
27
22
28
const { loading, message } = status
23
29
30
+ const handleCopyLink = ( ) => {
31
+ window . api . clipboardWriteText ( epicLoginUrl )
32
+ setLinkCopied ( true )
33
+ }
34
+
24
35
const handleLogin = async ( sid : string ) => {
25
36
await epic . login ( sid ) . then ( async ( res ) => {
26
37
setStatus ( {
@@ -67,6 +78,33 @@ export default function SIDLogin({ backdropClick }: Props) {
67
78
className = "material-icons"
68
79
/>
69
80
</ span >
81
+ < Paper variant = "outlined" className = "login-link" >
82
+ < Typography variant = "subtitle1" paddingLeft = { 2 } >
83
+ { epicLoginUrl }
84
+ </ Typography >
85
+ < Stack direction = "row" spacing = { 1 } >
86
+ < Button
87
+ className = {
88
+ linkCopied ? 'icon-button-success' : 'icon-button'
89
+ }
90
+ onClick = { handleCopyLink }
91
+ endIcon = { < LinkIcon fontSize = "small" /> }
92
+ variant = "outlined"
93
+ size = "small"
94
+ >
95
+ { linkCopied ? t ( 'button.copied' ) : t ( 'button.copy' ) }
96
+ </ Button >
97
+ < Button
98
+ className = "icon-button"
99
+ endIcon = { < PublicIcon fontSize = "small" /> }
100
+ onClick = { ( ) => loginPage ( ) }
101
+ size = "small"
102
+ variant = "outlined"
103
+ >
104
+ { t ( 'button.open' ) }
105
+ </ Button >
106
+ </ Stack >
107
+ </ Paper >
70
108
</ li >
71
109
< li >
72
110
{ `${ t ( 'message.part6' ) } ` }
0 commit comments