Skip to content

Commit 246b498

Browse files
Hide Submission tab if user not logged
1 parent 6987e6c commit 246b498

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

src/shared/components/challenge-detail/Header/TabSelector/index.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ function getSelectorStyle(selectedView, currentView) {
1919

2020
export default function ChallengeViewSelector(props) {
2121
const {
22+
isLoggedIn,
2223
challenge,
2324
checkpointCount,
2425
numOfRegistrants,
@@ -123,7 +124,7 @@ export default function ChallengeViewSelector(props) {
123124
)
124125
}
125126
{
126-
numOfSubmissions ? (
127+
(numOfSubmissions && isLoggedIn) ? (
127128
<a
128129
tabIndex="0"
129130
role="tab"
@@ -186,6 +187,7 @@ export default function ChallengeViewSelector(props) {
186187
}
187188

188189
ChallengeViewSelector.defaultProps = {
190+
isLoggedIn: false,
189191
challenge: {},
190192
checkpointCount: 0,
191193
numOfRegistrants: 0,
@@ -194,6 +196,7 @@ ChallengeViewSelector.defaultProps = {
194196
};
195197

196198
ChallengeViewSelector.propTypes = {
199+
isLoggedIn: PT.bool,
197200
challenge: PT.shape({
198201
subTrack: PT.any,
199202
details: PT.shape({

src/shared/components/challenge-detail/Header/index.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ const DAY_MS = 24 * HOUR_MS;
3434

3535
export default function ChallengeHeader(props) {
3636
const {
37+
isLoggedIn,
3738
challenge,
3839
challengesUrl,
3940
challengeTypes,
@@ -447,6 +448,7 @@ export default function ChallengeHeader(props) {
447448
}
448449
</div>
449450
<TabSelector
451+
isLoggedIn={isLoggedIn}
450452
challenge={challenge}
451453
onSelectorClicked={onSelectorClicked}
452454
trackLower={trackLower}
@@ -465,6 +467,7 @@ export default function ChallengeHeader(props) {
465467
}
466468

467469
ChallengeHeader.defaultProps = {
470+
isLoggedIn: false,
468471
checkpoints: {},
469472
isMenuOpened: false,
470473
hasThriveArticles: false,
@@ -473,6 +476,7 @@ ChallengeHeader.defaultProps = {
473476
};
474477

475478
ChallengeHeader.propTypes = {
479+
isLoggedIn: PT.bool,
476480
checkpoints: PT.shape(),
477481
challenge: PT.shape({
478482
id: PT.string.isRequired,

src/shared/containers/challenge-detail/index.jsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,8 @@ class ChallengeDetailPageContainer extends React.Component {
365365

366366
const submissionsViewable = _.find(metadata, { type: 'submissionsViewable' });
367367

368+
const isLoggedIn = !_.isEmpty(auth.tokenV3);
369+
368370
/* Generation of data for SEO meta-tags. */
369371
let prizesStr;
370372
if (challenge.prizes && challenge.prizes.length) {
@@ -445,6 +447,7 @@ class ChallengeDetailPageContainer extends React.Component {
445447
!isEmpty
446448
&& (
447449
<ChallengeHeader
450+
isLoggedIn={isLoggedIn}
448451
challenge={challenge}
449452
challengeId={challengeId}
450453
challengeTypes={challengeTypes}
@@ -523,7 +526,7 @@ class ChallengeDetailPageContainer extends React.Component {
523526
)
524527
}
525528
{
526-
!isEmpty && selectedTab === DETAIL_TABS.SUBMISSIONS
529+
!isEmpty && isLoggedIn && selectedTab === DETAIL_TABS.SUBMISSIONS
527530
&& (
528531
<Submissions
529532
challenge={challenge}

0 commit comments

Comments
 (0)