Skip to content

Commit 65e0814

Browse files
authored
social links fix (#545)
1 parent 3b8de03 commit 65e0814

File tree

2 files changed

+51
-12
lines changed

2 files changed

+51
-12
lines changed

src/user/profile/popups/EditProfile.js

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class EditProfile extends Component {
1414
location: '',
1515
github: '',
1616
fb: '',
17-
linkedIn: '',
17+
linkedin: '',
18+
twitter: '',
1819
designation: '',
1920
website: '',
2021
longDesc: '',
@@ -29,7 +30,18 @@ class EditProfile extends Component {
2930

3031
onSave = (e) => {
3132
e.preventDefault();
32-
const { firstName, lastName, designation, location, website, shortDesc, longDesc } = this.state
33+
const {
34+
firstName,
35+
lastName,
36+
designation,
37+
location,
38+
website,
39+
shortDesc,
40+
longDesc,
41+
github,
42+
linkedin,
43+
twitter
44+
} = this.state
3345
const info = {
3446
name: {
3547
firstName,
@@ -43,6 +55,11 @@ class EditProfile extends Component {
4355
location,
4456
website
4557
}
58+
},
59+
socialMedia: {
60+
github,
61+
linkedin,
62+
twitter
4663
}
4764
}
4865
console.log('Updating data!', this.state)
@@ -54,6 +71,7 @@ class EditProfile extends Component {
5471
const { userProfile } = nextProps.user
5572
const permissions = nextProps?.org?.org?.options?.permissions
5673
const about = userProfile?.info?.about
74+
const { socialMedia } = userProfile
5775
this.setState({
5876
firstName: userProfile?.name?.firstName,
5977
lastName: userProfile?.name?.lastName,
@@ -63,7 +81,10 @@ class EditProfile extends Component {
6381
shortDesc: about?.shortDescription,
6482
location: about?.location,
6583
// canChangeEmail: permissions?.canChangeEmail,
66-
canChangeName: permissions?.canChangeName
84+
canChangeName: permissions?.canChangeName,
85+
github: socialMedia?.github,
86+
twitter: socialMedia?.twitter,
87+
linkedin: socialMedia?.linkedin
6788
}, () => {
6889
console.log('updated state ', this.state)
6990
})
@@ -79,8 +100,10 @@ class EditProfile extends Component {
79100
designation,
80101
website,
81102
longDesc,
82-
canChangeName
83-
// canChangeEmail
103+
canChangeName,
104+
// canChangeEmail,
105+
github,
106+
linkedin,
84107
} = this.state
85108
return (
86109
<Modal onHide={onHide} show={show} className="modal">
@@ -191,7 +214,7 @@ class EditProfile extends Component {
191214
</Form.Group>
192215
</Form.Row>
193216
<div className="modal__secondary-title">PROFILE</div>
194-
{/* <Form.Row className="modal__row">
217+
<Form.Row className="modal__row">
195218
<Form.Group
196219
as={Col}
197220
controlId="formGridGithub"
@@ -216,12 +239,12 @@ class EditProfile extends Component {
216239
<Form.Control
217240
type="text"
218241
placeholder="LinkedIn URL"
219-
defaultValue={linkedIn}
242+
defaultValue={linkedin}
220243
name="linkedIn"
221244
onChange={this.onChange}
222245
/>
223246
</Form.Group>
224-
</Form.Row> */}
247+
</Form.Row>
225248
<Form.Row className="modal__row">
226249
<Form.Group
227250
as={Col}

src/user/profile/user-info/user-info.js

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,49 @@ class UserInfo extends Component {
1616
designation: '',
1717
location: '',
1818
shortDesc: '',
19-
website: ''
19+
website: '',
20+
github: '',
21+
twitter: '',
22+
linkedin: '',
23+
facebook: ''
2024
}
2125
}
2226

2327
componentWillReceiveProps(nextProps) {
2428
console.log('nextProps ', nextProps.userProfile)
2529
const name = nextProps.userProfile?.name || "NA"
2630
const about = nextProps.userProfile?.info?.about;
31+
const { socialMedia } = nextProps.userProfile
2732
this.setState({
2833
name: `${name?.firstName + " " + name?.lastName}`,
2934
designation: about?.designation,
3035
shortDesc: about?.shortDescription,
3136
location: about?.location,
32-
website: about?.website
37+
website: about?.website,
38+
github: socialMedia?.github,
39+
twitter: socialMedia?.twitter,
40+
linkedin: socialMedia?.linkedin,
41+
facebook: socialMedia?.facebook
3342
})
3443
}
3544

3645
onFbClick = () => {
3746
// this.props.history.push()
47+
this.state.facebook
48+
? window.open(`${this.state.facebook}`, '_blank')
49+
: window.location.href = '/profile'
3850
}
3951

4052
onLinkedInClick = () => {
41-
53+
this.state.linkedin
54+
? window.open(`${this.state.linkedin}`, '_blank')
55+
: window.location.href = '/profile'
4256
}
4357

4458
onGithubClick = () => {
45-
59+
this.state.github
60+
? window.open(`${this.state.github}`, '_blank')
61+
: window.location.href = '/profile'
4662
}
4763

4864
render() {

0 commit comments

Comments
 (0)