Skip to content

update my dashboard page #4577

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 all commits
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 @@ -35,12 +35,18 @@ function normalizeSubTrackTagForRendering(subTrack) {
return _.startCase(_.toLower(x));
}

function normalizeSubTrack(subTrack) {
const type = _.upperCase(subTrack);
return type.replace(/ /g, '_');
}

export default function ChallengeCard({
challenge,
selectChallengeDetailsTab,
setChallengeListingFilter,
// unregisterFromChallenge,
userResources,
challengeSubtracksMap,
}) {
const {
phases,
Expand All @@ -51,6 +57,8 @@ export default function ChallengeCard({
type,
} = challenge;

const subTrackId = _.findKey(challengeSubtracksMap, { abbreviation: normalizeSubTrack(type) });

const { track } = legacy;

let EventTag;
Expand Down Expand Up @@ -100,15 +108,14 @@ export default function ChallengeCard({
const submitted = _.get(userDetails, 'hasUserSubmittedForReview');
const nextPhase = phases && _.last(phases);

const submissionPhase = _.find(phases, { name: 'Submission' });
const nextPhaseType = _.get(nextPhase, 'phaseType');

if (submitted && _.intersection(nextPhaseType, [
'Appeals',
'Appeal Response',
]).length) showOrLink = true;

const submissionOpen = moment(submissionPhase.scheduledEndDate).isSameOrAfter(new Date());
const isChallengeOpen = status === 'Active';

const allPhases = phases || [];
let statusPhase = allPhases
Expand Down Expand Up @@ -141,12 +148,12 @@ export default function ChallengeCard({
<EventTag
onClick={
() => setImmediate(
() => setChallengeListingFilter({ subtracks: [type] }),
() => setChallengeListingFilter({ subtracks: [subTrackId] }),
)
}
theme={{ button: style.tag }}
to={`/challenges?filter[subtracks][0]=${
encodeURIComponent(type)}`}
encodeURIComponent(subTrackId)}`}
>
{normalizeSubTrackTagForRendering(type)}
</EventTag>
Expand Down Expand Up @@ -222,7 +229,7 @@ export default function ChallengeCard({
) : null
}
{
submitter && submissionOpen ? (
submitter && isChallengeOpen ? (
<Button
size="sm"
theme={{ button: style.button }}
Expand Down Expand Up @@ -278,4 +285,5 @@ ChallengeCard.propTypes = {
setChallengeListingFilter: PT.func.isRequired,
// unregisterFromChallenge: PT.func.isRequired,
userResources: PT.arrayOf(PT.shape()),
challengeSubtracksMap: PT.shape().isRequired,
};
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export default function Challenges({
switchShowChallengeFilter,
unregisterFromChallenge,
userResources,
challengeSubtracksMap,
}) {
if (challengesLoading) {
return (
Expand Down Expand Up @@ -76,6 +77,7 @@ export default function Challenges({
setChallengeListingFilter={setChallengeListingFilter}
unregisterFromChallenge={unregisterFromChallenge}
userResources={userResources}
challengeSubtracksMap={challengeSubtracksMap}
/>
))
) : (
Expand Down Expand Up @@ -163,4 +165,5 @@ Challenges.propTypes = {
switchShowChallengeFilter: PT.func.isRequired,
unregisterFromChallenge: PT.func.isRequired,
userResources: PT.arrayOf(PT.shape()),
challengeSubtracksMap: PT.shape().isRequired,
};
3 changes: 3 additions & 0 deletions src/shared/components/Dashboard/CurrentActivity/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ export default class MyChallenges extends React.Component {
unregisterFromChallenge,
userGroups,
userResources,
challengeSubtracksMap,
} = this.props;

const myCommunities = communities.filter(x => _.intersection(userGroups, x.groupIds).length)
Expand Down Expand Up @@ -107,6 +108,7 @@ export default class MyChallenges extends React.Component {
switchShowChallengeFilter={switchShowChallengeFilter}
unregisterFromChallenge={unregisterFromChallenge}
userResources={userResources}
challengeSubtracksMap={challengeSubtracksMap}
/>
) : null
}
Expand Down Expand Up @@ -156,4 +158,5 @@ MyChallenges.propTypes = {
unregisterFromChallenge: PT.func.isRequired,
userGroups: PT.arrayOf(PT.string).isRequired,
userResources: PT.arrayOf(PT.shape()),
challengeSubtracksMap: PT.shape().isRequired,
};
3 changes: 3 additions & 0 deletions src/shared/components/Dashboard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export default function Dashboard({
xlBadge,
// errorLoadingRss,
userResources,
challengeSubtracksMap,
}) {
return (
<div styleName="container">
Expand Down Expand Up @@ -83,6 +84,7 @@ export default function Dashboard({
unregisterFromChallenge={unregisterFromChallenge}
userGroups={userGroups}
userResources={userResources}
challengeSubtracksMap={challengeSubtracksMap}
/>
{/* {!errorLoadingRss && (
<CommunityBlog isLoading={tcBlogLoading} posts={tcBlogPosts} />
Expand Down Expand Up @@ -130,4 +132,5 @@ Dashboard.propTypes = {
xlBadge: PT.string.isRequired,
// errorLoadingRss: PT.bool.isRequired,
userResources: PT.arrayOf(PT.shape()),
challengeSubtracksMap: PT.shape().isRequired,
};
15 changes: 15 additions & 0 deletions src/shared/containers/Dashboard/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ export class DashboardPageContainer extends React.Component {
xlBadge,
errorLoadingRss,
userResources,
challengeSubtracksMap,
getTypes,
} = this.props;

// console.log('r', userResources);
Expand All @@ -204,6 +206,10 @@ export class DashboardPageContainer extends React.Component {
({ announcementPreviewId } = qs.parse(urlQuery));
}

if (_.isEmpty(challengeSubtracksMap)) {
getTypes();
}

return (
<Dashboard
achievements={achievements}
Expand Down Expand Up @@ -238,6 +244,7 @@ export class DashboardPageContainer extends React.Component {
xlBadge={xlBadge}
errorLoadingRss={errorLoadingRss}
userResources={userResources ? userResources.resources : []}
challengeSubtracksMap={challengeSubtracksMap}
/>
);
}
Expand Down Expand Up @@ -314,6 +321,8 @@ DashboardPageContainer.propTypes = {
errorLoadingRss: PT.bool,
getMemberResources: PT.func.isRequired,
userResources: PT.shape(),
challengeSubtracksMap: PT.shape().isRequired,
getTypes: PT.func.isRequired,
};

function mapStateToProps(state, props) {
Expand Down Expand Up @@ -370,6 +379,7 @@ function mapStateToProps(state, props) {
xlBadge: dash.xlBadge,
errorLoadingRss: state.rss.errorLoadingRss,
userResources: state.members.userResources,
challengeSubtracksMap: state.challengeListing.challengeSubtracksMap,
};
}

Expand Down Expand Up @@ -448,6 +458,11 @@ function mapDispatchToProps(dispatch) {
dispatch(a.unregisterInit());
dispatch(a.unregisterDone(auth, challengeId));
},
getTypes: () => {
const cl = challengeListingActions.challengeListing;
dispatch(cl.getChallengeTypesInit());
dispatch(cl.getChallengeTypesDone());
},
};
}

Expand Down