Skip to content

Commit cff8163

Browse files
committed
fix: issue #1169
1 parent 290f1be commit cff8163

File tree

14 files changed

+1321
-180
lines changed

14 files changed

+1321
-180
lines changed

config/constants/development.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ module.exports = {
1818
TERMS_API_URL: `${DEV_API_HOSTNAME}/v5/terms`,
1919
RESOURCES_API_URL: `${DEV_API_HOSTNAME}/v5/resources`,
2020
RESOURCE_ROLES_API_URL: `${DEV_API_HOSTNAME}/v5/resource-roles`,
21+
SUBMISSIONS_API_URL: `${DEV_API_HOSTNAME}/v5/submissions`,
2122
PLATFORMS_V4_API_URL: `${DEV_API_HOSTNAME}/v4/platforms`,
2223
TECHNOLOGIES_V4_API_URL: `${DEV_API_HOSTNAME}/v4/technologies`,
24+
STUDIO_URL: `https://studio.${DOMAIN}`,
2325
CONNECT_APP_URL: `https://connect.${DOMAIN}`,
2426
DIRECT_PROJECT_URL: `https://www.${DOMAIN}/direct`,
2527
ONLINE_REVIEW_URL: `https://software.${DOMAIN}`,

config/constants/production.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,10 @@ module.exports = {
1818
TERMS_API_URL: `${PROD_API_HOSTNAME}/v5/terms`,
1919
RESOURCES_API_URL: `${PROD_API_HOSTNAME}/v5/resources`,
2020
RESOURCE_ROLES_API_URL: `${PROD_API_HOSTNAME}/v5/resource-roles`,
21+
SUBMISSIONS_API_URL: `${PROD_API_HOSTNAME}/v5/submissions`,
2122
PLATFORMS_V4_API_URL: `${PROD_API_HOSTNAME}/v4/platforms`,
2223
TECHNOLOGIES_V4_API_URL: `${PROD_API_HOSTNAME}/v4/technologies`,
24+
STUDIO_URL: `https://studio.${DOMAIN}`,
2325
CONNECT_APP_URL: `https://connect.${DOMAIN}`,
2426
DIRECT_PROJECT_URL: `https://www.${DOMAIN}/direct`,
2527
ONLINE_REVIEW_URL: `https://software.${DOMAIN}`,
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { fetchSubmissions } from '../services/challenges'
2+
3+
import { LOAD_CHALLENGE_SUBMISSIONS } from '../config/constants'
4+
5+
export function loadSubmissions (challengeId) {
6+
return dispatch => {
7+
if (challengeId) {
8+
dispatch({
9+
type: LOAD_CHALLENGE_SUBMISSIONS,
10+
payload: fetchSubmissions(challengeId)
11+
})
12+
}
13+
}
14+
}

src/assets/images/lock.svg

Lines changed: 9 additions & 0 deletions
Loading

src/components/ChallengeEditor/ChallengeViewTabs/ChallengeViewTabs.module.scss

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,44 @@
11
@import '../../../styles/includes';
22

3+
$tc-dark-blue: #0681ff;
4+
$tc-white: #FFFFFF;
5+
6+
7+
.challenge-view-selector {
8+
display: flex;
9+
flex-wrap: wrap;
10+
justify-content: center;
11+
position: relative;
12+
border-bottom: 1px solid silver;
13+
14+
@include xs-to-sm {
15+
flex-wrap: nowrap;
16+
justify-content: flex-start;
17+
overflow: auto;
18+
}
19+
20+
.challenge-selector-common {
21+
font-family: roboto, sans-serif;
22+
font-size: 13px;
23+
line-height: 30px;
24+
margin: 10px 20px 0;
25+
cursor: pointer;
26+
white-space: nowrap;
27+
}
28+
29+
.challenge-selected-view {
30+
font-weight: 700;
31+
color: $tc-dark-blue;
32+
border-bottom: 3px solid $tc-dark-blue;
33+
}
34+
35+
.challenge-unselected-view {
36+
font-weight: 400;
37+
color: $tc-gray-70;
38+
border-bottom: 3px hidden $tc-white;
39+
}
40+
}
41+
342
.list {
443
width: 100%;
544
display: flex;

src/components/ChallengeEditor/ChallengeViewTabs/index.js

Lines changed: 72 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,31 @@
33
*/
44
import React, { useState, useMemo } from 'react'
55
import PropTypes from 'prop-types'
6-
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'
6+
import cn from 'classnames'
7+
import _ from 'lodash'
78

89
import ChallengeViewComponent from '../ChallengeView'
910
import Registrants from '../Registrants'
11+
import Submissions from '../Submissions'
1012
import { getResourceRoleByName } from '../../../util/tc'
1113
import 'react-tabs/style/react-tabs.css'
1214
import styles from './ChallengeViewTabs.module.scss'
1315

16+
function getSelectorStyle (selectedView, currentView) {
17+
return cn(styles['challenge-selector-common'], {
18+
[styles['challenge-selected-view']]: selectedView === currentView,
19+
[styles['challenge-unselected-view']]: selectedView !== currentView
20+
})
21+
}
22+
1423
const ChallengeViewTabs = ({
1524
projectDetail,
1625
challenge,
1726
attachments,
1827
isBillingAccountExpired,
1928
metadata,
2029
challengeResources,
30+
challengeSubmissions,
2131
token,
2232
isLoading,
2333
challengeId,
@@ -38,23 +48,64 @@ const ChallengeViewTabs = ({
3848
}
3949
}, [metadata, challengeResources])
4050

51+
const submissions = useMemo(() => {
52+
return _.map(challengeSubmissions, s => {
53+
s.registrant = _.find(registrants, r => {
54+
return +r.memberId === s.memberId
55+
})
56+
return s
57+
})
58+
}, [challengeSubmissions, registrants])
4159
return (
4260
<div className={styles.list}>
43-
<Tabs
44-
selectedIndex={selectedTab}
45-
className={styles.tabsContainer}
46-
onSelect={index => {
47-
setSelectedTab(index)
48-
}}
49-
>
50-
<TabList>
51-
<Tab>DETAILS</Tab>
52-
<Tab>REGISTRANTS({registrants.length})</Tab>
53-
</TabList>
54-
<TabPanel />
55-
<TabPanel />
56-
<TabPanel />
57-
</Tabs>
61+
<div className={styles['challenge-view-selector']}>
62+
<a
63+
tabIndex='0'
64+
role='tab'
65+
aria-selected={selectedTab === 0}
66+
onClick={e => {
67+
setSelectedTab(0)
68+
}}
69+
onKeyPress={e => {
70+
setSelectedTab(0)
71+
}}
72+
className={getSelectorStyle(selectedTab, 0)}
73+
>
74+
DETAILS
75+
</a>
76+
{registrants.length ? (
77+
<a
78+
tabIndex='1'
79+
role='tab'
80+
aria-selected={selectedTab === 1}
81+
onClick={e => {
82+
setSelectedTab(1)
83+
}}
84+
onKeyPress={e => {
85+
setSelectedTab(1)
86+
}}
87+
className={getSelectorStyle(selectedTab, 1)}
88+
>
89+
REGISTRANTS ({registrants.length})
90+
</a>
91+
) : null}
92+
{challengeSubmissions.length ? (
93+
<a
94+
tabIndex='2'
95+
role='tab'
96+
aria-selected={selectedTab === 2}
97+
onClick={e => {
98+
setSelectedTab(2)
99+
}}
100+
onKeyPress={e => {
101+
setSelectedTab(2)
102+
}}
103+
className={getSelectorStyle(selectedTab, 2)}
104+
>
105+
SUBMISSIONS ({submissions.length})
106+
</a>
107+
) : null}
108+
</div>
58109
{selectedTab === 0 && (
59110
<ChallengeViewComponent
60111
isLoading={isLoading}
@@ -73,10 +124,10 @@ const ChallengeViewTabs = ({
73124
/>
74125
)}
75126
{selectedTab === 1 && (
76-
<Registrants
77-
challenge={challenge}
78-
registrants={registrants}
79-
/>
127+
<Registrants challenge={challenge} registrants={registrants} />
128+
)}
129+
{selectedTab === 2 && (
130+
<Submissions challenge={challenge} submissions={submissions} />
80131
)}
81132
</div>
82133
)
@@ -100,6 +151,7 @@ ChallengeViewTabs.propTypes = {
100151
isLoading: PropTypes.bool.isRequired,
101152
challengeId: PropTypes.string.isRequired,
102153
challengeResources: PropTypes.arrayOf(PropTypes.object),
154+
challengeSubmissions: PropTypes.arrayOf(PropTypes.object),
103155
assignedMemberDetails: PropTypes.shape(),
104156
enableEdit: PropTypes.bool,
105157
onLaunchChallenge: PropTypes.func,

src/components/ChallengeEditor/Registrants/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import PT from 'prop-types'
88
import moment from 'moment'
99
import _ from 'lodash'
1010
import cn from 'classnames'
11+
import { getTCMemberURL } from '../../../config/constants'
1112
import ReactSVG from 'react-svg'
1213
import { getRatingLevel, sortList } from '../../../util/tc'
1314
import styles from './Registrants.module.scss'
@@ -440,7 +441,7 @@ export default class Registrants extends React.Component {
440441
<div className={styles['col-3']}>
441442
<span role='cell'>
442443
<a
443-
href={`${window.origin}/members/${r.memberHandle}`}
444+
href={getTCMemberURL(r.memberHandle)}
444445

445446
className={cn({
446447
[styles[`level-${getRatingLevel(_.get(r, 'rating', 0))}`]]: !isDesign

0 commit comments

Comments
 (0)