1
- import React , { useCallback , useEffect , useState } from 'react'
2
- import PropTypes from 'prop-types'
3
- import _ from 'lodash'
1
+ import React , { useCallback , useEffect , useState } from 'react' ;
2
+ import PropTypes from 'prop-types' ;
3
+ import _ from 'lodash' ;
4
4
5
5
import { Modal } from 'topcoder-react-ui-kit' ;
6
6
import LoadingIndicator from 'components/LoadingIndicator' ;
7
7
import IconClose from 'assets/images/icon-close-green.svg' ;
8
8
9
9
10
- import styles from './styles.scss'
10
+ import styles from './styles.scss' ;
11
11
12
12
const theme = {
13
13
container : styles . modalContainer ,
14
14
overlay : styles . modalOverlay ,
15
15
} ;
16
16
17
17
const SystemReviewers = {
18
- Default : 'TC System'
18
+ Default : 'TC System' ,
19
19
} ;
20
20
21
- export const RatingsListModal = ( { onCancel, submissionId, challengeId, getReviewTypesList, getChallengeResources, getSubmissionInformation } ) => {
22
- const [ reviews , setReviews ] = useState ( [ ] )
23
- const [ loading , setLoading ] = useState ( false )
21
+ const RatingsListModal = ( {
22
+ onCancel,
23
+ submissionId,
24
+ challengeId,
25
+ getReviewTypesList,
26
+ getChallengeResources,
27
+ getSubmissionInformation,
28
+ } ) => {
29
+ const [ reviews , setReviews ] = useState ( [ ] ) ;
30
+ const [ loading , setLoading ] = useState ( false ) ;
24
31
25
32
const enrichSources = useCallback ( async ( submissionReviews , reviewSummation ) => {
26
-
27
- const reviewTypes = await getReviewTypesList ( )
28
- const resources = await getChallengeResources ( challengeId )
33
+ const reviewTypes = await getReviewTypesList ( ) ;
34
+ const resources = await getChallengeResources ( challengeId ) ;
29
35
30
36
const finalReview = {
31
37
reviewType : 'Final score' ,
32
38
reviewer : '' ,
33
39
score : reviewSummation ? reviewSummation . aggregateScore : 'N/A' ,
34
- isPassing : reviewSummation ? reviewSummation . isPassing : undefined
35
- }
40
+ isPassing : reviewSummation ? reviewSummation . isPassing : undefined ,
41
+ } ;
36
42
37
- return [ ...submissionReviews . map ( review => {
38
- const reviewType = reviewTypes . find ( rt => rt . id === review . typeId )
39
- const reviewer = resources . find ( resource => resource . memberHandle === review . reviewerId ) || SystemReviewers . Default
43
+ return [ ...submissionReviews . map ( ( review ) => {
44
+ const reviewType = reviewTypes . find ( rt => rt . id === review . typeId ) ;
45
+ const reviewer = resources
46
+ . find ( resource => resource . memberHandle === review . reviewerId ) || SystemReviewers . Default ;
40
47
return {
41
48
...review ,
42
49
reviewType : reviewType ? reviewType . name : '' ,
43
- reviewer
44
- }
45
- } ) , finalReview ]
46
- } , [ challengeId , getReviewTypesList , getChallengeResources ] )
50
+ reviewer,
51
+ } ;
52
+ } ) , finalReview ] ;
53
+ } , [ challengeId , getReviewTypesList , getChallengeResources ] ) ;
47
54
48
55
const getSubmission = useCallback ( async ( ) => {
49
- const submissionInfo = await getSubmissionInformation ( submissionId )
50
- setReviews ( await enrichSources ( submissionInfo . review , submissionInfo . reviewSummation [ 0 ] ) )
51
- setLoading ( false )
52
- } , [ submissionId , getSubmissionInformation , enrichSources ] )
56
+ const submissionInfo = await getSubmissionInformation ( submissionId ) ;
57
+ setReviews ( await enrichSources ( submissionInfo . review , submissionInfo . reviewSummation [ 0 ] ) ) ;
58
+ setLoading ( false ) ;
59
+ } , [ submissionId , getSubmissionInformation , enrichSources ] ) ;
53
60
54
61
useEffect ( ( ) => {
55
- setLoading ( true )
56
- getSubmission ( )
57
- } , [ submissionId , getSubmission ] )
62
+ setLoading ( true ) ;
63
+ getSubmission ( ) ;
64
+ } , [ submissionId , getSubmission ] ) ;
58
65
59
66
return (
60
67
< Modal onCancel = { ( ) => onCancel ( ) } theme = { theme } >
@@ -69,12 +76,12 @@ export const RatingsListModal = ({ onCancel, submissionId, challengeId, getRevie
69
76
< div styleName = "header-item" > Score</ div >
70
77
< div styleName = "header-item" > Status</ div >
71
78
</ div >
72
- { reviews . map ( review => {
73
- const { isPassing } = review
74
- const isFailed = isPassing === false
75
- const isPassed = isPassing === true
76
- const statusIsDefined = isPassed || isFailed
77
- const status = isPassing ? 'Passed' : 'Failed'
79
+ { reviews . map ( ( review ) => {
80
+ const { isPassing } = review ;
81
+ const isFailed = isPassing === false ;
82
+ const isPassed = isPassing === true ;
83
+ const statusIsDefined = isPassed || isFailed ;
84
+ const status = isPassing ? 'Passed' : 'Failed' ;
78
85
79
86
return (
80
87
< div styleName = "list-item" >
@@ -91,7 +98,7 @@ export const RatingsListModal = ({ onCancel, submissionId, challengeId, getRevie
91
98
{ statusIsDefined ? status : 'N/A' }
92
99
</ div >
93
100
</ div >
94
- )
101
+ ) ;
95
102
} ) }
96
103
</ div >
97
104
@@ -100,24 +107,25 @@ export const RatingsListModal = ({ onCancel, submissionId, challengeId, getRevie
100
107
}
101
108
</ div >
102
109
</ Modal >
103
- )
104
- }
110
+ ) ;
111
+ } ;
105
112
106
113
RatingsListModal . defaultProps = {
107
114
onCancel : ( ) => { } ,
108
115
submissionId : '' ,
109
116
challengeId : '' ,
110
117
getReviewTypesList : _ . noop ,
111
118
getChallengeResources : _ . noop ,
112
- getSubmissionInformation : _ . noop
113
- }
119
+ getSubmissionInformation : _ . noop ,
120
+ } ;
114
121
115
122
RatingsListModal . propTypes = {
116
123
onCancel : PropTypes . func ,
117
- token : PropTypes . string ,
118
124
submissionId : PropTypes . string ,
119
125
challengeId : PropTypes . string ,
120
126
getReviewTypesList : PropTypes . func ,
121
127
getChallengeResources : PropTypes . func ,
122
- getSubmissionInformation : PropTypes . func
123
- }
128
+ getSubmissionInformation : PropTypes . func ,
129
+ } ;
130
+
131
+ export default RatingsListModal ;
0 commit comments