Skip to content

Commit 9e620ef

Browse files
Merge pull request #388 from topcoder-platform/PROD-1573_work-details-solutions
PROD-1573 work details solutions -> qa
2 parents 0a9b3c6 + 88bee06 commit 9e620ef

Some content is hidden

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

49 files changed

+311
-1074
lines changed

src-ts/lib/work-provider/work-functions/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export {
88
workFactoryGetStatus,
99
type WorkProgress,
1010
type WorkProgressStep,
11+
type WorkSolution,
1112
WorkStatus,
1213
WorkType,
1314
WorkTypeCategory,

src-ts/lib/work-provider/work-functions/work-factory/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export * from './work-progress.model'
22
export * from './work-progress-step.model'
33
export * from './work-status.enum'
4+
export * from './work-solution.model'
45
export * from './work-type-category.enum'
56
export * from './work-type.enum'
67
export {
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
export interface WorkSolution {
3+
challengeId: number
4+
created: Date
5+
createdBy: string
6+
fileType: string
7+
id: string
8+
isFileSubmission: boolean
9+
legacyChallengeId: number
10+
legacySubmissionId: number
11+
memberId: number
12+
placement: string
13+
submissionPhaseId: string
14+
submittedDate: Date
15+
type: string
16+
updated: Date
17+
updatedBy: string
18+
url: string
19+
v5ChallengeId: string
20+
}

src-ts/tools/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
export { default as ToolsRoutes } from './tools.routes'
2-
export { WorkFeedback, WorkDetailDetails, WorkDetailHeader, WorkDetailSummary } from './work'
2+
export { WorkFeedback, WorkDetailDetails, WorkDetailHeader, WorkDetailSummary, WorkDetailSolutions } from './work'

src-ts/tools/work/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './work-detail-details'
22
export * from './work-detail-header'
3+
export * from './work-detail-solutions'
34
export * from './work-detail-summary'
45
export * from './work.routes'
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
@import '../../../lib/styles';
2+
3+
.wrap {
4+
display: block;
5+
padding-bottom: $pad-xxxxl;
6+
}
7+
8+
.header {
9+
@include font-black-100;
10+
@include font-roboto;
11+
margin-bottom: $pad-lg;
12+
13+
p {
14+
margin-top: $pad-sm;
15+
}
16+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
import { FC, useContext, useMemo } from 'react'
2+
3+
import { Work, workContext, WorkContextData, WorkSolution, WorkStatus } from '../../../lib'
4+
5+
import { WorkSolutionsList } from './work-solutions-list'
6+
import styles from './WorkDetailSolutions.module.scss'
7+
8+
interface WorkDetailSolutionsProps {
9+
challenge: any
10+
onDownload: (solutionId: string) => void
11+
solutions: Array<WorkSolution>
12+
}
13+
14+
const WorkDetailSolutions: FC<WorkDetailSolutionsProps> = (props: WorkDetailSolutionsProps) => {
15+
16+
const workContextData: WorkContextData = useContext(workContext)
17+
const work: Work = workContextData.createFromChallenge(props.challenge)
18+
19+
const isSolutionsReady: boolean = useMemo(() => {
20+
const activeStepName: string = work.progress.steps[work.progress.activeStepIndex]?.name
21+
return (activeStepName === WorkStatus.ready || activeStepName === WorkStatus.done) && props.solutions?.length > 0
22+
}, [work, props.solutions])
23+
24+
return (
25+
<div className={styles.wrap}>
26+
{isSolutionsReady && (
27+
<div className={styles.header}>
28+
<h3>
29+
Solutions Available for Download
30+
</h3>
31+
<p className={'body-small'}>
32+
The solutions listed below have met your detailed criteria. They are ranked based on the best solution as determined by Topcoder expert reviewers.
33+
</p>
34+
</div>
35+
)}
36+
<WorkSolutionsList isSolutionsReady={isSolutionsReady} work={work} solutions={props.solutions} onDownload={props.onDownload} />
37+
</div>
38+
)
39+
}
40+
41+
export default WorkDetailSolutions
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export { default as WorkDetailSolutions } from './WorkDetailSolutions'
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
@import '../../../../lib/styles';
2+
3+
.list-wrap {
4+
counter-reset: solutionListItem;
5+
}
6+
7+
8+
.solutions-not-available {
9+
@extend .large-subtitle;
10+
@include font-barlow;
11+
color: $black-100;
12+
13+
display: flex;
14+
align-items: center;
15+
justify-content: center;
16+
min-height: 507px;
17+
padding: $pad-lg;
18+
text-align: center;
19+
background-color: $black-5;
20+
border-radius: $pad-sm;
21+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
import moment from 'moment'
2+
import { FC, useMemo } from 'react'
3+
4+
import { Work, WorkSolution, WorkStatus } from '../../../../lib'
5+
6+
import { WorkSolutionsListItem } from './work-solutions-list-item'
7+
import styles from './WorkSolutionsList.module.scss'
8+
9+
interface WorkSolutionsListProps {
10+
isSolutionsReady: boolean
11+
onDownload: (solutionId: string) => void
12+
solutions: Array<WorkSolution>
13+
work: Work
14+
}
15+
16+
const WorkSolutionsList: FC<WorkSolutionsListProps> = (props: WorkSolutionsListProps) => {
17+
18+
if (!props.isSolutionsReady || !props.solutions?.length) {
19+
return (
20+
<div className={styles['solutions-not-available']}>
21+
YOUR SOLUTIONS WILL BE AVAILABLE FOR DOWNLOAD ON:
22+
<br />
23+
{moment(props.work.solutionsReadyDate).format('MM/DD/YY')}
24+
</div>
25+
)
26+
}
27+
28+
return (
29+
<div className={styles['list-wrap']}>
30+
{props.solutions.map((solution) => (
31+
<WorkSolutionsListItem solution={solution} key={solution.id} onDownload={props.onDownload}/>
32+
))}
33+
</div>
34+
)
35+
}
36+
37+
export default WorkSolutionsList

0 commit comments

Comments
 (0)