diff --git a/src/components/monitoringMenu.tsx b/src/components/monitoringMenu.tsx index 3c14629..60b3fe1 100644 --- a/src/components/monitoringMenu.tsx +++ b/src/components/monitoringMenu.tsx @@ -29,11 +29,10 @@ export default function MonitoringMenu({ monitoredVessels, zoomToVessel }: IMoni {!isCollapsed && ( <> -
-

MMSI

-

Trust

-

Reason

-

Find vessel

+
+

MMSI

+

Trust

+

Reason

{sortedMonitoredVessels.map((vessel, index) => ( diff --git a/src/components/monitoringMenuRow.tsx b/src/components/monitoringMenuRow.tsx index 3fe090d..b420a53 100644 --- a/src/components/monitoringMenuRow.tsx +++ b/src/components/monitoringMenuRow.tsx @@ -19,29 +19,46 @@ export default function MonitoringMenuRow({ monitoredVessel, zoomToCallback }: I } } + function convertToReasons(reason: string | undefined): string[] { + const separator = ' | ' + if (reason === undefined || reason.length === 0) { + return [] + } + return reason.split(separator) + } + function handleClick(e: React.MouseEvent) { e.stopPropagation() setSelectedVesselmmsi(monitoredVessel.mmsi) zoomToCallback(monitoredVessel) } + return (
-

{monitoredVessel.mmsi}

-

{(Math.round(monitoredVessel.trustworthiness * 1000) / 10).toFixed(2)}%

-

- {monitoredVessel.reason} -

+

{monitoredVessel.mmsi}

+

{(Math.round(monitoredVessel.trustworthiness * 1000) / 10).toFixed(2)}%

+ {selectedVesselmmsi === monitoredVessel.mmsi ? ( +
+ {convertToReasons(monitoredVessel.reason).map((reason, index) => ( + + {reason} + + ))} +
+ ) : ( +

+ {monitoredVessel.reason} +

+ )} - {selectedVesselmmsi === monitoredVessel.mmsi && ( + {selectedVesselmmsi === monitoredVessel.mmsi ? ( - )} - - {selectedVesselmmsi !== monitoredVessel.mmsi && ( + ) : (
Zoom
)}