@@ -6,6 +6,7 @@ import React, { useState } from 'react';
6
6
import PT from 'prop-types' ;
7
7
import _ from 'lodash' ;
8
8
import { PrimaryButton } from 'topcoder-react-ui-kit' ;
9
+ import LoadingIndicator from 'components/LoadingIndicator' ;
9
10
import tc from 'components/buttons/themed/tc.scss' ;
10
11
import ReferralModal from '../ReferralModal' ;
11
12
import defautlStyle from './style.scss' ;
@@ -21,8 +22,9 @@ const buttonThemes = {
21
22
function ReferralCode ( props ) {
22
23
const { profile } = props ;
23
24
const [ loginModalOpen , setLoginModalOpen ] = useState ( false ) ;
25
+ const [ referralCode , setReferralCode ] = useState ( 'abcXYZ' ) ;
24
26
return (
25
- < div className = { defautlStyle . container } >
27
+ < div className = { _ . isEmpty ( profile ) ? defautlStyle . container : defautlStyle . containerWithLink } >
26
28
< span className = { defautlStyle . title } > Topcoder Referral Program:</ span >
27
29
{
28
30
_ . isEmpty ( profile ) ? (
@@ -46,14 +48,37 @@ function ReferralCode(props) {
46
48
onCloseButton = { ( ) => setLoginModalOpen ( false ) }
47
49
isReferrSucess = { false }
48
50
isReferrError = { false }
49
- onReferralDone = { ( ) => { } }
51
+ onReferralDone = { ( ) => { } }
50
52
/>
51
53
)
52
54
}
53
55
</ React . Fragment >
54
56
) : (
55
57
< React . Fragment >
56
58
< span > Your referral link:</ span >
59
+ {
60
+ referralCode ? (
61
+ < div className = { defautlStyle . rondedArea } >
62
+ < span > { `https://www.topcoder.com/gigs/${ referralCode } ` } </ span >
63
+ < PrimaryButton
64
+ onClick = { ( ) => {
65
+ const copyhelper = document . createElement ( 'input' ) ;
66
+ copyhelper . className = 'copyhelper' ;
67
+ document . body . appendChild ( copyhelper ) ;
68
+ copyhelper . value = `https://www.topcoder.com/gigs/${ referralCode } ` ;
69
+ copyhelper . select ( ) ;
70
+ document . execCommand ( 'copy' ) ;
71
+ document . body . removeChild ( copyhelper ) ;
72
+ } }
73
+ theme = { {
74
+ button : buttonThemes . tc [ 'primary-borderless-xs' ] ,
75
+ } }
76
+ >
77
+ COPY
78
+ </ PrimaryButton >
79
+ </ div >
80
+ ) : < LoadingIndicator />
81
+ }
57
82
</ React . Fragment >
58
83
)
59
84
}
0 commit comments