@@ -24,18 +24,18 @@ export interface MapStopElement extends BaseMapElement {
2424 stopId : string ;
2525}
2626
27- export type MapElement = MapRouteElement | MapStopElement ;
27+ export type MapElementType = MapRouteElement | MapStopElement ;
2828
2929export interface MapElementProps {
30- mapElements : MapElement [ ] ;
30+ mapElements : MapElementType [ ] ;
3131}
3232
3333export const MapElement = (
3434 props : React . PropsWithChildren < MapElementProps > ,
3535) : JSX . Element => {
3636 const theme = useTheme ( ) ;
3737 const formatSet = new Set ( ) ;
38- const formattedElements : MapElement [ ] = [ ] ;
38+ const formattedElements : MapElementType [ ] = [ ] ;
3939
4040 props . mapElements . forEach ( ( element ) => {
4141 if ( ! formatSet . has ( element . name ) ) {
@@ -50,12 +50,12 @@ export const MapElement = (
5050 routeColorText : string ,
5151 ) : JSX . Element | null => {
5252 // The route type could be out of specs (e.g. google route types), so we may not have an icon.
53- if ( ! routeTypeMetadata || ! routeTypeMetadata . icon ) {
54- // Optionally render a default icon or return null
55- return null ;
53+ if ( routeTypeMetadata ? .icon == null ) {
54+ // Optionally render a default icon or return null
55+ return null ;
5656 }
5757 const { icon : Icon } = routeTypeMetadata ;
58- return < Icon style = { { color : routeColorText , fontSize : 20 } } /> ;
58+ return < Icon style = { { color : routeColorText , fontSize : 20 } } /> ;
5959 } ;
6060
6161 const renderRouteMapElement = ( element : MapRouteElement ) : JSX . Element => {
@@ -65,17 +65,23 @@ export const MapElement = (
6565 display : 'flex' ,
6666 alignItems : 'center' ,
6767 gap : 1 ,
68- color : element . routeTextColor
69- ? '#' + element . routeTextColor
70- : '000000' ,
71- background : element . routeColor ? '#' + element . routeColor : 'ffffff' ,
68+ color :
69+ element . routeTextColor !== ''
70+ ? '#' + element . routeTextColor
71+ : '#000000' ,
72+ background :
73+ element . routeColor !== '' ? '#' + element . routeColor : '#ffffff' ,
7274 padding : '5px' ,
7375 borderRadius : '5px' ,
7476 } }
7577 >
7678 { renderRouteTypeIcon (
77- routeTypesMapping [ element . routeType ?. toString ( ) || '0' ] ,
78- element . routeTextColor ? '#' + element . routeTextColor : '#000000' ,
79+ routeTypesMapping [
80+ element . routeType != null ? element . routeType . toString ( ) : '0'
81+ ] ,
82+ element . routeTextColor !== ''
83+ ? '#' + element . routeTextColor
84+ : '#000000' ,
7985 ) }
8086
8187 < Typography gutterBottom sx = { { color : 'inherit' , fontSize : 14 , m : 0 } } >
@@ -85,7 +91,10 @@ export const MapElement = (
8591 ) ;
8692 } ;
8793
88- const renderStopMapElement = ( element : MapStopElement , iconColor : string ) : JSX . Element => {
94+ const renderStopMapElement = (
95+ element : MapStopElement ,
96+ iconColor : string ,
97+ ) : JSX . Element => {
8998 return (
9099 < Box
91100 sx = { {
@@ -97,7 +106,9 @@ export const MapElement = (
97106 } }
98107 >
99108 { renderRouteTypeIcon (
100- locationTypesMapping [ element . locationType ?. toString ( ) || '0' ] ,
109+ locationTypesMapping [
110+ element . locationType != null ? element . locationType . toString ( ) : '0'
111+ ] ,
101112 iconColor ,
102113 ) }
103114
@@ -135,7 +146,12 @@ export const MapElement = (
135146 { element . isStop ? 'Stop' : 'Route' }
136147 </ Typography >
137148 { element . isStop ? (
138- < > { renderStopMapElement ( element as MapStopElement , theme . palette . text . primary ) } </ >
149+ < >
150+ { renderStopMapElement (
151+ element as MapStopElement ,
152+ theme . palette . text . primary ,
153+ ) }
154+ </ >
139155 ) : (
140156 < > { renderRouteMapElement ( element as MapRouteElement ) } </ >
141157 ) }
0 commit comments