Skip to content

Commit 714edb0

Browse files
Merge pull request #2332 from nauhil/hot-fixes
The country value of Profile page get from lookup data
2 parents a341f81 + f5486cc commit 714edb0

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed

__tests__/shared/components/ProfilePage/__snapshots__/index.jsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ exports[`renders a full Profile correctly 1`] = `
2828
>
2929
<ProfileHeader
3030
copilot={true}
31-
country="United States"
31+
country=""
3232
info={
3333
Object {
3434
"competitionCountryCode": "USA",
@@ -631,7 +631,7 @@ exports[`renders an empty Profile correctly 1`] = `
631631
>
632632
<ProfileHeader
633633
copilot={false}
634-
country="United States"
634+
country=""
635635
info={
636636
Object {
637637
"competitionCountryCode": "USA",

src/shared/components/ProfilePage/index.jsx

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -112,12 +112,12 @@ class ProfilePage extends React.Component {
112112
const {
113113
achievements,
114114
copilot,
115-
country,
116115
externalAccounts,
117116
externalLinks,
118117
info,
119118
skills: propSkills,
120119
stats,
120+
lookupData,
121121
} = this.props;
122122

123123
const {
@@ -126,6 +126,17 @@ class ProfilePage extends React.Component {
126126
skillsExpanded,
127127
} = this.state;
128128

129+
// get country
130+
let country = '';
131+
if (_.has(lookupData, 'countries') && lookupData.countries.length > 0) {
132+
const countryCode = _.isEmpty(_.get(info, 'homeCountryCode'))
133+
? _.get(info, 'competitionCountryCode') : _.get(info, 'homeCountryCode');
134+
135+
const result = _.find(lookupData.countries,
136+
c => c.countryCode === countryCode.toUpperCase());
137+
country = _.isEmpty(result) ? '' : result.country;
138+
}
139+
129140
// Convert skills from object to an array for easier iteration
130141
let skills = propSkills ? _.map(propSkills, (skill, tagId) => ({ tagId, ...skill })) : [];
131142
const showMoreButton = skills.length > MAX_SKILLS;
@@ -286,12 +297,12 @@ ProfilePage.defaultProps = {
286297
ProfilePage.propTypes = {
287298
achievements: PT.arrayOf(PT.shape()),
288299
copilot: PT.bool.isRequired,
289-
country: PT.string.isRequired,
290300
externalAccounts: PT.shape().isRequired,
291301
externalLinks: PT.arrayOf(PT.shape()).isRequired,
292302
info: PT.shape().isRequired,
293303
skills: PT.shape(),
294304
stats: PT.shape(),
305+
lookupData: PT.shape().isRequired,
295306
};
296307

297308
export default ProfilePage;

src/shared/containers/Profile.jsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ ProfileContainer.propTypes = {
9393
profileForHandle: PT.string,
9494
skills: PT.shape(),
9595
stats: PT.shape(),
96+
lookupData: PT.shape().isRequired,
9697
};
9798

9899
const mapStateToProps = (state, ownProps) => ({
@@ -107,10 +108,12 @@ const mapStateToProps = (state, ownProps) => ({
107108
profileForHandle: state.profile.profileForHandle,
108109
skills: state.profile.skills,
109110
stats: state.profile.stats,
111+
lookupData: state.lookup,
110112
});
111113

112114
function mapDispatchToProps(dispatch) {
113115
const a = actions.profile;
116+
const lookupActions = actions.lookup;
114117
return {
115118
loadProfile: (handle) => {
116119
dispatch(a.clearProfile());
@@ -121,12 +124,14 @@ function mapDispatchToProps(dispatch) {
121124
dispatch(a.getInfoInit());
122125
dispatch(a.getSkillsInit());
123126
dispatch(a.getStatsInit());
127+
dispatch(lookupActions.getCountriesInit());
124128
dispatch(a.getAchievementsV3Done(handle));
125129
dispatch(a.getExternalAccountsDone(handle));
126130
dispatch(a.getExternalLinksDone(handle));
127131
dispatch(a.getInfoDone(handle));
128132
dispatch(a.getSkillsDone(handle));
129133
dispatch(a.getStatsDone(handle));
134+
dispatch(lookupActions.getCountriesDone());
130135
},
131136
};
132137
}

0 commit comments

Comments
 (0)