Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/apps/review/src/lib/hooks/useFetchScorecard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface ScorecardResponse {
isValidating: boolean
}

export function useFetchScorecard(id: string | undefined): ScorecardResponse {
export function useFetchScorecard(id: string | undefined, shouldRetry: boolean): ScorecardResponse {

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

Expand All @@ -23,6 +23,12 @@ export function useFetchScorecard(id: string | undefined): ScorecardResponse {
id ? `${baseUrl}/scorecards/${id}` : null,
fetcher,
{
...(shouldRetry
? {}
: {
errorRetryCount: 0,
shouldRetryOnError: false,
}),
onError: err => {
toast.error(err.message)
},
Expand Down
1 change: 1 addition & 0 deletions src/apps/review/src/lib/models/ScorecardQuestion.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@ export interface ScorecardQuestion {
weight: number
scaleMin: number
scaleMax: number
requiresUpload: boolean
}
10 changes: 10 additions & 0 deletions src/apps/review/src/mock-datas/MockScorecard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ export const MockScorecard: ScorecardInfo = {
'Was the pricing adequate for the contest?',
guidelines: mockGuidelines,
id: '4',
requiresUpload: true,
scaleMax: 9,
scaleMin: 1,
type: 'YES_NO',
Expand All @@ -43,6 +44,7 @@ export const MockScorecard: ScorecardInfo = {
'Was the timeline adequate for the contest?',
guidelines: mockGuidelines,
id: '5',
requiresUpload: true,
scaleMax: 9,
scaleMin: 1,
type: 'YES_NO',
Expand All @@ -52,6 +54,7 @@ export const MockScorecard: ScorecardInfo = {
description: 'Were the specifications clear?',
guidelines: mockGuidelines,
id: '6',
requiresUpload: true,
scaleMax: 9,
scaleMin: 1,
type: 'SCALE',
Expand All @@ -61,6 +64,7 @@ export const MockScorecard: ScorecardInfo = {
description: 'Here comes another question',
guidelines: mockGuidelines,
id: '7',
requiresUpload: true,
scaleMax: 9,
scaleMin: 1,
type: 'SCALE',
Expand All @@ -79,6 +83,7 @@ export const MockScorecard: ScorecardInfo = {
'Have all major specification requirements been met?',
guidelines: mockGuidelines,
id: '9',
requiresUpload: true,
scaleMax: 9,
scaleMin: 1,
type: 'SCALE',
Expand All @@ -89,6 +94,7 @@ export const MockScorecard: ScorecardInfo = {
'Have all minor specification requirements been met?',
guidelines: mockGuidelines,
id: '10',
requiresUpload: true,
scaleMax: 9,
scaleMin: 1,
type: 'SCALE',
Expand All @@ -115,6 +121,7 @@ export const MockScorecard: ScorecardInfo = {
'This is the first question of this section',
guidelines: mockGuidelines,
id: '13',
requiresUpload: true,
scaleMax: 9,
scaleMin: 1,
type: 'SCALE',
Expand All @@ -125,6 +132,7 @@ export const MockScorecard: ScorecardInfo = {
'This is the second question of this section',
guidelines: mockGuidelines,
id: '14',
requiresUpload: true,
scaleMax: 9,
scaleMin: 1,
type: 'SCALE',
Expand All @@ -143,6 +151,7 @@ export const MockScorecard: ScorecardInfo = {
'Does the code have proper code coverage?',
guidelines: mockGuidelines,
id: '16',
requiresUpload: true,
scaleMax: 9,
scaleMin: 1,
type: 'SCALE',
Expand All @@ -154,6 +163,7 @@ export const MockScorecard: ScorecardInfo = {
'Do all test cases provided, pass, given any test data or setup for the current application?',
guidelines: mockGuidelines,
id: '17',
requiresUpload: true,
scaleMax: 9,
scaleMin: 1,
type: 'SCALE',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ const EditScorecardPage: FC = () => {
const [isSaving, setSaving] = useState(false)
const params = useParams()
const isEditMode = !!params.scorecardId
const scorecardQuery = useFetchScorecard(params.scorecardId)
const scorecardQuery = useFetchScorecard(params.scorecardId, false)
const title = useMemo(() => (
`${isEditMode ? 'Edit' : 'Create'} Scorecard`
), [isEditMode])
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,9 @@ const ScorecardSections: FC<ScorecardSectionsProps> = (props: ScorecardSectionsP
</div>
<div className={styles.detailItem}>
<div className={styles.label}>Document Upload:</div>
{/* This will be added once upload functionality works */}
<div className={styles.value}>NA</div>
<div className={styles.value}>
{question.requiresUpload ? 'Yes' : 'No'}
</div>
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@ const ViewScorecardPage: FC = () => {
[],
)

const scorecardQuery = useFetchScorecard(scorecardId)
const scorecardQuery = useFetchScorecard(scorecardId, true)

return (
<PageWrapper
pageTitle={(scorecardQuery.scorecard && scorecardQuery.scorecard.name) || ''}
breadCrumb={breadCrumb}
rightHeader={isAdmin && (
rightHeader={scorecardQuery.scorecard && isAdmin && (
<LinkButton
iconToLeft
icon={PencilIconWrapper}
Expand Down