File tree Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Expand file tree Collapse file tree 1 file changed +8
-4
lines changed Original file line number Diff line number Diff line change @@ -4,18 +4,22 @@ import { BADGE_CLASS_MAP } from 'utils/data'
44
55type BadgeProps = {
66 name : string
7- cssClass : string
7+ cssClass : string | undefined
88 showTooltip ?: boolean
99}
1010
1111const DEFAULT_ICON = BADGE_CLASS_MAP [ 'medal' ]
1212
13- const normalizeCssClass = ( cssClass : string ) => {
13+ const normalizeCssClass = ( cssClass : string | undefined ) => {
14+ if ( ! cssClass || cssClass . trim ( ) === '' ) {
15+ return ''
16+ }
17+
1418 // Convert backend snake_case format to frontend camelCase format
15- return cssClass . replace ( / _ ( [ a - z ] ) / g, ( _ , letter ) => letter . toUpperCase ( ) )
19+ return cssClass . trim ( ) . replace ( / _ ( [ a - z ] ) / g, ( _ , letter ) => letter . toUpperCase ( ) )
1620}
1721
18- const resolveIcon = ( cssClass : string ) => {
22+ const resolveIcon = ( cssClass : string | undefined ) => {
1923 const normalizedClass = normalizeCssClass ( cssClass )
2024 return BADGE_CLASS_MAP [ normalizedClass ] ?? DEFAULT_ICON
2125}
You can’t perform that action at this time.
0 commit comments