@@ -20,6 +20,47 @@ const ResourceToPhaseNameMap = {
2020 'Checkpoint Screener' : 'Checkpoint Screening'
2121}
2222
23+ // Keep track filters aligned with the scorecards API regardless of legacy values
24+ const SCORECARD_TRACK_ALIASES = {
25+ DEVELOP : 'DEVELOPMENT' ,
26+ DEV : 'DEVELOPMENT' ,
27+ QA : 'QUALITY_ASSURANCE' ,
28+ QUALITY_ASSURANCE : 'QUALITY_ASSURANCE' ,
29+ QUALITYASSURANCE : 'QUALITY_ASSURANCE' ,
30+ DES : 'DESIGN' ,
31+ DESIGN : 'DESIGN' ,
32+ DS : 'DATA_SCIENCE' ,
33+ DATA_SCIENCE : 'DATA_SCIENCE' ,
34+ DATASCIENCE : 'DATA_SCIENCE'
35+ }
36+
37+ const normalizeTrackForScorecards = ( challenge , metadata ) => {
38+ const normalize = ( value ) => {
39+ if ( ! value ) return null
40+ const normalized = value . toString ( ) . trim ( ) . toUpperCase ( ) . replace ( / \s + / g, '_' )
41+ return SCORECARD_TRACK_ALIASES [ normalized ] || normalized
42+ }
43+
44+ if ( ! challenge ) return null
45+
46+ if ( challenge . trackId && metadata && Array . isArray ( metadata . challengeTracks ) ) {
47+ const trackFromMetadata = metadata . challengeTracks . find ( t => t . id === challenge . trackId )
48+ if ( trackFromMetadata ) {
49+ return normalize ( trackFromMetadata . track || trackFromMetadata . name || trackFromMetadata . abbreviation )
50+ }
51+ }
52+
53+ const { track } = challenge
54+ if ( typeof track === 'string' ) {
55+ return normalize ( track )
56+ }
57+ if ( track && typeof track === 'object' ) {
58+ return normalize ( track . track || track . name || track . abbreviation )
59+ }
60+
61+ return null
62+ }
63+
2364class ChallengeReviewerField extends Component {
2465 constructor ( props ) {
2566 super ( props )
@@ -327,19 +368,16 @@ class ChallengeReviewerField extends Component {
327368 }
328369
329370 loadScorecards ( ) {
330- const { challenge, loadScorecards } = this . props
371+ const { challenge, loadScorecards, metadata } = this . props
331372
332373 const filters = {
333374 status : 'ACTIVE'
334375 }
335376
336377 // Add challenge track if available
337- if ( challenge . track ) {
338- if ( typeof challenge . track === 'string' ) {
339- filters . challengeTrack = challenge . track . toUpperCase ( ) . replace ( ' ' , '_' )
340- } else if ( challenge . track . track ) {
341- filters . challengeTrack = challenge . track . track
342- }
378+ const normalizedTrack = normalizeTrackForScorecards ( challenge , metadata )
379+ if ( normalizedTrack ) {
380+ filters . challengeTrack = normalizedTrack
343381 }
344382
345383 // Add challenge type if available
@@ -1013,7 +1051,8 @@ ChallengeReviewerField.propTypes = {
10131051 scorecards : PropTypes . array ,
10141052 defaultReviewers : PropTypes . array ,
10151053 workflows : PropTypes . array ,
1016- resourceRoles : PropTypes . array
1054+ resourceRoles : PropTypes . array ,
1055+ challengeTracks : PropTypes . array
10171056 } ) ,
10181057 isLoading : PropTypes . bool ,
10191058 readOnly : PropTypes . bool ,
0 commit comments