Skip to content

Commit 71c080e

Browse files
committed
Fix reviewer view
1 parent f3c9d00 commit 71c080e

File tree

1 file changed

+36
-1
lines changed

1 file changed

+36
-1
lines changed

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

Lines changed: 36 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ import {
1515
ChallengeDetailContext,
1616
} from '../../contexts'
1717
import {
18+
BackendSubmission,
1819
ChallengeDetailContextModel,
20+
convertBackendSubmissionToSubmissionInfo,
1921
MappingReviewAppeal,
2022
SubmissionInfo,
2123
} from '../../models'
@@ -50,9 +52,13 @@ export const TabContentReview: FC<Props> = (props: Props) => {
5052
const providedSubmitterReviews = props.submitterReviews
5153
const {
5254
challengeInfo,
55+
challengeSubmissions: backendChallengeSubmissions,
5356
myResources,
5457
}: ChallengeDetailContextModel = useContext(ChallengeDetailContext)
55-
const challengeSubmissions = challengeInfo?.submissions ?? []
58+
const challengeSubmissions = useMemo<SubmissionInfo[]>(
59+
() => challengeInfo?.submissions ?? [],
60+
[challengeInfo?.submissions],
61+
)
5662
const myReviewerResourceIds = useMemo<Set<string>>(
5763
() => new Set(
5864
(myResources ?? [])
@@ -92,6 +98,33 @@ export const TabContentReview: FC<Props> = (props: Props) => {
9298
return providedReviews
9399
}
94100

101+
const fallbackFromBackend: SubmissionInfo[] = []
102+
103+
if (backendChallengeSubmissions.length && myReviewerResourceIds.size) {
104+
backendChallengeSubmissions.forEach(submission => {
105+
const matchingReviews = (submission.review ?? []).filter(review => (
106+
Boolean(review?.resourceId) && myReviewerResourceIds.has(review.resourceId)
107+
))
108+
109+
matchingReviews.forEach(review => {
110+
const submissionForReviewer: BackendSubmission = {
111+
...submission,
112+
review: [review],
113+
reviewResourceMapping: {
114+
[review.resourceId]: review,
115+
},
116+
}
117+
fallbackFromBackend.push(
118+
convertBackendSubmissionToSubmissionInfo(submissionForReviewer),
119+
)
120+
})
121+
})
122+
}
123+
124+
if (fallbackFromBackend.length) {
125+
return fallbackFromBackend
126+
}
127+
95128
if (!challengeSubmissions.length) {
96129
return providedReviews
97130
}
@@ -100,8 +133,10 @@ export const TabContentReview: FC<Props> = (props: Props) => {
100133
return fallback.length ? fallback : providedReviews
101134
},
102135
[
136+
backendChallengeSubmissions,
103137
challengeSubmissions,
104138
hasReviewerAssignment,
139+
myReviewerResourceIds,
105140
providedReviews,
106141
],
107142
)

0 commit comments

Comments
 (0)