Skip to content

Fix challenge detail screen #5008

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
Show file tree
Hide file tree
Changes from 1 commit
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ export default function ChallengeTags(props) {
let EventTag;
let TrackTag;
switch (track) {
case COMPETITION_TRACKS.DATA_SCIENCE:
case COMPETITION_TRACKS.DS:
EventTag = DataScienceTrackEventTag;
TrackTag = DataScienceTrackTag;
break;
case COMPETITION_TRACKS.DESIGN:
case COMPETITION_TRACKS.DES:
EventTag = DesignTrackEventTag;
TrackTag = DesignTrackTag;
break;
case COMPETITION_TRACKS.DEVELOP:
case COMPETITION_TRACKS.DEV:
EventTag = DevelopmentTrackEventTag;
TrackTag = DevelopmentTrackTag;
break;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/components/challenge-detail/Header/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ export default function ChallengeHeader(props) {
<div styleName="tag-container">
<ChallengeTags
track={track}
challengeType={_.find(challengeTypesMap, { name: type }) || []}
challengeType={_.find(challengeTypesMap, { name: type }) || {}}
challengesUrl={challengesUrl}
events={eventNames}
technPlatforms={miscTags}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -360,15 +360,15 @@ SideBar.defaultProps = {
environment: '',
codeRepo: '',
isMM: false,
metadata: {},
metadata: [],
reviewScorecardId: '',
screeningScorecardId: '',
legacyId: '',
};

SideBar.propTypes = {
challengesUrl: PT.string.isRequired,
legacyId: PT.string,
legacyId: PT.oneOfType([PT.string, PT.number]),
eventDetail: PT.shape({
eventName: PT.string.isRequired,
description: PT.string.isRequired,
Expand All @@ -384,7 +384,7 @@ SideBar.propTypes = {
environment: PT.string,
codeRepo: PT.string,
isMM: PT.bool,
metadata: PT.shape(),
reviewScorecardId: PT.string,
metadata: PT.array,
reviewScorecardId: PT.oneOfType([PT.string, PT.number]),
screeningScorecardId: PT.string,
};
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ ChallengeDetailsView.defaultProps = {
environment: '',
descriptionFormat: 'HTML',
codeRepo: '',
metadata: {},
metadata: [],
events: [],
reviewScorecardId: '',
screeningScorecardId: '',
Expand All @@ -424,12 +424,12 @@ ChallengeDetailsView.propTypes = {
id: PT.any,
privateDescription: PT.string,
legacy: PT.shape({
reviewScorecardId: PT.string,
reviewScorecardId: PT.oneOfType([PT.string, PT.number]),
screeningScorecardId: PT.string,
forumId: PT.number,
}),
track: PT.string.isRequired,
legacyId: PT.string,
legacyId: PT.oneOfType([PT.string, PT.number]),
groups: PT.any,
reviewType: PT.string,
numberOfCheckpointsPrizes: PT.number,
Expand All @@ -439,7 +439,7 @@ ChallengeDetailsView.propTypes = {
userDetails: PT.shape({
roles: PT.arrayOf(PT.string).isRequired,
}),
metadata: PT.shape(),
metadata: PT.array,
events: PT.arrayOf(PT.string),
}),
challengesUrl: PT.string.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default function ThriveArticles({ articles }) {
<div
styleName="article-right"
style={{
backgroundImage: `url(${a.fields.featuredImage.file.url})`,
backgroundImage: `url(${a.fields.featuredImage ? a.fields.featuredImage.file.url : ''})`,
}}
/>
</div>
Expand Down
121 changes: 61 additions & 60 deletions src/shared/containers/challenge-detail/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ import MySubmissions from 'components/challenge-detail/MySubmissions';
import Winners from 'components/challenge-detail/Winners';
import ChallengeDetailsView from 'components/challenge-detail/Specification';
import RecommendedThriveArticles from 'components/challenge-detail/ThriveArticles';
import RecommendedActiveChallenges from 'components/challenge-detail/RecommendedActiveChallenges';
// eslint-disable-next-line max-len
// import RecommendedActiveChallenges from 'components/challenge-detail/RecommendedActiveChallenges';
import Terms from 'containers/Terms';
import termsActions from 'actions/terms';
import ChallengeCheckpoints from 'components/challenge-detail/Checkpoints';
Expand All @@ -36,10 +37,10 @@ import { CHALLENGE_PHASE_TYPES, COMPETITION_TRACKS_V3, SUBTRACKS } from 'utils/t
import { config, MetaTags } from 'topcoder-react-utils';
import { actions } from 'topcoder-react-lib';
import { getService } from 'services/contentful';
import {
getDisplayRecommendedChallenges,
getRecommendedTags,
} from 'utils/challenge-detail/helper';
// import {
// getDisplayRecommendedChallenges,
// getRecommendedTags,
// } from 'utils/challenge-detail/helper';

import ogWireframe from
'../../../assets/images/open-graph/challenges/01-wireframe.jpg';
Expand Down Expand Up @@ -200,11 +201,11 @@ class ChallengeDetailPageContainer extends React.Component {
const {
challengeId,
reloadChallengeDetails,
getAllRecommendedChallenges,
recommendedChallenges,
auth,
// getAllRecommendedChallenges,
// recommendedChallenges,
// auth,
challenge,
loadingRecommendedChallengesUUID,
// loadingRecommendedChallengesUUID,
history,
} = this.props;

Expand All @@ -213,21 +214,21 @@ class ChallengeDetailPageContainer extends React.Component {
history.push(history.location.pathname, history.state);
}

const recommendedTechnology = getRecommendedTags(challenge);
if (
challenge
&& challenge.id === challengeId
&& !loadingRecommendedChallengesUUID
&& (
!recommendedChallenges[recommendedTechnology]
|| (
Date.now() - recommendedChallenges[recommendedTechnology].lastUpdateOfActiveChallenges
> 10 * MIN
)
)
) {
getAllRecommendedChallenges(auth.tokenV3, recommendedTechnology);
}
// const recommendedTechnology = getRecommendedTags(challenge);
// if (
// challenge
// && challenge.id === challengeId
// && !loadingRecommendedChallengesUUID
// && (
// !recommendedChallenges[recommendedTechnology]
// || (
// Date.now() - recommendedChallenges[recommendedTechnology].lastUpdateOfActiveChallenges
// > 10 * MIN
// )
// )
// ) {
// getAllRecommendedChallenges(auth.tokenV3, recommendedTechnology);
// }

const { thriveArticles } = this.state;
const userId = _.get(this, 'props.auth.user.userId');
Expand All @@ -251,9 +252,9 @@ class ChallengeDetailPageContainer extends React.Component {
}).then((content) => {
// format image file data
_.forEach(content.Article.items, (item) => {
const asset = _.find(content.Article.includes.Asset,
a => a.sys.id === item.fields.featuredImage.sys.id);
_.assign(item.fields.featuredImage, { file: asset.fields.file });
// eslint-disable-next-line max-len
const asset = _.find(content.Article.includes.Asset, a => item.fields.featuredImage !== null && a.sys.id === item.fields.featuredImage.sys.id);
if (asset) _.assign(item.fields.featuredImage, { file: asset.fields.file });
});
this.setState({
thriveArticles: content.Article.items,
Expand Down Expand Up @@ -326,20 +327,20 @@ class ChallengeDetailPageContainer extends React.Component {
isLoadingSubmissionInformation,
submissionInformation,
loadSubmissionInformation,
selectChallengeDetailsTab,
prizeMode,
recommendedChallenges,
expandedTags,
expandTag,
// selectChallengeDetailsTab,
// prizeMode,
// recommendedChallenges,
// expandedTags,
// expandTag,
mySubmissions,
reviewTypes,
} = this.props;

const displayRecommendedChallenges = getDisplayRecommendedChallenges(
challenge,
recommendedChallenges,
auth,
);
// const displayRecommendedChallenges = getDisplayRecommendedChallenges(
// challenge,
// recommendedChallenges,
// auth,
// );

const {
thriveArticles,
Expand Down Expand Up @@ -451,7 +452,7 @@ class ChallengeDetailPageContainer extends React.Component {
registerForChallenge={this.registerForChallenge}
registering={registering}
selectedView={selectedTab}
hasRecommendedChallenges={displayRecommendedChallenges.length > 0}
// hasRecommendedChallenges={displayRecommendedChallenges.length > 0}
hasThriveArticles={thriveArticles.length > 0}
setChallengeListingFilter={setChallengeListingFilter}
unregisterFromChallenge={() => unregisterFromChallenge(auth, challengeId)
Expand Down Expand Up @@ -590,7 +591,7 @@ class ChallengeDetailPageContainer extends React.Component {
}}
/>
)}
{
{/* {
!isEmpty && displayRecommendedChallenges.length ? (
<RecommendedActiveChallenges
challenges={displayRecommendedChallenges}
Expand All @@ -604,7 +605,7 @@ class ChallengeDetailPageContainer extends React.Component {
isLoggedIn={isLoggedIn}
/>
) : null
}
} */}
{
!isEmpty && thriveArticles.length ? (
<RecommendedThriveArticles articles={thriveArticles} />
Expand Down Expand Up @@ -635,7 +636,7 @@ ChallengeDetailPageContainer.defaultProps = {
mySubmissions: [],
isLoadingSubmissionInformation: false,
submissionInformation: null,
prizeMode: 'money-usd',
// prizeMode: 'money-usd',
};

ChallengeDetailPageContainer.propTypes = {
Expand All @@ -648,7 +649,7 @@ ChallengeDetailPageContainer.propTypes = {
checkpointResults: PT.arrayOf(PT.shape()),
checkpointResultsUi: PT.shape().isRequired,
checkpoints: PT.shape(),
recommendedChallenges: PT.shape().isRequired,
// recommendedChallenges: PT.shape().isRequired,
communityId: PT.string,
communitiesList: PT.shape({
data: PT.arrayOf(PT.object).isRequired,
Expand Down Expand Up @@ -692,12 +693,12 @@ ChallengeDetailPageContainer.propTypes = {
isLoadingSubmissionInformation: PT.bool,
submissionInformation: PT.shape(),
loadSubmissionInformation: PT.func.isRequired,
selectChallengeDetailsTab: PT.func.isRequired,
getAllRecommendedChallenges: PT.func.isRequired,
prizeMode: PT.string,
expandedTags: PT.arrayOf(PT.number).isRequired,
expandTag: PT.func.isRequired,
loadingRecommendedChallengesUUID: PT.string.isRequired,
// selectChallengeDetailsTab: PT.func.isRequired,
// getAllRecommendedChallenges: PT.func.isRequired,
// prizeMode: PT.string,
// expandedTags: PT.arrayOf(PT.number).isRequired,
// expandTag: PT.func.isRequired,
// loadingRecommendedChallengesUUID: PT.string.isRequired,
history: PT.shape().isRequired,
};

Expand Down Expand Up @@ -765,8 +766,8 @@ function mapStateToProps(state, props) {
auth: state.auth,
challenge,
challengeTypes: cl.challengeTypes,
recommendedChallenges: cl.recommendedChallenges,
loadingRecommendedChallengesUUID: cl.loadingRecommendedChallengesUUID,
// recommendedChallenges: cl.recommendedChallenges,
// loadingRecommendedChallengesUUID: cl.loadingRecommendedChallengesUUID,
expandedTags: cl.expandedTags,
challengeId: String(props.match.params.challengeId),
challengesUrl: props.challengesUrl,
Expand Down Expand Up @@ -811,16 +812,16 @@ const mapDispatchToProps = (dispatch) => {
const ca = communityActions.tcCommunity;
const lookupActions = actions.lookup;
return {
getAllRecommendedChallenges: (tokenV3, recommendedTechnology) => {
const uuid = shortId();
const cl = challengeListingActions.challengeListing;
dispatch(cl.getAllRecommendedChallengesInit(uuid));
dispatch(
cl.getAllRecommendedChallengesDone(
uuid, tokenV3, recommendedTechnology,
),
);
},
// getAllRecommendedChallenges: (tokenV3, recommendedTechnology) => {
// const uuid = shortId();
// const cl = challengeListingActions.challengeListing;
// dispatch(cl.getAllRecommendedChallengesInit(uuid));
// dispatch(
// cl.getAllRecommendedChallengesDone(
// uuid, tokenV3, recommendedTechnology,
// ),
// );
// },
getCommunitiesList: (auth) => {
const uuid = shortId();
dispatch(ca.getListInit(uuid));
Expand Down