-
Notifications
You must be signed in to change notification settings - Fork 21
Feat/v6 #1276
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feat/v6 #1276
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -242,8 +242,11 @@ export function renderReviewScoreCell( | |
| .trim() | ||
| .toUpperCase() | ||
| : '' | ||
| const hasValidScore = typeof review.finalScore === 'number' | ||
| && Number.isFinite(review.finalScore) | ||
|
|
||
| if (!normalizedStatus) { | ||
| return true | ||
| return !hasValidScore | ||
| } | ||
|
|
||
| return normalizedStatus !== 'COMPLETED' | ||
|
|
@@ -540,9 +543,9 @@ export function renderScoreCell( | |
| } | ||
|
|
||
| const reviewInfo = reviewDetail.reviewInfo | ||
| const reviewId = reviewInfo?.id || reviewDetail.reviewId | ||
| const reviewId = reviewInfo?.id ?? reviewDetail.reviewId | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
|
|
||
| if (!reviewInfo || !reviewId) { | ||
| if (!reviewId) { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [❗❗ |
||
| return ( | ||
| <span className={styles.notReviewed}> | ||
| -- | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -12,8 +12,52 @@ import { | |
| fetchAllResourceRoles, | ||
| fetchChallengeResouces, | ||
| } from '../services/resources.service' | ||
| import { BackendResourceRole, BackendSubmission, ChallengeRealtiveInfosMapping } from '../models' | ||
| import { fetchSubmissions } from '../services' | ||
| import { BackendResourceRole, BackendSubmission, ChallengeRealtiveInfosMapping } from '../models' | ||
|
|
||
| const FALLBACK_RESOURCE_ROLES: BackendResourceRole[] = [ | ||
| { | ||
| fullReadAccess: false, | ||
| fullWriteAccess: false, | ||
| id: 'fd672cca-556e-4d16-b0a2-718218edd412', | ||
| isActive: true, | ||
| legacyId: 19, | ||
| name: 'Checkpoint Screener', | ||
| selfObtainable: false, | ||
| }, | ||
| { | ||
| fullReadAccess: true, | ||
| fullWriteAccess: false, | ||
| id: '3970272b-85b4-48d8-8439-672b4f6031bd', | ||
| isActive: true, | ||
| legacyId: 20, | ||
| name: 'Checkpoint Reviewer', | ||
| selfObtainable: false, | ||
| }, | ||
| ] | ||
|
|
||
| const ensureResourceRoleMapping = ( | ||
| mapping: { [key: string]: BackendResourceRole } | undefined, | ||
| ): { [key: string]: BackendResourceRole } => { | ||
| const base = { ...(mapping ?? {}) } | ||
|
|
||
| FALLBACK_RESOURCE_ROLES.forEach(role => { | ||
| const existing = base[role.id] | ||
| if (!existing) { | ||
| base[role.id] = role | ||
| return | ||
| } | ||
|
|
||
| if (!existing.name) { | ||
| base[role.id] = { | ||
| ...existing, | ||
| name: role.name, | ||
| } | ||
| } | ||
| }) | ||
|
|
||
| return base | ||
| } | ||
|
|
||
| export interface useFetchChallengeRelativeDatasProps { | ||
| challengeRelativeInfosMapping: ChallengeRealtiveInfosMapping // from challenge id to list of my role | ||
|
|
@@ -57,20 +101,21 @@ export function useFetchChallengeRelativeDatas( | |
| setResourceRoleReviewer(find(results.data, { | ||
| name: 'Reviewer', | ||
| })) | ||
| setResourceRoleMapping( | ||
| reduce( | ||
| results.data, | ||
| (mappingResult, resourceRole: BackendResourceRole) => ({ | ||
| ...mappingResult, | ||
| [resourceRole.id]: resourceRole, | ||
| }), | ||
| {}, | ||
| ), | ||
| ) | ||
| const mapping = ensureResourceRoleMapping(reduce( | ||
| results.data, | ||
| (mappingResult, resourceRole: BackendResourceRole) => ({ | ||
| ...mappingResult, | ||
| [resourceRole.id]: resourceRole, | ||
| }), | ||
| {}, | ||
| )) | ||
|
|
||
| setResourceRoleMapping(mapping) | ||
| setIsLoadingResourceRoles(false) | ||
| }) | ||
| .catch(e => { | ||
| handleError(e) | ||
| setResourceRoleMapping(current => ensureResourceRoleMapping(current)) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| setIsLoadingResourceRoles(false) | ||
| }) | ||
| }) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,6 +11,7 @@ import { BackendReview } from './BackendReview.model' | |
| * Review result info | ||
| */ | ||
| export interface ReviewResult { | ||
| id?: string | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| appeals: AppealResult[] | ||
| createdAt: string | Date | ||
| createdAtString?: string // this field is calculated at frontend | ||
|
|
@@ -111,6 +112,7 @@ export function convertBackendReviewToReviewResult( | |
| appeals: [], | ||
| createdAt, | ||
| createdAtString, | ||
| id: data.id, | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| phaseName, | ||
| resourceId: data.resourceId, | ||
| reviewDate, | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ export interface SubmissionInfo { | |
| memberId: string | ||
| userInfo?: BackendResource // this field is calculated at frontend | ||
| review?: ReviewInfo | ||
| reviewInfos?: ReviewInfo[] | ||
| reviews?: ReviewResult[] | ||
| /** | ||
| * Backend review type identifier (e.g. 'Post-Mortem Review'). | ||
|
|
@@ -109,6 +110,9 @@ export function convertBackendSubmissionToSubmissionInfo( | |
| ? isPassingReviewRaw | ||
| : undefined | ||
| const reviewEntries = Array.isArray(data.review) ? data.review : [] | ||
| const reviewInfos = reviewEntries.map(convertBackendReviewToReviewInfo) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [ |
||
| const reviewResults = reviewEntries.map(convertBackendReviewToReviewResult) | ||
| const primaryReviewInfo = reviewInfos[0] | ||
| const primaryReview = reviewEntries[0] | ||
|
|
||
| return { | ||
|
|
@@ -117,11 +121,9 @@ export function convertBackendSubmissionToSubmissionInfo( | |
| isLatest: data.isLatest, | ||
| isPassingReview, | ||
| memberId: data.memberId, | ||
| review: | ||
| primaryReview | ||
| ? convertBackendReviewToReviewInfo(primaryReview) | ||
| : undefined, | ||
| reviews: reviewEntries.map(convertBackendReviewToReviewResult), | ||
| review: primaryReviewInfo, | ||
| reviewInfos, | ||
| reviews: reviewResults, | ||
| reviewTypeId: primaryReview?.typeId ?? undefined, | ||
| submittedDate, | ||
| submittedDateString, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[💡
readability]The use of
typeof review.finalScore === 'number' && Number.isFinite(review.finalScore)is a good check for a valid score. However, consider usingNumber.isNaN(review.finalScore)to explicitly check for NaN values, which can sometimes be more readable and convey the intent more clearly.