@@ -36,6 +36,7 @@ import MapContainerWithDisclaimer from '#components/MapContainerWithDisclaimer';
3636import MapPopup from '#components/MapPopup' ;
3737import useAuth from '#hooks/domain/useAuth' ;
3838import useFilterState from '#hooks/useFilterState' ;
39+ import { chooseName } from '#utils/common' ;
3940import {
4041 COLOR_DARK_GREY ,
4142 COLOR_PRIMARY_BLUE ,
@@ -330,6 +331,16 @@ function LocalUnitsMap() {
330331 && countryResponse . emails . length > 0 ;
331332 const hasContactDetails = hasAddress || hasEmails ;
332333
334+ const localUnitName = useMemo ( ( ) => chooseName (
335+ localUnitDetail ?. local_branch_name ,
336+ localUnitDetail ?. english_branch_name ,
337+ ) , [ localUnitDetail ?. local_branch_name , localUnitDetail ?. english_branch_name ] ) ;
338+
339+ const localUnitAddress = useMemo ( ( ) => chooseName (
340+ localUnitDetail ?. address_loc ,
341+ localUnitDetail ?. address_en ,
342+ ) , [ localUnitDetail ?. address_loc , localUnitDetail ?. address_en ] ) ;
343+
333344 return (
334345 < Container
335346 className = { styles . localUnitsMap }
@@ -410,9 +421,7 @@ function LocalUnitsMap() {
410421 popupClassName = { styles . mapPopup }
411422 coordinates = { clickedPointProperties . lngLat }
412423 onCloseButtonClick = { handlePointClose }
413- heading = { isTruthyString ( localUnitDetail ?. english_branch_name )
414- ? localUnitDetail ?. english_branch_name
415- : localUnitDetail ?. local_branch_name ?? '--' }
424+ heading = { localUnitName }
416425 contentViewType = "vertical"
417426 pending = { localUnitDetailPending }
418427 errored = { isDefined ( localUnitDetailError ) }
@@ -429,8 +438,7 @@ function LocalUnitsMap() {
429438 < TextOutput
430439 label = { strings . localUnitDetailAddress }
431440 strongLabel
432- value = { localUnitDetail ?. address_en
433- ?? localUnitDetail ?. address_loc }
441+ value = { localUnitAddress }
434442 />
435443 < TextOutput
436444 label = { strings . localUnitLocalUnitType }
@@ -507,48 +515,50 @@ function LocalUnitsMap() {
507515 </ Container >
508516 ) }
509517 </ div >
510- { isDefined ( localUnitsOptions ) && (
511- < Container
512- contentViewType = "vertical"
513- spacing = "comfortable"
514- >
515- < Container
516- heading = { strings . localUnitLegendLocalUnitTitle }
517- headingLevel = { 4 }
518- contentViewType = "grid"
519- numPreferredGridContentColumns = { 5 }
520- spacing = "compact"
521- >
522- { localUnitsOptions ?. type . map ( ( legendItem ) => (
523- < LegendItem
524- key = { legendItem . id }
525- iconSrc = { legendItem . image_url }
526- iconClassName = { styles . legendIcon }
527- color = { legendItem . colour ?? COLOR_DARK_GREY }
528- label = { legendItem . name }
529- />
530- ) ) }
531- </ Container >
518+ {
519+ isDefined ( localUnitsOptions ) && (
532520 < Container
533- heading = { strings . localUnitLegendHealthCareTitle }
534- headingLevel = { 5 }
535- contentViewType = "grid"
536- numPreferredGridContentColumns = { 5 }
537- spacing = "compact"
521+ contentViewType = "vertical"
522+ spacing = "comfortable"
538523 >
539- { localUnitsOptions ?. health_facility_type . map ( ( legendItem ) => (
540- < LegendItem
541- key = { legendItem . id }
542- // FIXME: use color from server
543- color = { COLOR_PRIMARY_BLUE }
544- iconSrc = { legendItem . image_url }
545- iconClassName = { styles . legendIcon }
546- label = { legendItem . name }
547- />
548- ) ) }
524+ < Container
525+ heading = { strings . localUnitLegendLocalUnitTitle }
526+ headingLevel = { 4 }
527+ contentViewType = "grid"
528+ numPreferredGridContentColumns = { 5 }
529+ spacing = "compact"
530+ >
531+ { localUnitsOptions ?. type . map ( ( legendItem ) => (
532+ < LegendItem
533+ key = { legendItem . id }
534+ iconSrc = { legendItem . image_url }
535+ iconClassName = { styles . legendIcon }
536+ color = { legendItem . colour ?? COLOR_DARK_GREY }
537+ label = { legendItem . name }
538+ />
539+ ) ) }
540+ </ Container >
541+ < Container
542+ heading = { strings . localUnitLegendHealthCareTitle }
543+ headingLevel = { 5 }
544+ contentViewType = "grid"
545+ numPreferredGridContentColumns = { 5 }
546+ spacing = "compact"
547+ >
548+ { localUnitsOptions ?. health_facility_type . map ( ( legendItem ) => (
549+ < LegendItem
550+ key = { legendItem . id }
551+ // FIXME: use color from server
552+ color = { COLOR_PRIMARY_BLUE }
553+ iconSrc = { legendItem . image_url }
554+ iconClassName = { styles . legendIcon }
555+ label = { legendItem . name }
556+ />
557+ ) ) }
558+ </ Container >
549559 </ Container >
550- </ Container >
551- ) }
560+ )
561+ }
552562 </ Container >
553563 ) ;
554564}
0 commit comments