Skip to content

Commit b3b1a0d

Browse files
authored
Merge pull request #1197 from topcoder-platform/feat/review-detail-page-integation-2
Feat/review detail page integation 2
2 parents 136bb49 + 8cd9ee0 commit b3b1a0d

File tree

67 files changed

+1439
-842
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

67 files changed

+1439
-842
lines changed

src/apps/admin/src/lib/components/common/ActionLoading/ActionLoading.module.scss

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
display: flex;
77
align-items: center;
88
justify-content: center;
9-
bottom: 0;
9+
bottom: -20px;
1010
height: 64px;
1111
left: $sp-8;
1212

src/apps/review/src/config/index.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import { SelectOption } from '../lib/models'
66

77
export const DESIGN = 'Design'
8+
export const TRACK_CHALLENGE = 'Challenge'
89
export const CODE = 'Code'
910
export const BUG_HUNT = 'Bug Hunt'
1011
export const TEST_SUITE = 'Test Suite'

src/apps/review/src/lib/components/ChallengeDetailsContent/ChallengeDetailsContent.tsx

Lines changed: 48 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -3,92 +3,70 @@
33
*/
44
import { FC } from 'react'
55

6-
import { TableLoading } from '~/apps/admin/src/lib'
6+
import { ActionLoading } from '~/apps/admin/src/lib'
77

8+
import { Screening, SubmissionInfo } from '../../models'
89
import {
9-
ProjectResult,
10-
RegistrationInfo,
11-
Screening,
12-
SubmissionInfo,
13-
} from '../../models'
14-
import { TableRegistration } from '../TableRegistration'
15-
import { TableNoRecord } from '../TableNoRecord'
16-
import { TableSubmissionScreening } from '../TableSubmissionScreening'
17-
import { TableReviewAppeals } from '../TableReviewAppeals'
18-
import { TableWinners } from '../TableWinners'
19-
import { useRole, useRoleProps } from '../../hooks'
20-
import { APPROVAL, MOCKHANDLE, REVIEWER, SUBMITTER } from '../../../config/index.config'
21-
import { TableReviewAppealsForSubmitter } from '../TableReviewAppealsForSubmitter'
10+
useDownloadSubmission,
11+
useDownloadSubmissionProps,
12+
} from '../../hooks'
13+
import {
14+
useFetchChallengeResults,
15+
useFetchChallengeResultsProps,
16+
} from '../../hooks/useFetchChallengeResults'
17+
18+
import TabContentRegistration from './TabContentRegistration'
19+
import TabContentReview from './TabContentReview'
20+
import TabContentScreening from './TabContentScreening'
21+
import TabContentWinners from './TabContentWinners'
2222

2323
interface Props {
2424
selectedTab: string
25-
type?: string
26-
registrations: RegistrationInfo[]
27-
isLoadingRegistrants: boolean
28-
submissions: SubmissionInfo[]
29-
projectResults: ProjectResult[]
25+
isLoadingSubmission: boolean
3026
screening: Screening[]
31-
firstSubmissions: SubmissionInfo | undefined
27+
review: SubmissionInfo[]
3228
}
3329

3430
export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
35-
const selectedTab = props.selectedTab
36-
const type = props.type
37-
const registrations = props.registrations
38-
const submissions = props.submissions
39-
const firstSubmissions = props.firstSubmissions
40-
const projectResults = props.projectResults
41-
const { actionChallengeRole }: useRoleProps = useRole()
42-
const screening
43-
= actionChallengeRole === REVIEWER
44-
? props.screening
45-
: props.screening.filter(s => s.handle === MOCKHANDLE)
46-
47-
// show ui for Registration tab
48-
if (selectedTab === 'Registration') {
49-
// show loading ui when fetching registrants
50-
if (props.isLoadingRegistrants) {
51-
return <TableLoading />
52-
}
53-
54-
// show no record message
55-
if (!registrations.length) {
56-
return <TableNoRecord />
57-
}
58-
59-
// show registrants table
60-
return <TableRegistration datas={registrations} />
61-
}
62-
63-
if (
64-
!submissions.length
65-
|| !projectResults.length
66-
|| !screening.length
67-
) {
68-
return <TableNoRecord />
69-
}
31+
const {
32+
isLoading: isDownloadingSubmission,
33+
isLoadingBool: isDownloadingSubmissionBool,
34+
downloadSubmission,
35+
}: useDownloadSubmissionProps = useDownloadSubmission()
36+
const {
37+
isLoading: isLoadingProjectResult,
38+
projectResults,
39+
}: useFetchChallengeResultsProps = useFetchChallengeResults(props.review)
7040

