@@ -66,6 +66,11 @@ interface Props {
6666 className ?: string
6767}
6868
69+ const normalizePhaseName = ( name ?: string ) : string => ( name ? name . trim ( )
70+ . toLowerCase ( ) : '' )
71+ const SUBMISSION_PHASE_NAMES = new Set ( [ 'submission' , 'topgear submission' ] )
72+ const REGISTRATION_PHASE_NAME = 'registration'
73+
6974// Helpers to keep UI hooks simple and under complexity limits
7075
7176// Compute a Set of this member's reviewer resource IDs (excluding iterative roles)
@@ -1089,23 +1094,41 @@ export const ChallengeDetailsPage: FC<Props> = (props: Props) => {
10891094 return allowed
10901095 }
10911096
1092- challengePhases . forEach ( phase => {
1093- if ( ! phase ?. isOpen || ! phase . predecessor ) {
1097+ const addPhaseIdentifiers = ( phase ?: BackendPhase ) : void => {
1098+ if ( ! phase ) {
10941099 return
10951100 }
10961101
1097- allowed . add ( phase . predecessor )
1102+ if ( phase . id ) {
1103+ allowed . add ( phase . id )
1104+ }
10981105
1099- const predecessorPhase = phaseLookup . get ( phase . predecessor )
1100- if ( predecessorPhase ?. id ) {
1101- allowed . add ( predecessorPhase . id )
1106+ if ( phase . phaseId ) {
1107+ allowed . add ( phase . phaseId )
11021108 }
1109+ }
11031110
1104- if ( predecessorPhase ?. phaseId ) {
1105- allowed . add ( predecessorPhase . phaseId )
1111+ challengePhases . forEach ( phase => {
1112+ if ( ! phase ?. isOpen || ! phase . predecessor ) {
1113+ return
11061114 }
1115+
1116+ allowed . add ( phase . predecessor )
1117+ addPhaseIdentifiers ( phaseLookup . get ( phase . predecessor ) )
11071118 } )
11081119
1120+ const hasSubmissionVariantOpen = challengePhases . some ( phase => (
1121+ phase ?. isOpen && SUBMISSION_PHASE_NAMES . has ( normalizePhaseName ( phase . name ) )
1122+ ) )
1123+
1124+ if ( hasSubmissionVariantOpen ) {
1125+ challengePhases . forEach ( phase => {
1126+ if ( normalizePhaseName ( phase ?. name ) === REGISTRATION_PHASE_NAME ) {
1127+ addPhaseIdentifiers ( phase )
1128+ }
1129+ } )
1130+ }
1131+
11091132 return allowed
11101133 } , [ challengePhases , phaseLookup ] )
11111134
0 commit comments