Skip to content

Commit 0dbb53d

Browse files
authored
Merge pull request #1185 from yoution/issue-1166
fix: issue #1166
2 parents 51c2948 + 1a44896 commit 0dbb53d

File tree

8 files changed

+1083
-2
lines changed

8 files changed

+1083
-2
lines changed

src/assets/images/arrow-down.svg

Lines changed: 19 additions & 0 deletions
Loading

src/assets/images/check-mark.svg

Lines changed: 9 additions & 0 deletions
Loading
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
@import '../../../styles/includes';
2+
3+
.list {
4+
width: 100%;
5+
display: flex;
6+
flex-direction: column;
7+
justify-content: space-between;
8+
}
9+
10+
11+
.tabsContainer {
12+
ul {
13+
margin: 0;
14+
}
15+
16+
:global {
17+
.react-tabs__tab--selected {
18+
background: $light-bg;
19+
20+
&:focus::after {
21+
background: $light-bg;
22+
}
23+
}
24+
}
25+
}
Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
/**
2+
* Component to render tabs in challenge view page
3+
*/
4+
import React, { useState, useMemo } from 'react'
5+
import PropTypes from 'prop-types'
6+
import { Tab, Tabs, TabList, TabPanel } from 'react-tabs'
7+
8+
import ChallengeViewComponent from '../ChallengeView'
9+
import Registrants from '../Registrants'
10+
import { getResourceRoleByName } from '../../../util/tc'
11+
import 'react-tabs/style/react-tabs.css'
12+
import styles from './ChallengeViewTabs.module.scss'
13+
14+
const ChallengeViewTabs = ({
15+
projectDetail,
16+
challenge,
17+
attachments,
18+
isBillingAccountExpired,
19+
metadata,
20+
challengeResources,
21+
token,
22+
isLoading,
23+
challengeId,
24+
assignedMemberDetails,
25+
enableEdit,
26+
onLaunchChallenge,
27+
onCloseTask
28+
}) => {
29+
const [selectedTab, setSelectedTab] = useState(0)
30+
31+
const registrants = useMemo(() => {
32+
const { resourceRoles } = metadata
33+
const role = getResourceRoleByName(resourceRoles, 'Submitter')
34+
if (role && challengeResources) {
35+
return challengeResources.filter(resource => resource.roleId === role.id)
36+
} else {
37+
return []
38+
}
39+
}, [metadata, challengeResources])
40+
41+
return (
42+
<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>
58+
{selectedTab === 0 && (
59+
<ChallengeViewComponent
60+
isLoading={isLoading}
61+
isBillingAccountExpired={isBillingAccountExpired}
62+
metadata={metadata}
63+
projectDetail={projectDetail}
64+
challenge={challenge}
65+
attachments={attachments}
66+
challengeResources={challengeResources}
67+
token={token}
68+
challengeId={challengeId}
69+
assignedMemberDetails={assignedMemberDetails}
70+
enableEdit={enableEdit}
71+
onLaunchChallenge={onLaunchChallenge}
72+
onCloseTask={onCloseTask}
73+
/>
74+
)}
75+
{selectedTab === 1 && (
76+
<Registrants
77+
challenge={challenge}
78+
registrants={registrants}
79+
/>
80+
)}
81+
</div>
82+
)
83+
}
84+
85+
ChallengeViewTabs.defaultProps = {
86+
projectDetail: {},
87+
challenge: {},
88+
metadata: {},
89+
challengeResources: {},
90+
token: ''
91+
}
92+
93+
ChallengeViewTabs.propTypes = {
94+
projectDetail: PropTypes.object,
95+
challenge: PropTypes.object,
96+
isBillingAccountExpired: PropTypes.bool,
97+
attachments: PropTypes.array,
98+
metadata: PropTypes.object,
99+
token: PropTypes.string,
100+
isLoading: PropTypes.bool.isRequired,
101+
challengeId: PropTypes.string.isRequired,
102+
challengeResources: PropTypes.arrayOf(PropTypes.object),
103+
assignedMemberDetails: PropTypes.shape(),
104+
enableEdit: PropTypes.bool,
105+
onLaunchChallenge: PropTypes.func,
106+
onCloseTask: PropTypes.func
107+
}
108+
109+
export default ChallengeViewTabs

0 commit comments

Comments
 (0)