Skip to content

GAME-205 Feat/badges box -> dev #6711

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 22 commits into from
Nov 3, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
324cadf
Merge pull request #6596 from topcoder-platform/develop
luizrrodrigues Jul 29, 2022
6650c4f
Merge pull request #6601 from topcoder-platform/develop
luizrrodrigues Aug 5, 2022
6edc89a
Merge pull request #6606 from topcoder-platform/develop
luizrrodrigues Aug 11, 2022
129afc5
Merge pull request #6615 from topcoder-platform/develop
luizrrodrigues Aug 17, 2022
31ec364
Merge pull request #6622 from topcoder-platform/develop
luizrrodrigues Aug 24, 2022
0cc5dd8
Merge pull request #6625 from topcoder-platform/develop
luizrrodrigues Aug 29, 2022
f9eac9d
Merge pull request #6629 from topcoder-platform/develop
luizrrodrigues Aug 31, 2022
12b1a54
Merge pull request #6631 from topcoder-platform/develop
luizrrodrigues Sep 1, 2022
9ed1d9a
Merge pull request #6636 from topcoder-platform/develop
luizrrodrigues Sep 13, 2022
a573aec
Merge pull request #6637 from topcoder-platform/develop
luizrrodrigues Sep 15, 2022
bd11298
Merge pull request #6642 from topcoder-platform/develop
luizrrodrigues Sep 21, 2022
38ec31a
Merge pull request #6659 from topcoder-platform/develop
luizrrodrigues Oct 4, 2022
de5eec8
Merge pull request #6669 from topcoder-platform/develop
luizrrodrigues Oct 11, 2022
a038209
Merge pull request #6674 from topcoder-platform/develop
luizrrodrigues Oct 12, 2022
1064dfa
Merge pull request #6677 from topcoder-platform/develop
luizrrodrigues Oct 12, 2022
b2356d6
Merge pull request #6687 from topcoder-platform/develop
luizrrodrigues Oct 18, 2022
d21ec47
Merge pull request #6690 from topcoder-platform/develop
luizrrodrigues Oct 19, 2022
359612d
GAME-205 profile pages updates
kkartunov Oct 28, 2022
63113e9
ci: on test
kkartunov Oct 28, 2022
fa46579
up badges to 100
kkartunov Oct 31, 2022
e50b62b
add awardedAt date
kkartunov Nov 1, 2022
afe679d
ci: on QA env
kkartunov Nov 2, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ workflows:
filters:
branches:
only:
- feature/dice-setup
- feat/badges-box
# This is beta env for production soft releases
- "build-prod-beta":
context : org-global
Expand Down
4 changes: 2 additions & 2 deletions src/shared/actions/page/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@ async function getGamificationBadgesInit(handle) {
* @param {String} handle Topcoder member handle.
* @return {Action}
*/
async function getGamificationBadgesDone(handle) {
async function getGamificationBadgesDone(handle, limit) {
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}`)
const badges = await fetch(`${config.API.V5}/gamification/badges/assigned/${memberInfo.userId}?organization_id=${config.GAMIFICATION.ORG_ID}&limit=${limit || 4}`)
.then(response => response.json());

return {
Expand Down
120 changes: 120 additions & 0 deletions src/shared/components/ProfileBadgesPage/index.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
import React, { useState } from 'react';
import PT from 'prop-types';
import { Link } from 'react-router-dom';
import { get } from 'lodash';
import { Modal } from 'topcoder-react-ui-kit';
import IconClose from 'assets/images/tc-edu/icon-close-big.svg';
import FallBackAwardIcon from 'assets/images/default-award.svg';
import md from 'utils/markdown';
import { format } from 'date-fns';
import AwardModal from '../ProfilePage/Awards/AwardModal';

import style from './styles.scss';

const ProfileBadges = ({ badges, handleParam }) => {
const [showModal, setShowModal] = useState(false);
const [modalData, setModalData] = useState({});

return (
<div styleName="outer-container">
<Link
to={`/members/${handleParam}`}
styleName="memberPageBackLink"
>
<svg
xmlns="http://www.w3.org/2000/svg"
width="14"
height="12"
fill="none"
viewBox="0 0 14 12"
>
<path
fill="#137D60"
fillRule="evenodd"
d="M6.766 11.366a.8.8 0 01-1.132 0l-4.8-4.8a.8.8 0 010-1.132l4.8-4.8a.8.8 0 111.132 1.132L3.33 5.2h9.27a.8.8 0 010 1.6H3.33l3.435 3.434a.8.8 0 010 1.132z"
clipRule="evenodd"
/>
</svg>
Return to Profile
</Link>
<div styleName="badgesWrap">
<div styleName="seactionTitle">COMMUNITY AWARDS & HONORS</div>
<div styleName="badgesGrid">
{
badges.rows.map((reward) => {
const title = get(reward, 'org_badge.badge_name');
const imageUrl = get(reward, 'org_badge.badge_image_url');
let description = get(reward, 'org_badge.badge_description');
if (description) {
description = md(description);
}
let awardedAt = get(reward, 'awarded_at');
if (awardedAt) {
awardedAt = format(new Date(awardedAt), 'PPP');
}

return (
<div
role="presentation"
styleName="awardBadge"
onClick={() => {
setShowModal(true);
setModalData({
title,
description,
imageUrl,
awardedAt,
});
}}
>
{
imageUrl ? (
<img src={imageUrl} alt="award-badge" styleName="image" />
) : (
<FallBackAwardIcon styleName="image" />
)
}
<div styleName="title">
<span>
<div dangerouslySetInnerHTML={{ __html: title }} />
</span>
</div>
</div>
);
})
}
</div>
</div>
{
showModal && (
<Modal onCancel={() => setShowModal(false)} theme={style}>
<div styleName="award-modal">
<div styleName="header">
<h2 styleName="title">Community Awards & Honors</h2>
<div styleName="icon" role="presentation" onClick={() => setShowModal(false)}>
<IconClose />
</div>
</div>
<hr />

<AwardModal
modalData={modalData}
/>
</div>
</Modal>
)
}
</div>
);
};

ProfileBadges.defaultProps = {
badges: {},
};

ProfileBadges.propTypes = {
badges: PT.shape(),
handleParam: PT.string.isRequired,
};

export default ProfileBadges;
144 changes: 144 additions & 0 deletions src/shared/components/ProfileBadgesPage/styles.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
/* stylelint-disable no-descending-specificity */
@import "~styles/mixins";

.outer-container {
width: 100%;
max-width: $screen-max;
margin: 0 auto;
display: flex;
flex-direction: column;

@include xs-to-md {
margin: 0 32px;
}

.memberPageBackLink {
text-transform: uppercase;
color: $listing-checkbox-green;
font-weight: 700;
font-family: Roboto, sans-serif;
margin: 32px 0;
display: flex;
align-items: center;

svg {
margin-right: 6px;
}
}

.badgesWrap {
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
border-radius: 8px;
display: flex;
flex-direction: column;
padding: 32px;
margin-bottom: 32px;

.seactionTitle {
@include barlow-medium;

font-weight: 600;
color: #2a2a2a;
font-size: 22px;
line-height: 26px;
text-transform: uppercase;
padding-bottom: 24px;
border-bottom: 2px solid #e9e9e9;
}

.badgesGrid {
display: grid;
grid-template-columns: repeat(6, 1fr);

@include xs-to-sm {
grid-template-columns: repeat(2, 1fr);
}

@include md {
grid-template-columns: repeat(4, 1fr);
}

.awardBadge {
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
cursor: pointer;
padding-top: 32px;

.image {
width: 100px;
height: 100px;
}

.title {
@include roboto-bold;
$color: $tco-black;

font-size: 12px;
font-weight: 700;
line-height: 16px;
display: flex;
flex-direction: column;
justify-content: center;
text-align: center;
align-items: center;
max-width: 130px;
margin-top: 17px;
text-transform: uppercase;

@include xs-to-sm {
max-width: unset;
}
}
}
}
}
}

.award-modal {
padding-bottom: 10px;
border-radius: 8px;
margin: 25px 32px 32px;

.header {
display: flex;
justify-content: space-between;
margin-bottom: 25px;

.title {
@include barlow-medium;

font-weight: 600;
color: #2a2a2a;
font-size: 22px;
line-height: 26px;
text-transform: uppercase;
}

.icon {
cursor: pointer;
margin-top: 5px;
}
}
}

hr {
opacity: 0.5;
}

.container {
box-shadow: 0 1px 5px rgba(0, 0, 0, 0.2);
border-radius: 8px;
min-width: 600px;

@include xs-to-sm {
width: 90%;
min-width: unset;
}
}

.overlay {
background-color: #0c0c0c;
opacity: 0.85;
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
border-radius: 8px;
display: flex;
cursor: pointer;
min-width: 316px;

.image {
width: 48px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const AwatarModal = ({
modalData,
}) => {
const {
title, description, imageUrl,
title, description, imageUrl, awardedAt,
} = modalData;

return (
Expand All @@ -25,6 +25,9 @@ const AwatarModal = ({
<div styleName="title">
<span>{title}</span>
</div>
{
awardedAt && <div styleName="awardedAt">{`Awarded on ${awardedAt}`}</div>
}

<div styleName="description">{description}</div>

Expand All @@ -41,6 +44,7 @@ AwatarModal.propTypes = {
modalData: PT.shape(
{
title: PT.string,
awardedAt: PT.string,
description: PT.string,
imageUrl: PT.string,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@
justify-content: center;
flex-direction: column;

@include xs-to-md {
align-items: center;
}

.title {
@include roboto-bold;

Expand All @@ -40,14 +44,24 @@
}
}

.awardedAt {
@include roboto-bold;

color: $listing-placeholder-gray;
font-size: 12px;
line-height: 16px;
text-transform: uppercase;
margin-top: 8px;
}

.description {
@include brackets-content;

font-weight: 400;
color: $tco-black;
font-size: 16px;
line-height: 24px;
margin-top: 10px;
margin-top: 16px;
}

@include xs-to-md {
Expand Down
Loading