7141
return (
7242
<>
73-
{selectedTab === 'Submission / Screening' ? (
74-
<TableSubmissionScreening datas={screening} />
75-
) : selectedTab === 'Winners' ? (
76-
<TableWinners datas={projectResults} />
77-
) : (actionChallengeRole !== SUBMITTER || selectedTab === APPROVAL) ? (
78-
<TableReviewAppeals
79-
datas={submissions}
80-
tab={selectedTab}
81-
type={type}
82-
firstSubmissions={firstSubmissions}
43+
{props.selectedTab === 'Registration' ? (
44+
<TabContentRegistration />
45+
) : props.selectedTab === 'Submission / Screening' ? (
46+
<TabContentScreening
47+
screening={props.screening}
48+
isLoadingScreening={props.isLoadingSubmission}
49+
isDownloading={isDownloadingSubmission}
50+
downloadSubmission={downloadSubmission}
51+
/>
52+
) : props.selectedTab === 'Winners' ? (
53+
<TabContentWinners
54+
isLoading={isLoadingProjectResult}
55+
projectResults={projectResults}
56+
isDownloading={isDownloadingSubmission}
57+
downloadSubmission={downloadSubmission}
8358
/>
8459
) : (
85-
<TableReviewAppealsForSubmitter
86-
datas={submissions}
87-
tab={selectedTab}
88-
type={type}
89-
firstSubmissions={firstSubmissions}
60+
<TabContentReview
61+
selectedTab={props.selectedTab}
62+
reviews={props.review}
63+
isLoadingReview={props.isLoadingSubmission}
64+
isDownloading={isDownloadingSubmission}
65+
downloadSubmission={downloadSubmission}
9066
/>
9167
)}
68+
69+
{isDownloadingSubmissionBool && <ActionLoading />}
9270
</>
9371
)
9472
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* Content of registration tab.
3+
*/
4+
import { FC, useContext } from 'react'
5+
6+
import { TableLoading } from '~/apps/admin/src/lib'
7+
8+
import { ChallengeDetailContextModel } from '../../models'
9+
import { TableRegistration } from '../TableRegistration'
10+
import { TableNoRecord } from '../TableNoRecord'
11+
import { ChallengeDetailContext } from '../../contexts'
12+
13+
export const TabContentRegistration: FC = () => {
14+
// get challenge info from challenge detail context
15+
const {
16+
isLoadingChallengeResources,
17+
registrants,
18+
}: ChallengeDetailContextModel = useContext(ChallengeDetailContext)
19+
20+
// show loading ui when fetching registrants
21+
if (isLoadingChallengeResources) {
22+
return <TableLoading />
23+
}
24+
25+
// show no record message
26+
if (!registrants.length) {
27+
return <TableNoRecord />
28+
}
29+
30+
// show registrants table
31+
return <TableRegistration datas={registrants} />
32+
}
33+
34+
export default TabContentRegistration
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/**
2+
* Content of review tab.
3+
*/
4+
import { FC, useMemo } from 'react'
5+
import { maxBy } from 'lodash'
6+
7+
import { TableLoading } from '~/apps/admin/src/lib'
8+
import { IsRemovingType } from '~/apps/admin/src/lib/models'
9+
10+
import { SubmissionInfo } from '../../models'
11+
import { TableNoRecord } from '../TableNoRecord'
12+
import { TableReviewAppeals } from '../TableReviewAppeals'
13+
import { useRole, useRoleProps } from '../../hooks'
14+
import {
15+
APPROVAL,
16+
SUBMITTER,
17+
} from '../../../config/index.config'
18+
import { TableReviewAppealsForSubmitter } from '../TableReviewAppealsForSubmitter'
19+
20+
interface Props {
21+
selectedTab: string
22+
reviews: SubmissionInfo[]
23+
isLoadingReview: boolean
24+
isDownloading: IsRemovingType
25+
downloadSubmission: (submissionId: string) => void
26+
}
27+
28+
export const TabContentReview: FC<Props> = (props: Props) => {
29+
const selectedTab = props.selectedTab
30+
const reviews = props.reviews
31+
const firstSubmissions = useMemo(
32+
() => maxBy(reviews, 'review.initialScore'),
33+
[reviews],
34+
)
35+
const { actionChallengeRole }: useRoleProps = useRole()
36+
37+
// show loading ui when fetching data
38+
if (
39+
props.isLoadingReview
40+
) {
41+
return <TableLoading />
42+
}
43+
44+
// show no record message
45+
if (!reviews.length) {
46+
return <TableNoRecord />
47+
}
48+
49+
return actionChallengeRole !== SUBMITTER || selectedTab === APPROVAL ? (
50+
<TableReviewAppeals
51+
datas={reviews}
52+
tab={selectedTab}
53+
firstSubmissions={firstSubmissions}
54+
isDownloading={props.isDownloading}
55+
downloadSubmission={props.downloadSubmission}
56+
/>
57+
) : (
58+
<TableReviewAppealsForSubmitter
59+
datas={reviews}
60+
firstSubmissions={firstSubmissions}
61+
isDownloading={props.isDownloading}
62+
downloadSubmission={props.downloadSubmission}
63+
/>
64+
)
65+
}
66+
67+
export default TabContentReview
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Content of screening tab.
3+
*/
4+
import { FC } from 'react'
5+
6+
import { TableLoading } from '~/apps/admin/src/lib'
7+
import { IsRemovingType } from '~/apps/admin/src/lib/models'
8+
9+
import { Screening } from '../../models'
10+
import { TableNoRecord } from '../TableNoRecord'
11+
import { TableSubmissionScreening } from '../TableSubmissionScreening'
12+
13+
interface Props {
14+
screening: Screening[]
15+
isLoadingScreening: boolean
16+
isDownloading: IsRemovingType
17+
downloadSubmission: (submissionId: string) => void
18+
}
19+
20+
export const TabContentScreening: FC<Props> = (props: Props) => {
21+
// show loading ui when fetching data
22+
if (props.isLoadingScreening) {
23+
return <TableLoading />
24+
}
25+
26+
// show no record message
27+
if (!props.screening.length) {
28+
return <TableNoRecord />
29+
}
30+
31+
return (
32+
<TableSubmissionScreening
33+
datas={props.screening}
34+
isDownloading={props.isDownloading}
35+
downloadSubmission={props.downloadSubmission}
36+
/>
37+
)
38+
}
39+
40+
export default TabContentScreening
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
/**
2+
* Content of winners tab.
3+
*/
4+
import { FC } from 'react'
5+
6+
import { TableLoading } from '~/apps/admin/src/lib'
7+
import { IsRemovingType } from '~/apps/admin/src/lib/models'
8+
9+
import { ProjectResult } from '../../models'
10+
import { TableNoRecord } from '../TableNoRecord'
11+
import { TableWinners } from '../TableWinners'
12+
13+
interface Props {
14+
projectResults: ProjectResult[]
15+
isLoading: boolean
16+
isDownloading: IsRemovingType
17+
downloadSubmission: (submissionId: string) => void
18+
}
19+
20+
export const TabContentWinners: FC<Props> = (props: Props) => {
21+
// show loading ui when fetching data
22+
if (props.isLoading) {
23+
return <TableLoading />
24+
}
25+
26+
// show no record message
27+
if (!props.projectResults.length) {
28+
return <TableNoRecord />
29+
}
30+
31+
return (
32+
<TableWinners
33+
datas={props.projectResults}
34+
isDownloading={props.isDownloading}
35+
downloadSubmission={props.downloadSubmission}
36+
/>
37+
)
38+
}
39+
40+
export default TabContentWinners

src/apps/review/src/lib/components/ChallengePhaseInfo/ChallengePhaseInfo.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import styles from './ChallengePhaseInfo.module.scss'
1313
interface Props {
1414
className?: string
1515
challengeInfo: ChallengeInfo
16+
reviewProgress: number
1617
}
1718

1819
export const ChallengePhaseInfo: FC<Props> = (props: Props) => {
@@ -54,10 +55,10 @@ export const ChallengePhaseInfo: FC<Props> = (props: Props) => {
5455
{
5556
title: 'Review Progress',
5657
type: PROGRESS_TYPE,
57-
value: data.reviewProgress,
58+
value: props.reviewProgress,
5859
},
5960
]
60-
}, [props.challengeInfo, myChallengeRoles])
61+
}, [props.challengeInfo, myChallengeRoles, props.reviewProgress])
6162
return (
6263
<div className={classNames(styles.container, props.className)}>
6364
{uiItems.map(item => {

src/apps/review/src/lib/components/ScorecardQuestionView/ScorecardQuestionView.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ export const ScorecardQuestionView: FC<Props> = (props: Props) => {
170170
</td>
171171
</tr>
172172
{!includes(WITHOUT_APPEAL, challengeInfo?.type)
173+
&& !includes(WITHOUT_APPEAL, challengeInfo?.track)
173174
&& (includes([REVIEWER, COPILOT, ADMIN], actionChallengeRole) ? (
174175
props.mappingAppeals[commentItem.id] && (
175176
<tr

src/apps/review/src/lib/components/SubmissionBarInfo/SubmissionBarInfo.module.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,13 @@
4949
line-height: 20px;
5050
}
5151
}
52+
53+
.blockMyRoles {
54+
display: flex;
55+
flex-direction: column;
56+
gap: 0;
57+
58+
span {
59+
color: var(--FontColor);
60+
}
61+
}

0 commit comments

Comments
 (0)