-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6571 from topcoder-platform/reskin-tco-badge
TCO badges in member profile
- Loading branch information
Showing
23 changed files
with
513 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
import _ from 'lodash'; | ||
import challengeDetails from './challenge-details'; | ||
import memberProfile from './profile'; | ||
|
||
export default _.merge({}, challengeDetails); | ||
export default _.merge({}, challengeDetails, memberProfile); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/** | ||
* Actions for member profile page. | ||
*/ | ||
/* global fetch */ | ||
import { redux, config } from 'topcoder-react-utils'; | ||
|
||
/** | ||
* @static | ||
* @desc Initiates an action that fetch member's badges | ||
* @param {String} handle Member handle. | ||
* @return {Action} | ||
*/ | ||
async function getGamificationBadgesInit(handle) { | ||
return { handle }; | ||
} | ||
|
||
/** | ||
* @static | ||
* @desc Creates an action that gets member's badges | ||
* | ||
* @param {String} handle Topcoder member handle. | ||
* @return {Action} | ||
*/ | ||
async function getGamificationBadgesDone(handle) { | ||
try { | ||
const memberInfo = await fetch(`${config.API.V5}/members/${handle}`) | ||
.then(response => response.json()); | ||
const badges = await fetch(`${config.API.V5}/gamification/badges/assigned/${memberInfo.userId}?organization_id=${config.GAMIFICATION.ORG_ID}`) | ||
.then(response => response.json()); | ||
|
||
return { | ||
handle, | ||
badges, | ||
}; | ||
} catch (error) { | ||
return { | ||
handle, | ||
error, | ||
}; | ||
} | ||
} | ||
|
||
export default redux.createActions({ | ||
PAGE: { | ||
PROFILE: { | ||
GET_GAMIFICATION_BADGES_INIT: getGamificationBadgesInit, | ||
GET_GAMIFICATION_BADGES_DONE: getGamificationBadgesDone, | ||
}, | ||
}, | ||
}); |
39 changes: 39 additions & 0 deletions
39
src/shared/components/ProfilePage/Awards/AwardBadge/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import React from 'react'; | ||
import PT from 'prop-types'; | ||
import FallBackAwardIcon from 'assets/images/default-award.svg'; | ||
|
||
import './styles.scss'; | ||
|
||
const AwardBadge = ({ | ||
title, imageUrl, mimeType, onSelectBadge, | ||
}) => ( | ||
<div role="presentation" styleName="awardBadge" onClick={onSelectBadge}> | ||
{ | ||
imageUrl ? ( | ||
<img src={imageUrl} type={mimeType} alt="award-badge" styleName="image" /> | ||
) : ( | ||
<FallBackAwardIcon styleName="image" /> | ||
) | ||
} | ||
<div styleName="title"> | ||
<span> | ||
<div dangerouslySetInnerHTML={{ __html: title }} /> | ||
</span> | ||
</div> | ||
</div> | ||
); | ||
|
||
AwardBadge.defaultProps = { | ||
title: '', | ||
imageUrl: null, | ||
mimeType: 'image/svg+xml', | ||
}; | ||
|
||
AwardBadge.propTypes = { | ||
title: PT.string, | ||
imageUrl: PT.string, | ||
mimeType: PT.string, | ||
onSelectBadge: PT.func.isRequired, | ||
}; | ||
|
||
export default AwardBadge; |
32 changes: 32 additions & 0 deletions
32
src/shared/components/ProfilePage/Awards/AwardBadge/styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
@import "~styles/mixins"; | ||
|
||
.awardBadge { | ||
background-color: $tc-white; | ||
padding: 16px; | ||
border-radius: 8px; | ||
display: flex; | ||
cursor: pointer; | ||
|
||
.image { | ||
width: 48px; | ||
height: 48px; | ||
} | ||
|
||
.title { | ||
@include roboto-bold; | ||
$color: $tco-black; | ||
|
||
font-size: 14px; | ||
font-weight: 700; | ||
line-height: 16px; | ||
display: flex; | ||
flex-direction: column; | ||
justify-content: center; | ||
margin-left: 8px; | ||
max-width: 130px; | ||
|
||
@include xs-to-sm { | ||
max-width: unset; | ||
} | ||
} | ||
} |
50 changes: 50 additions & 0 deletions
50
src/shared/components/ProfilePage/Awards/AwardModal/index.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import React from 'react'; | ||
import PT from 'prop-types'; | ||
import FallBackAwardIcon from 'assets/images/default-award.svg'; | ||
|
||
import './styles.scss'; | ||
|
||
const AwatarModal = ({ | ||
modalData, | ||
}) => { | ||
const { | ||
title, description, imageUrl, | ||
} = modalData; | ||
|
||
return ( | ||
<div styleName="awardModal"> | ||
{ | ||
imageUrl ? ( | ||
<img src={imageUrl} alt="award-badge" styleName="image" /> | ||
) : ( | ||
<FallBackAwardIcon styleName="image" /> | ||
) | ||
} | ||
|
||
<div styleName="rightContent"> | ||
<div styleName="title"> | ||
<span>{title}</span> | ||
</div> | ||
|
||
<div styleName="description">{description}</div> | ||
|
||
</div> | ||
</div> | ||
); | ||
}; | ||
|
||
AwatarModal.defaultProps = { | ||
modalData: {}, | ||
}; | ||
|
||
AwatarModal.propTypes = { | ||
modalData: PT.shape( | ||
{ | ||
title: PT.string, | ||
description: PT.string, | ||
imageUrl: PT.string, | ||
}, | ||
), | ||
}; | ||
|
||
export default AwatarModal; |
58 changes: 58 additions & 0 deletions
58
src/shared/components/ProfilePage/Awards/AwardModal/styles.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
@import "~styles/mixins"; | ||
@import "~components/Contentful/brackets"; | ||
|
||
.awardModal { | ||
display: flex; | ||
margin-top: 48px; | ||
|
||
@include xs-to-md { | ||
flex-direction: column; | ||
margin-top: 24px; | ||
} | ||
|
||
.image { | ||
width: 100px; | ||
height: 100px; | ||
|
||
@include xs-to-md { | ||
display: block; | ||
margin: 0 auto; | ||
} | ||
} | ||
|
||
.rightContent { | ||
margin-left: 16px; | ||
display: flex; | ||
align-items: flex-start; | ||
justify-content: center; | ||
flex-direction: column; | ||
|
||
.title { | ||
@include roboto-bold; | ||
|
||
color: $tco-black; | ||
font-size: 20px; | ||
font-weight: 700; | ||
line-height: 26px; | ||
|
||
@include xs-to-md { | ||
text-align: center; | ||
} | ||
} | ||
|
||
.description { | ||
@include brackets-content; | ||
|
||
font-weight: 400; | ||
color: $tco-black; | ||
font-size: 16px; | ||
line-height: 24px; | ||
margin-top: 10px; | ||
} | ||
|
||
@include xs-to-md { | ||
margin-top: 24px; | ||
text-align: center; | ||
} | ||
} | ||
} |
Oops, something went wrong.