@@ -39,72 +39,84 @@ export function getCurrentPerProcessStep(status: PerProcessStatusResponse | unde
3939
4040export function getFormattedComponentName ( component : PerComponent ) : string {
4141 const { component_num, component_letter, title } = component ;
42-
4342 const prefix = [ component_num , component_letter ] . filter ( isDefined ) . join ( ' ' ) . trim ( ) ;
44-
45- return `${ prefix } : ${ title } ` ;
43+ return `${ prefix } : ${ title } ` ;
4644}
4745
48- export const perRatingColors = [
49- 'var(--go-ui-color-dark-blue-40)' ,
50- 'var(--go-ui-color-dark-blue-30)' ,
51- 'var(--go-ui-color-dark-blue-20)' ,
52- 'var(--go-ui-color-dark-blue-10)' ,
53- 'var(--go-ui-color-gray-40)' ,
54- 'var(--go-ui-color-gray-30)' ,
55- ] ;
56-
57- export const perRatingColorMap : {
58- [ key : string ] : string ;
59- } = {
60- 5 : 'var(--go-ui-color-dark-blue-40)' ,
61- 4 : 'var(--go-ui-color-dark-blue-30)' ,
62- 3 : 'var(--go-ui-color-dark-blue-20)' ,
63- 2 : 'var(--go-ui-color-dark-blue-10)' ,
64- 1 : 'var(--go-ui-color-gray-40)' ,
65- 0 : 'var(--go-ui-color-gray-30)' ,
66- } ;
46+ export const PER_FALLBACK_COLOR = 'var(--go-ui-color-gray-40)' ;
6747
68- export const perAreaColorMap : { [ key : number ] : string } = {
69- 1 : 'var(--go-ui-color-purple-per)' ,
70- 2 : 'var(--go-ui-color-orange-per)' ,
71- 3 : 'var(--go-ui-color-blue-per)' ,
72- 4 : 'var(--go-ui-color-teal-per)' ,
73- 5 : 'var(--go-ui-color-red-per)' ,
48+ export type PerRatingValue = 0 | 1 | 2 | 3 | 4 | 5 ;
49+ const PER_RATING_VALUE_NOT_REVIEWED = 0 satisfies PerRatingValue ;
50+ const PER_RATING_VALUE_DOES_NOT_EXIST = 1 satisfies PerRatingValue ;
51+ const PER_RATING_VALUE_PARTIALLY_EXISTS = 2 satisfies PerRatingValue ;
52+ const PER_RATING_VALUE_NEEDS_IMPROVEMENT = 3 satisfies PerRatingValue ;
53+ const PER_RATING_VALUE_EXISTS_COULD_BE_STRENGTHENED = 4 satisfies PerRatingValue ;
54+ const PER_RATING_VALUE_HIGH_PERFORMANCE = 5 satisfies PerRatingValue ;
55+
56+ const perRatingColorMap : Record < PerRatingValue , string > = {
57+ [ PER_RATING_VALUE_HIGH_PERFORMANCE ] : 'var(--go-ui-color-dark-blue-40)' ,
58+ [ PER_RATING_VALUE_EXISTS_COULD_BE_STRENGTHENED ] : 'var(--go-ui-color-dark-blue-30)' ,
59+ [ PER_RATING_VALUE_NEEDS_IMPROVEMENT ] : 'var(--go-ui-color-dark-blue-20)' ,
60+ [ PER_RATING_VALUE_PARTIALLY_EXISTS ] : 'var(--go-ui-color-dark-blue-10)' ,
61+ [ PER_RATING_VALUE_DOES_NOT_EXIST ] : 'var(--go-ui-color-gray-40)' ,
62+ [ PER_RATING_VALUE_NOT_REVIEWED ] : 'var(--go-ui-color-gray-30)' ,
7463} ;
7564
76- export const perBenchmarkColorMap : {
77- [ key : string ] : string ;
78- } = {
79- 1 : 'var(--go-ui-color-dark-blue-40)' ,
80- 2 : 'var(--go-ui-color-dark-blue-30)' ,
81- 5 : 'var(--go-ui-color-dark-blue-10)' ,
82- } ;
65+ export function getPerRatingColor ( value : number | undefined ) {
66+ if ( isDefined ( value ) ) {
67+ return perRatingColorMap [ value as PerRatingValue ] ?? PER_FALLBACK_COLOR ;
68+ }
69+ return PER_FALLBACK_COLOR ;
70+ }
71+ export function perRatingColorSelector ( item : { value : number | undefined } ) {
72+ return getPerRatingColor ( item . value ) ;
73+ }
8374
84- export const PER_FALLBACK_COLOR = 'var(--go-ui-color-gray-40)' ;
75+ export type PerAreaNumber = 1 | 2 | 3 | 4 | 5 ;
76+ const PER_AREA_NUMBER_1 = 1 satisfies PerAreaNumber ;
77+ const PER_AREA_NUMBER_2 = 2 satisfies PerAreaNumber ;
78+ const PER_AREA_NUMBER_3 = 3 satisfies PerAreaNumber ;
79+ const PER_AREA_NUMBER_4 = 4 satisfies PerAreaNumber ;
80+ const PER_AREA_NUMBER_5 = 5 satisfies PerAreaNumber ;
81+
82+ const perAreaColorMap : Record < PerAreaNumber , string > = {
83+ [ PER_AREA_NUMBER_1 ] : 'var(--go-ui-color-purple-per)' ,
84+ [ PER_AREA_NUMBER_2 ] : 'var(--go-ui-color-orange-per)' ,
85+ [ PER_AREA_NUMBER_3 ] : 'var(--go-ui-color-blue-per)' ,
86+ [ PER_AREA_NUMBER_4 ] : 'var(--go-ui-color-teal-per)' ,
87+ [ PER_AREA_NUMBER_5 ] : 'var(--go-ui-color-red-per)' ,
88+ } ;
8589
86- export function perRatingColorSelector ( item : {
87- value : number | undefined ;
88- } ) {
89- if ( isDefined ( item . value ) ) {
90- return perRatingColorMap [ item . value ] ;
90+ export function getPerAreaColor ( value : number | undefined ) {
91+ if ( isDefined ( value ) ) {
92+ return perAreaColorMap [ value as PerAreaNumber ] ?? PER_FALLBACK_COLOR ;
9193 }
9294 return PER_FALLBACK_COLOR ;
9395}
94-
9596export function perAreaColorSelector ( item : {
9697 value : number | undefined ;
9798} ) {
98- if ( isDefined ( item . value ) ) {
99- return perRatingColorMap [ item . value ] ;
100- }
101- return PER_FALLBACK_COLOR ;
99+ return getPerAreaColor ( item . value ) ;
102100}
103101
102+ type PerBenchmarkId = 1 | 2 | 5 ;
103+ const PER_BENCHMARK_YES = 1 satisfies PerBenchmarkId ;
104+ const PER_BENCHMARK_NO = 2 satisfies PerBenchmarkId ;
105+ const PER_BENCHMARK_PARTIALLY_EXISTS = 5 satisfies PerBenchmarkId ;
106+
107+ const perBenchmarkColorMap : Record < PerBenchmarkId , string > = {
108+ [ PER_BENCHMARK_YES ] : 'var(--go-ui-color-dark-blue-40)' ,
109+ [ PER_BENCHMARK_NO ] : 'var(--go-ui-color-dark-blue-30)' ,
110+ [ PER_BENCHMARK_PARTIALLY_EXISTS ] : 'var(--go-ui-color-dark-blue-10)' ,
111+ } ;
112+
113+ export function getPerBenchmarkColor ( id : number | undefined ) {
114+ return perBenchmarkColorMap [ id as PerBenchmarkId ] ?? PER_FALLBACK_COLOR ;
115+ }
104116export function perBenchmarkColorSelector ( item : {
105117 id : number ;
106118 label : string ;
107119 count : number ;
108120} ) {
109- return perBenchmarkColorMap [ item . id ] ;
121+ return getPerBenchmarkColor ( item . id ) ;
110122}
0 commit comments