From 2215a6935608ab49ea2ad6f6a9232be5dec5953a Mon Sep 17 00:00:00 2001 From: Shouvik Roy Date: Mon, 3 Apr 2017 00:01:03 +0530 Subject: [PATCH 1/6] Lazy load winners on hover --- .../UserAvatarTooltip/UserAvatarTooltip.jsx | 6 +- .../ChallengeStatus/ChallengeStatus.jsx | 256 +++++++++++++----- 2 files changed, 191 insertions(+), 71 deletions(-) diff --git a/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx b/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx index bdddf59a0..00fc6bd98 100644 --- a/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx +++ b/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx @@ -30,8 +30,10 @@ function Tip(props) { )); return (
- User avatar + User avatar
{props.user.handle}
+ {/* Below block is commented out as it's not possible to get this information + // as of now.
{props.user.country}  / 257 wins  @@ -40,7 +42,7 @@ function Tip(props) {

Ratings

{rating} -
+
*/}
); } diff --git a/components/ChallengeStatus/ChallengeStatus.jsx b/components/ChallengeStatus/ChallengeStatus.jsx index 114e54a03..4fe868892 100644 --- a/components/ChallengeStatus/ChallengeStatus.jsx +++ b/components/ChallengeStatus/ChallengeStatus.jsx @@ -1,4 +1,4 @@ -import React from 'react'; +import React, { Component, PropTypes } from 'react'; import LeaderboardAvatar from '../LeaderboardAvatar/LeaderboardAvatar'; import ChallengeProgressBar from '../ChallengeProgressBar/ChallengeProgressBar'; import ProgressBarTooltip from '../ChallengeCard/Tooltips/ProgressBarTooltip'; @@ -8,6 +8,7 @@ import Tooltip from '../ChallengeCard/Tooltips/Tooltip'; import UserAvatarTooltip from '../ChallengeCard/Tooltips/UserAvatarTooltip'; import ForumIcon from '../Icons/ForumIcon'; import moment from 'moment'; +import _ from 'lodash'; import './ChallengeStatus.scss'; // Constants @@ -39,6 +40,10 @@ let MOCK_WINNERS = [ const MAX_VISIBLE_WINNERS = 3 const FORUM_URL = 'https://apps.topcoder.com/forums/?module=Category&categoryID=' const CHALLENGE_URL = 'https://www.topcoder.com/challenge-details/' +const DEV_CHALLENGE_DETAILS_API = 'https://api.topcoder.com/v2/develop/challenges/' +const DES_CHALLENGE_DETAILS_API = 'https://api.topcoder.com/v2/design/challenges/result/' +const DS_CHALLENGE_DETAILS_API = '' +const MOCK_PHOTO = 'https://acrobatusers.com/assets/images/template/author_generic.jpg' const STALLED_MSG = 'Stalled' const STALLED_TIME_LEFT_MSG = 'Challenge is currently on hold' const FF_TIME_LEFT_MSG = 'Winner is working on fixes' @@ -78,29 +83,149 @@ const getTimeLeft = (date, currentPhase) => { } } +function numRegistrantsTipText(number) { + switch (number) { + case 0: return 'No registrants'; + case 1: return '1 total registrant'; + default: return `${number} total registrants`; + } +} + +function numSubmissionsTipText(number) { + switch (number) { + case 0: return 'No submissions'; + case 1: return '1 total submission'; + default: return `${number} total submissions`; + } +} +const registrantsLink = (challenge, type) => { + if(challenge.track === 'DATA_SCIENCE') { + const id = challenge.challengeId + ''; + if(id.length < ID_LENGTH) { + return `${type}${challenge.challengeId}`; + } else { + return `${CHALLENGE_URL}${challenge.challengeId}/?type=develop#viewRegistrant`; + } + } else { + return `${CHALLENGE_URL}${challenge.challengeId}/?type=${challenge.track.toLowerCase()}#viewRegistrant`; + } +} + +const getStatusPhase = ( challenge ) => { + switch (challenge.currentPhaseName) { + case 'Registration': + return { + currentPhaseName: 'Submission', + currentPhaseEndDate: challenge.submissionEndDate + } + default: + return { + currentPhaseName: challenge.currentPhaseName, + currentPhaseEndDate: challenge.currentPhaseEndDate + } + } +} + const getTimeToGo = (start, end) => { const percentageComplete = (moment() - moment(start)) / (moment(end) - moment(start)) * 100 return (Math.round(percentageComplete * 100) / 100) } -function ChallengeStatus ({challenge, config, sampleWinnerProfile}) { - const lastItem = { - handle: `+${MOCK_WINNERS.length - MAX_VISIBLE_WINNERS}` +function getDevelopmentWinners(challengeId) { + return new Promise((resolve, reject) => { + fetch(`${DEV_CHALLENGE_DETAILS_API}${challengeId}`) + .then(res => res.json()) + .then(data => { + const winners = data.submissions.filter(submission => submission.placement < 4) + .map(winner => ({ + handle: winner.handle, + position: winner.placement, + photoURL: MOCK_PHOTO + })); + const uniqeWinners = _.uniqWith(winners, _.isEqual); + resolve(uniqeWinners); + }) + .catch(err => reject(err)); + }); +} + +function getDesignWinners(challengeId) { + return new Promise((resolve, reject) => { + fetch(`${DES_CHALLENGE_DETAILS_API}${challengeId}`) + .then(res => res.json()) + .then(data => { + const winners = data.results.filter(submission => submission.placement <=3) + .map(winner => ({ + handle: winner.handle, + position: winner.placement, + photoURL: MOCK_PHOTO + })); + resolve(winners); + }) + .catch(err => reject(err)); + }); +} + +/** + * TODO + * Return a list of winners given the challenge ID for a + * Data Science challenge. + * @param {String} challengeId + */ +function getDataScienceWinners(challengeId) { + +} + +/** + * Returns an user profile object as expected by the UserAvatarTooltip + * @param {String} handle + */ +function getSampleProfile(user) { + const { handle } = user; + return { + handle, + country: '', + memberSince: '', + photoLink: `i/m/${handle}.jpeg`, + ratingSummary: [], } - MOCK_WINNERS = MOCK_WINNERS.slice(0, MAX_VISIBLE_WINNERS) - MOCK_WINNERS.push(lastItem) +} - const renderLeaderboard = MOCK_WINNERS.map((winner) => { - return ( -
- - - -
- ) - }) - const renderRegisterButton = () => { +class ChallengeStatus extends Component { + constructor(props) { + super(props); + const {challenge, config, sampleWinnerProfile} = props; + const lastItem = { + handle: `+${MOCK_WINNERS.length - MAX_VISIBLE_WINNERS}` + } + MOCK_WINNERS = MOCK_WINNERS.slice(0, MAX_VISIBLE_WINNERS); + MOCK_WINNERS.push(lastItem); + this.state = { + winners: '' + }; + this.handleHover = this.handleHover.bind(this); + } + + renderLeaderboard() { + const { challenge, sampleWinnerProfile } = this.props; + const leaderboard = this.state.winners && this.state.winners.map((winner) => { + + return ( +
+ + + +
+ ) + }); + return leaderboard || ( + + Winners + ); + } + + renderRegisterButton(challenge) { const lng = getTimeLeft(challenge.registrationEndDate || challenge.submissionEndDate, challenge.currentPhaseName).text.length return ( @@ -110,52 +235,11 @@ function ChallengeStatus ({challenge, config, sampleWinnerProfile}) { ) } - function numRegistrantsTipText(number) { - switch (number) { - case 0: return 'No registrants'; - case 1: return '1 total registrant'; - default: return `${number} total registrants`; - } - } - - function numSubmissionsTipText(number) { - switch (number) { - case 0: return 'No submissions'; - case 1: return '1 total submission'; - default: return `${number} total submissions`; - } - } - const registrantsLink = (challenge, type) => { - if(challenge.track === 'DATA_SCIENCE') { - const id = challenge.challengeId + ''; - if(id.length < ID_LENGTH) { - return `${type}${challenge.challengeId}`; - } else { - return `${CHALLENGE_URL}${challenge.challengeId}/?type=develop#viewRegistrant`; - } - } else { - return `${CHALLENGE_URL}${challenge.challengeId}/?type=${challenge.track.toLowerCase()}#viewRegistrant`; - } - } - const getStatusPhase = () => { - switch (challenge.currentPhaseName) { - case 'Registration': - return { - currentPhaseName: 'Submission', - currentPhaseEndDate: challenge.submissionEndDate - } - default: - return { - currentPhaseName: challenge.currentPhaseName, - currentPhaseEndDate: challenge.currentPhaseEndDate - } - } - } - - const activeChallenge = () => { + activeChallenge() { + const { challenge, config } = this.props; return (
- {challenge.currentPhaseName ? getStatusPhase().currentPhaseName : STALLED_MSG} + {challenge.currentPhaseName ? getStatusPhase(challenge).currentPhaseName : STALLED_MSG} @@ -185,24 +269,25 @@ function ChallengeStatus ({challenge, config, sampleWinnerProfile}) { challenge.status === 'Active' ?
-
{getTimeLeft(getStatusPhase().currentPhaseEndDate, getStatusPhase().currentPhaseName).text}
+
{getTimeLeft(getStatusPhase(challenge).currentPhaseEndDate, getStatusPhase(challenge).currentPhaseName).text}
: } - {challenge.registrationOpen === 'Yes' && renderRegisterButton()} + {challenge.registrationOpen === 'Yes' && this.renderRegisterButton(challenge)}
) } - const completedChallenge = () => { + completedChallenge() { + const { challenge } = this.props; return (
- {renderLeaderboard} + {this.renderLeaderboard()} @@ -229,13 +314,46 @@ function ChallengeStatus ({challenge, config, sampleWinnerProfile}) { ) } - const status = challenge.status === 'Completed' ? "completed" : ""; + getWinners(challengeType, challengeId) { + switch (challengeType) { + case 'develop': + return getDevelopmentWinners(challengeId); + case 'data': + return getDataScienceWinners(challengeId); + case 'design': + return getDesignWinners(challengeId); + } + return getDevelopmentWinners(challengeId); + } + + /** + * Get the list of winners when the user hovers + * over the status + */ + handleHover() { + if (!this.state.winners) { + const { challenge } = this.props; + const { challengeId, challengeCommunity } = challenge; + + // We don't have the API for data science challenge + if (challengeCommunity.toLowerCase() === 'data') { + return; + } + const results = this.getWinners(challengeCommunity.toLowerCase(), challengeId); + results.then(winners => this.setState({ winners })); + } + } + render() { + const { challenge } = this.props; + const status = challenge.status === 'Completed' ? "completed" : ""; return (
- {challenge.status === 'Completed' ? completedChallenge() : activeChallenge()} + {challenge.status === 'Completed' ? this.completedChallenge() : this.activeChallenge()}
- ) + ) + } + } export default ChallengeStatus; From a091690d7c2af53aff62201e0f02331ffb05f843 Mon Sep 17 00:00:00 2001 From: Shouvik Roy Date: Mon, 3 Apr 2017 03:21:49 +0530 Subject: [PATCH 2/6] Use API url from props --- .../Tooltips/Tooltip/Tooltip.jsx | 1 + .../UserAvatarTooltip/UserAvatarTooltip.jsx | 43 +++++-- .../ChallengeStatus/ChallengeStatus.jsx | 121 +++++++++--------- 3 files changed, 92 insertions(+), 73 deletions(-) diff --git a/components/ChallengeCard/Tooltips/Tooltip/Tooltip.jsx b/components/ChallengeCard/Tooltips/Tooltip/Tooltip.jsx index 0ce0a87f2..43f1c653a 100644 --- a/components/ChallengeCard/Tooltips/Tooltip/Tooltip.jsx +++ b/components/ChallengeCard/Tooltips/Tooltip/Tooltip.jsx @@ -44,6 +44,7 @@ class Tooltip extends React.Component { render() { return ( this.showTooltip()} onMouseEnter={() => this.showTooltip()} onMouseLeave={() => this.hideTooltip()} ref={(node) => { this.wrapper = node; }} diff --git a/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx b/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx index 00fc6bd98..36de2b9a1 100644 --- a/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx +++ b/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx @@ -7,11 +7,12 @@ * the 'user' prop. */ -import React, { PropTypes as PT } from 'react'; +import React, { Component, PropTypes as PT } from 'react'; import moment from 'moment'; import Tooltip from '../Tooltip'; import './UserAvatarTooltip.scss'; +const MOCK_PHOTO = 'https://acrobatusers.com/assets/images/template/author_generic.jpg' /** * Renders the tooltip's content. * It includes: user profile picture, handle, his country and the TC registration @@ -28,9 +29,17 @@ function Tip(props) { {item.rating} )); + const { photoLink } = props.user; + const src = photoLink.startsWith('https') ? photoLink : `https://topcoder.com/${photoLink}`; + return (
- User avatar + User avatar
{props.user.handle}
{/* Below block is commented out as it's not possible to get this information // as of now. @@ -48,6 +57,7 @@ function Tip(props) { } Tip.propTypes = { + handleError: PT.func.isRequired, user: PT.shape({ country: PT.string, handle: PT.string, @@ -60,13 +70,28 @@ Tip.propTypes = { /** * Renders the tooltip. */ -function UserAvatarTooltip(props) { - const tip = ; - return ( - - {props.children} - - ); +class UserAvatarTooltip extends Component { + constructor(props) { + super(props); + this.state = { + user: props.user, + }; + this.handleError = this.handleError.bind(this); + } + handleError() { + const user = this.state.user; + user.photoLink = MOCK_PHOTO; + this.setState({ user }); + } + + render() { + const tip = ; + return ( + + {this.props.children} + + ); + } } UserAvatarTooltip.defaultProps = { diff --git a/components/ChallengeStatus/ChallengeStatus.jsx b/components/ChallengeStatus/ChallengeStatus.jsx index 4fe868892..5b08f8244 100644 --- a/components/ChallengeStatus/ChallengeStatus.jsx +++ b/components/ChallengeStatus/ChallengeStatus.jsx @@ -40,8 +40,7 @@ let MOCK_WINNERS = [ const MAX_VISIBLE_WINNERS = 3 const FORUM_URL = 'https://apps.topcoder.com/forums/?module=Category&categoryID=' const CHALLENGE_URL = 'https://www.topcoder.com/challenge-details/' -const DEV_CHALLENGE_DETAILS_API = 'https://api.topcoder.com/v2/develop/challenges/' -const DES_CHALLENGE_DETAILS_API = 'https://api.topcoder.com/v2/design/challenges/result/' +const DS_CHALLENGE_URL = 'https://community.topcoder.com/longcontest/stats/?module=ViewOverview&rd=' const DS_CHALLENGE_DETAILS_API = '' const MOCK_PHOTO = 'https://acrobatusers.com/assets/images/template/author_generic.jpg' const STALLED_MSG = 'Stalled' @@ -131,50 +130,7 @@ const getTimeToGo = (start, end) => { return (Math.round(percentageComplete * 100) / 100) } -function getDevelopmentWinners(challengeId) { - return new Promise((resolve, reject) => { - fetch(`${DEV_CHALLENGE_DETAILS_API}${challengeId}`) - .then(res => res.json()) - .then(data => { - const winners = data.submissions.filter(submission => submission.placement < 4) - .map(winner => ({ - handle: winner.handle, - position: winner.placement, - photoURL: MOCK_PHOTO - })); - const uniqeWinners = _.uniqWith(winners, _.isEqual); - resolve(uniqeWinners); - }) - .catch(err => reject(err)); - }); -} - -function getDesignWinners(challengeId) { - return new Promise((resolve, reject) => { - fetch(`${DES_CHALLENGE_DETAILS_API}${challengeId}`) - .then(res => res.json()) - .then(data => { - const winners = data.results.filter(submission => submission.placement <=3) - .map(winner => ({ - handle: winner.handle, - position: winner.placement, - photoURL: MOCK_PHOTO - })); - resolve(winners); - }) - .catch(err => reject(err)); - }); -} - -/** - * TODO - * Return a list of winners given the challenge ID for a - * Data Science challenge. - * @param {String} challengeId - */ -function getDataScienceWinners(challengeId) { -} /** * Returns an user profile object as expected by the UserAvatarTooltip @@ -198,30 +154,33 @@ class ChallengeStatus extends Component { const {challenge, config, sampleWinnerProfile} = props; const lastItem = { handle: `+${MOCK_WINNERS.length - MAX_VISIBLE_WINNERS}` - } + }; MOCK_WINNERS = MOCK_WINNERS.slice(0, MAX_VISIBLE_WINNERS); MOCK_WINNERS.push(lastItem); this.state = { - winners: '' + winners: '', }; this.handleHover = this.handleHover.bind(this); - } + this.getDevelopmentWinners = this.getDevelopmentWinners.bind(this); + this.getDesignWinners = this.getDesignWinners.bind(this); + } renderLeaderboard() { - const { challenge, sampleWinnerProfile } = this.props; + const { challenge } = this.props; + const { challengeId, challengeCommunity } = challenge; + const challengeURL = challengeCommunity.toLowerCase() == 'data' ? DS_CHALLENGE_URL : CHALLENGE_URL; const leaderboard = this.state.winners && this.state.winners.map((winner) => { - return (
- ) + ); }); return leaderboard || ( -
Winners + Winners ); } @@ -314,16 +273,50 @@ class ChallengeStatus extends Component { ) } + getDevelopmentWinners(challengeId) { + return new Promise((resolve, reject) => { + fetch(`${this.props.config.API_URL_V2}/develop/challenges/${challengeId}`) + .then(res => res.json()) + .then((data) => { + const winners = data.submissions.filter(submission => submission.placement && submission.placement < 4) + .map(winner => ({ + handle: winner.handle, + position: winner.placement, + photoURL: MOCK_PHOTO, + })); + const uniqeWinners = _.uniqWith(winners, _.isEqual); + resolve(uniqeWinners); + }) + .catch(err => reject(err)); + }); + } + + getDesignWinners(challengeId) { + return new Promise((resolve, reject) => { + fetch(`${this.props.config.API_URL_V2}/design/challenges/result/${challengeId}`) + .then(res => res.json()) + .then(data => { + const winners = data.results.filter(submission => submission.placement && submission.placement < 4) + .map(winner => ({ + handle: winner.handle, + position: winner.placement, + photoURL: MOCK_PHOTO, + })); + resolve(winners); + }) + .catch(err => reject(err)); + }); + } + + getWinners(challengeType, challengeId) { switch (challengeType) { case 'develop': - return getDevelopmentWinners(challengeId); - case 'data': - return getDataScienceWinners(challengeId); + return this.getDevelopmentWinners(challengeId); case 'design': - return getDesignWinners(challengeId); + return this.getDesignWinners(challengeId); } - return getDevelopmentWinners(challengeId); + return this.getDevelopmentWinners(challengeId); } /** @@ -345,13 +338,13 @@ class ChallengeStatus extends Component { } render() { - const { challenge } = this.props; - const status = challenge.status === 'Completed' ? "completed" : ""; - return ( -
- {challenge.status === 'Completed' ? this.completedChallenge() : this.activeChallenge()} -
- ) + const { challenge } = this.props; + const status = challenge.status === 'Completed' ? "completed" : ""; + return ( +
+ {challenge.status === 'Completed' ? this.completedChallenge() : this.activeChallenge()} +
+ ); } } From 17f9463af203bbc4f571a9e7fac8d86318a68e9b Mon Sep 17 00:00:00 2001 From: Shouvik Roy Date: Tue, 4 Apr 2017 22:47:52 +0530 Subject: [PATCH 3/6] Display last item only if more than 3 winners are present --- .../ChallengeStatus/ChallengeStatus.jsx | 24 +++++++++++-------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/components/ChallengeStatus/ChallengeStatus.jsx b/components/ChallengeStatus/ChallengeStatus.jsx index 69cb5b8af..0d1f4f566 100644 --- a/components/ChallengeStatus/ChallengeStatus.jsx +++ b/components/ChallengeStatus/ChallengeStatus.jsx @@ -328,11 +328,13 @@ class ChallengeStatus extends Component { photoURL: MOCK_PHOTO, })); winners = _.uniqWith(winners, _.isEqual); - const lastItem = { - handle: `+${winners.length - MAX_VISIBLE_WINNERS}`, - }; - winners = winners.slice(0, MAX_VISIBLE_WINNERS); - winners.push(lastItem); + if (winners.length > MAX_VISIBLE_WINNERS) { + const lastItem = { + handle: `+${winners.length - MAX_VISIBLE_WINNERS}`, + }; + winners = winners.slice(0, MAX_VISIBLE_WINNERS); + winners.push(lastItem); + } resolve(winners); }) .catch(err => reject(err)); @@ -351,11 +353,13 @@ class ChallengeStatus extends Component { photoURL: MOCK_PHOTO, })); winners = _.uniqWith(winners, _.isEqual); - const lastItem = { - handle: `+${winners.length - MAX_VISIBLE_WINNERS}`, - }; - winners = winners.slice(0, MAX_VISIBLE_WINNERS); - winners.push(lastItem); + if (winners.length > MAX_VISIBLE_WINNERS) { + const lastItem = { + handle: `+${winners.length - MAX_VISIBLE_WINNERS}`, + }; + winners = winners.slice(0, MAX_VISIBLE_WINNERS); + winners.push(lastItem); + } resolve(winners); }) .catch(err => reject(err)); From f2253a6e74befba7ff0a2b93ee064c222ab28b40 Mon Sep 17 00:00:00 2001 From: Shouvik Roy Date: Tue, 4 Apr 2017 23:08:25 +0530 Subject: [PATCH 4/6] Fix lint errors --- .../Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx | 6 +++--- components/ChallengeStatus/ChallengeStatus.jsx | 10 +++++----- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx b/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx index 36de2b9a1..3ea3186e3 100644 --- a/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx +++ b/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx @@ -12,7 +12,7 @@ import moment from 'moment'; import Tooltip from '../Tooltip'; import './UserAvatarTooltip.scss'; -const MOCK_PHOTO = 'https://acrobatusers.com/assets/images/template/author_generic.jpg' +const MOCK_PHOTO = 'https://acrobatusers.com/assets/images/template/author_generic.jpg'; /** * Renders the tooltip's content. * It includes: user profile picture, handle, his country and the TC registration @@ -22,13 +22,13 @@ const MOCK_PHOTO = 'https://acrobatusers.com/assets/images/template/author_gener * efficient way to query those. */ function Tip(props) { - const joined = moment(props.user.memberSince).format('MMM YYYY'); + /* const joined = moment(props.user.memberSince).format('MMM YYYY'); const rating = props.user.ratingSummary.map(item => ( {item.name} {item.rating} - )); + ));*/ const { photoLink } = props.user; const src = photoLink.startsWith('https') ? photoLink : `https://topcoder.com/${photoLink}`; diff --git a/components/ChallengeStatus/ChallengeStatus.jsx b/components/ChallengeStatus/ChallengeStatus.jsx index 0d1f4f566..306051e59 100644 --- a/components/ChallengeStatus/ChallengeStatus.jsx +++ b/components/ChallengeStatus/ChallengeStatus.jsx @@ -38,12 +38,12 @@ const getTimeLeft = (date, currentPhase) => { const d = duration.days(); const m = duration.minutes(); const late = (d < 0 || h < 0 || m < 0); - const suffix = h != 0 ? 'h' : 'min'; + const suffix = h !== 0 ? 'h' : 'min'; let text = ''; - if (d != 0) text += `${Math.abs(d)}d `; - if (h != 0) text += `${Math.abs(h)}`; - if (h != 0 && m != 0) text += ':'; - if (m != 0) text += `${Math.abs(m)}`; + if (d !== 0) text += `${Math.abs(d)}d `; + if (h !== 0) text += `${Math.abs(h)}`; + if (h !== 0 && m !== 0) text += ':'; + if (m !== 0) text += `${Math.abs(m)}`; text += suffix; if (late) { text = `Late by ${text}`; From d0f0fc4b9590f7e40f698a3c7c9c959843064e89 Mon Sep 17 00:00:00 2001 From: Shouvik Roy Date: Tue, 4 Apr 2017 23:13:38 +0530 Subject: [PATCH 5/6] Fix unused import lint error --- .../Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx b/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx index 3ea3186e3..e7b3bc3b8 100644 --- a/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx +++ b/components/ChallengeCard/Tooltips/UserAvatarTooltip/UserAvatarTooltip.jsx @@ -8,7 +8,7 @@ */ import React, { Component, PropTypes as PT } from 'react'; -import moment from 'moment'; +// import moment from 'moment'; import Tooltip from '../Tooltip'; import './UserAvatarTooltip.scss'; From d359a2fdc7f95ce27b1889f960755e9caf0babbd Mon Sep 17 00:00:00 2001 From: Shouvik Roy Date: Wed, 5 Apr 2017 03:25:26 +0530 Subject: [PATCH 6/6] Fix lint error default myFilter to false --- components/SideBarFilters/FilterItems/FilterItems.jsx | 1 + 1 file changed, 1 insertion(+) diff --git a/components/SideBarFilters/FilterItems/FilterItems.jsx b/components/SideBarFilters/FilterItems/FilterItems.jsx index f1c641cde..2df48226b 100644 --- a/components/SideBarFilters/FilterItems/FilterItems.jsx +++ b/components/SideBarFilters/FilterItems/FilterItems.jsx @@ -75,6 +75,7 @@ function FilterItem(props) { FilterItem.defaultProps = { highlighted: false, onClick: _.noop, + myFilter: false, }; FilterItem.propTypes = {