Skip to content

Commit 3efd6b5

Browse files
authored
Merge pull request #1214 from topcoder-platform/pm-1503_4
fix(PM-1503) Used requiresUpload from backend
2 parents 003f6bb + 3590b3d commit 3efd6b5

File tree

6 files changed

+24
-6
lines changed

6 files changed

+24
-6
lines changed

src/apps/review/src/lib/hooks/useFetchScorecard.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface ScorecardResponse {
1414
isValidating: boolean
1515
}
1616

17-
export function useFetchScorecard(id: string | undefined): ScorecardResponse {
17+
export function useFetchScorecard(id: string | undefined, shouldRetry: boolean): ScorecardResponse {
1818

1919
const fetcher = (url: string): Promise<Scorecard> => xhrGetAsync<Scorecard>(url)
2020

@@ -23,6 +23,12 @@ export function useFetchScorecard(id: string | undefined): ScorecardResponse {
2323
id ? `${baseUrl}/scorecards/${id}` : null,
2424
fetcher,
2525
{
26+
...(shouldRetry
27+
? {}
28+
: {
29+
errorRetryCount: 0,
30+
shouldRetryOnError: false,
31+
}),
2632
onError: err => {
2733
toast.error(err.message)
2834
},

src/apps/review/src/lib/models/ScorecardQuestion.model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,5 @@ export interface ScorecardQuestion {
99
weight: number
1010
scaleMin: number
1111
scaleMax: number
12+
requiresUpload: boolean
1213
}

src/apps/review/src/mock-datas/MockScorecard.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const MockScorecard: ScorecardInfo = {
3333
'Was the pricing adequate for the contest?',
3434
guidelines: mockGuidelines,
3535
id: '4',
36+
requiresUpload: true,
3637
scaleMax: 9,
3738
scaleMin: 1,
3839
type: 'YES_NO',
@@ -43,6 +44,7 @@ export const MockScorecard: ScorecardInfo = {
4344
'Was the timeline adequate for the contest?',
4445
guidelines: mockGuidelines,
4546
id: '5',
47+
requiresUpload: true,
4648
scaleMax: 9,
4749
scaleMin: 1,
4850
type: 'YES_NO',
@@ -52,6 +54,7 @@ export const MockScorecard: ScorecardInfo = {
5254
description: 'Were the specifications clear?',
5355
guidelines: mockGuidelines,
5456
id: '6',
57+
requiresUpload: true,
5558
scaleMax: 9,
5659
scaleMin: 1,
5760
type: 'SCALE',
@@ -61,6 +64,7 @@ export const MockScorecard: ScorecardInfo = {
6164
description: 'Here comes another question',
6265
guidelines: mockGuidelines,
6366
id: '7',
67+
requiresUpload: true,
6468
scaleMax: 9,
6569
scaleMin: 1,
6670
type: 'SCALE',
@@ -79,6 +83,7 @@ export const MockScorecard: ScorecardInfo = {
7983
'Have all major specification requirements been met?',
8084
guidelines: mockGuidelines,
8185
id: '9',
86+
requiresUpload: true,
8287
scaleMax: 9,
8388
scaleMin: 1,
8489
type: 'SCALE',
@@ -89,6 +94,7 @@ export const MockScorecard: ScorecardInfo = {
8994
'Have all minor specification requirements been met?',
9095
guidelines: mockGuidelines,
9196
id: '10',
97+
requiresUpload: true,
9298
scaleMax: 9,
9399
scaleMin: 1,
94100
type: 'SCALE',
@@ -115,6 +121,7 @@ export const MockScorecard: ScorecardInfo = {
115121
'This is the first question of this section',
116122
guidelines: mockGuidelines,
117123
id: '13',
124+
requiresUpload: true,
118125
scaleMax: 9,
119126
scaleMin: 1,
120127
type: 'SCALE',
@@ -125,6 +132,7 @@ export const MockScorecard: ScorecardInfo = {
125132
'This is the second question of this section',
126133
guidelines: mockGuidelines,
127134
id: '14',
135+
requiresUpload: true,
128136
scaleMax: 9,
129137
scaleMin: 1,
130138
type: 'SCALE',
@@ -143,6 +151,7 @@ export const MockScorecard: ScorecardInfo = {
143151
'Does the code have proper code coverage?',
144152
guidelines: mockGuidelines,
145153
id: '16',
154+
requiresUpload: true,
146155
scaleMax: 9,
147156
scaleMin: 1,
148157
type: 'SCALE',
@@ -154,6 +163,7 @@ export const MockScorecard: ScorecardInfo = {
154163
'Do all test cases provided, pass, given any test data or setup for the current application?',
155164
guidelines: mockGuidelines,
156165
id: '17',
166+
requiresUpload: true,
157167
scaleMax: 9,
158168
scaleMin: 1,
159169
type: 'SCALE',

src/apps/review/src/pages/scorecards/EditScorecardPage/EditScorecardPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ const EditScorecardPage: FC = () => {
2323
const [isSaving, setSaving] = useState(false)
2424
const params = useParams()
2525
const isEditMode = !!params.scorecardId
26-
const scorecardQuery = useFetchScorecard(params.scorecardId)
26+
const scorecardQuery = useFetchScorecard(params.scorecardId, false)
2727
const title = useMemo(() => (
2828
`${isEditMode ? 'Edit' : 'Create'} Scorecard`
2929
), [isEditMode])

src/apps/review/src/pages/scorecards/ViewScorecardPage/ScorecardSections/ScorecardSections.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,9 @@ const ScorecardSections: FC<ScorecardSectionsProps> = (props: ScorecardSectionsP
4949
</div>
5050
<div className={styles.detailItem}>
5151
<div className={styles.label}>Document Upload:</div>
52-
{/* This will be added once upload functionality works */}
53-
<div className={styles.value}>NA</div>
52+
<div className={styles.value}>
53+
{question.requiresUpload ? 'Yes' : 'No'}
54+
</div>
5455
</div>
5556
</div>
5657
</div>

src/apps/review/src/pages/scorecards/ViewScorecardPage/ViewScorecardPage.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ const ViewScorecardPage: FC = () => {
2424
[],
2525
)
2626

27-
const scorecardQuery = useFetchScorecard(scorecardId)
27+
const scorecardQuery = useFetchScorecard(scorecardId, true)
2828

2929
return (
3030
<PageWrapper
3131
pageTitle={(scorecardQuery.scorecard && scorecardQuery.scorecard.name) || ''}
3232
breadCrumb={breadCrumb}
33-
rightHeader={isAdmin && (
33+
rightHeader={scorecardQuery.scorecard && isAdmin && (
3434
<LinkButton
3535
iconToLeft
3636
icon={PencilIconWrapper}

0 commit comments

Comments
 (0)