Skip to content

Commit e1a82bd

Browse files
committed
add logged state
1 parent f79c12a commit e1a82bd

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

src/shared/components/Gigs/ReferralCode/index.jsx

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import React, { useState } from 'react';
66
import PT from 'prop-types';
77
import _ from 'lodash';
88
import { PrimaryButton } from 'topcoder-react-ui-kit';
9+
import LoadingIndicator from 'components/LoadingIndicator';
910
import tc from 'components/buttons/themed/tc.scss';
1011
import ReferralModal from '../ReferralModal';
1112
import defautlStyle from './style.scss';
@@ -21,8 +22,9 @@ const buttonThemes = {
2122
function ReferralCode(props) {
2223
const { profile } = props;
2324
const [loginModalOpen, setLoginModalOpen] = useState(false);
25+
const [referralCode, setReferralCode] = useState('abcXYZ');
2426
return (
25-
<div className={defautlStyle.container}>
27+
<div className={_.isEmpty(profile) ? defautlStyle.container : defautlStyle.containerWithLink}>
2628
<span className={defautlStyle.title}>Topcoder Referral Program:</span>
2729
{
2830
_.isEmpty(profile) ? (
@@ -46,14 +48,37 @@ function ReferralCode(props) {
4648
onCloseButton={() => setLoginModalOpen(false)}
4749
isReferrSucess={false}
4850
isReferrError={false}
49-
onReferralDone={() => {}}
51+
onReferralDone={() => { }}
5052
/>
5153
)
5254
}
5355
</React.Fragment>
5456
) : (
5557
<React.Fragment>
5658
<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+
}
5782
</React.Fragment>
5883
)
5984
}

src/shared/components/Gigs/ReferralCode/style.scss

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
.container {
1+
.container,
2+
.containerWithLink {
23
display: flex;
34
background-image: linear-gradient(97.21deg, #2984BD 0%, #0AB88A 100%);
45
border-radius: 10px;
@@ -26,4 +27,23 @@
2627
margin-left: 10px !important;
2728
}
2829
}
30+
31+
.rondedArea {
32+
border: 1px solid rgba(255,255,255,0.4);
33+
border-radius: 2px;
34+
height: 35px;
35+
display: flex;
36+
align-items: center;
37+
padding: 0 12px;
38+
}
39+
}
40+
41+
.containerWithLink {
42+
padding: 10px 25px 9px;
43+
44+
svg {
45+
width: 34px;
46+
height: 34px;
47+
margin: initial;
48+
}
2949
}

0 commit comments

Comments
 (0)