Skip to content
Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { ActionLoading } from '~/apps/admin/src/lib'
import { ChallengeDetailContext } from '../../contexts'
import {
BackendSubmission,
ChallengeInfo,
ChallengeDetailContextModel,
MappingReviewAppeal,
Screening,
SubmissionInfo,
Expand Down Expand Up @@ -120,6 +120,7 @@ const buildScreeningRows = ({

interface SubmissionTabParams {
selectedTabNormalized: string
allowTopgearSubmissionList: boolean
submissions: BackendSubmission[]
screeningRows: Screening[]
screeningMinimumPassingScore: number | null | undefined
Expand All @@ -131,6 +132,7 @@ interface SubmissionTabParams {

const renderSubmissionTab = ({
selectedTabNormalized,
allowTopgearSubmissionList,
submissions,
screeningRows,
screeningMinimumPassingScore,
Expand All @@ -149,7 +151,7 @@ const renderSubmissionTab = ({
submission => normalizeType(submission.type) === 'contestsubmission',
)
: submissions
const canShowSubmissionList = !isTopgearSubmissionTab
const canShowSubmissionList = (allowTopgearSubmissionList || !isTopgearSubmissionTab)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[❗❗ correctness]
The logic for canShowSubmissionList has been modified to include allowTopgearSubmissionList. Ensure that this change aligns with the intended business logic, as it alters the conditions under which the submission list is displayed.

&& selectedTabNormalized !== 'screening'
&& visibleSubmissions.length > 0

Expand Down Expand Up @@ -178,8 +180,23 @@ const renderSubmissionTab = ({
}

export const ChallengeDetailsContent: FC<Props> = (props: Props) => {
const { challengeInfo }: { challengeInfo?: ChallengeInfo } = useContext(ChallengeDetailContext)
const {
challengeInfo,
myResources,
}: ChallengeDetailContextModel = useContext(ChallengeDetailContext)
const { actionChallengeRole }: useRoleProps = useRole()
const hasIterativeReviewerRole = useMemo(
() => myResources.some(
resource => resource.roleName
?.toLowerCase()
.includes('iterative reviewer'),
),
[myResources],
)
const allowTopgearSubmissionList = useMemo(

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[⚠️ performance]
The use of useMemo for allowTopgearSubmissionList is appropriate for performance optimization, but ensure that the dependencies [actionChallengeRole, hasIterativeReviewerRole] are exhaustive and correctly capture all factors influencing this value.

() => actionChallengeRole !== SUBMITTER || hasIterativeReviewerRole,
[actionChallengeRole, hasIterativeReviewerRole],
)
const { currentMemberId }: UseSubmissionDownloadAccessResult = useSubmissionDownloadAccess()
const {
isLoading: isDownloadingSubmission,
Expand Down Expand Up @@ -364,6 +381,7 @@ export const ChallengeDetailsContent: FC<Props> = (props: Props) => {

if (SUBMISSION_TAB_KEYS.has(selectedTabNormalized)) {
return renderSubmissionTab({
allowTopgearSubmissionList,
downloadSubmission: handleSubmissionDownload,
isActiveChallenge: props.isActiveChallenge,
isDownloadingSubmission,
Expand Down