11/**
22 * Content of checkpoint tab.
33 */
4- import { FC , useContext , useMemo } from 'react'
4+ import { FC , useCallback , useContext , useMemo } from 'react'
55
66import { TableLoading } from '~/apps/admin/src/lib'
77import { IsRemovingType } from '~/apps/admin/src/lib/models'
@@ -75,6 +75,32 @@ export const TabContentCheckpoint: FC<Props> = (props: Props) => {
7575 [ props . checkpointReview , myMemberIds , props . checkpointReviewMinimumPassingScore ] ,
7676 )
7777
78+ const checkpointScreeningOutcome = useMemo (
79+ ( ) => {
80+ const passingSubmissionIds = new Set < string > ( )
81+ const failingSubmissionIds = new Set < string > ( )
82+
83+ props . checkpoint . forEach ( entry => {
84+ if ( ! entry ?. submissionId ) {
85+ return
86+ }
87+
88+ const normalizedResult = ( entry . result || '' ) . toUpperCase ( )
89+ if ( normalizedResult === 'PASS' ) {
90+ passingSubmissionIds . add ( `${ entry . submissionId } ` )
91+ } else if ( normalizedResult === 'NO PASS' ) {
92+ failingSubmissionIds . add ( `${ entry . submissionId } ` )
93+ }
94+ } )
95+
96+ return {
97+ failingSubmissionIds,
98+ passingSubmissionIds,
99+ }
100+ } ,
101+ [ props . checkpoint ] ,
102+ )
103+
78104 const filteredCheckpoint = useMemo < Screening [ ] > (
79105 ( ) => {
80106 const baseRows = props . checkpoint ?? [ ]
@@ -107,9 +133,15 @@ export const TabContentCheckpoint: FC<Props> = (props: Props) => {
107133 ] ,
108134 )
109135
136+ const filterCheckpointReviewByScreeningResult = useCallback (
137+ ( screening : Screening [ ] ) => screening
138+ . filter ( row => checkpointScreeningOutcome . passingSubmissionIds . has ( `${ row . submissionId } ` ) ) ,
139+ [ checkpointScreeningOutcome ] ,
140+ )
141+
110142 const filteredCheckpointReview = useMemo < Screening [ ] > (
111143 ( ) => {
112- const baseRows = props . checkpointReview ?? [ ]
144+ const baseRows = filterCheckpointReviewByScreeningResult ( props . checkpointReview ?? [ ] )
113145
114146 if ( isPrivilegedRole || ( isChallengeCompleted && hasPassedCheckpointReviewThreshold ) ) {
115147 return baseRows
@@ -135,6 +167,7 @@ export const TabContentCheckpoint: FC<Props> = (props: Props) => {
135167 hasPassedCheckpointReviewThreshold ,
136168 checkpointReviewerResourceIds ,
137169 myMemberIds ,
170+ checkpointScreeningOutcome ,
138171 ] ,
139172 )
140173
0 commit comments