diff --git a/client/src/pages/MapView.jsx b/client/src/pages/MapView.jsx
index 278339e..f0f8862 100644
--- a/client/src/pages/MapView.jsx
+++ b/client/src/pages/MapView.jsx
@@ -613,7 +613,16 @@ const DevicePopup = ({ device, status, detections }) => (
Coordinates: {device.geo_lat}, {device.geo_lon}
{device.last_heartbeat && (
- Last seen: {format(new Date(device.last_heartbeat), 'MMM dd, HH:mm')}
+ Last seen: {(() => {
+ try {
+ if (device.last_heartbeat && !isNaN(new Date(device.last_heartbeat).getTime())) {
+ return format(new Date(device.last_heartbeat), 'MMM dd, HH:mm');
+ }
+ } catch (e) {
+ console.warn('Invalid last_heartbeat timestamp:', device.last_heartbeat, e);
+ }
+ return 'Invalid time';
+ })()}
)}
@@ -722,19 +731,33 @@ const DroneDetectionPopup = ({ detection, age, droneTypes, droneDetectionHistory
First detected:
- {firstDetection.device_timestamp ?
- format(new Date(firstDetection.device_timestamp), 'MMM dd, HH:mm:ss') :
- 'Unknown'
- }
+ {(() => {
+ const timestamp = firstDetection.device_timestamp || firstDetection.timestamp || firstDetection.server_timestamp;
+ try {
+ if (timestamp && !isNaN(new Date(timestamp).getTime())) {
+ return format(new Date(timestamp), 'MMM dd, HH:mm:ss');
+ }
+ } catch (e) {
+ console.warn('Invalid firstDetection timestamp:', timestamp, e);
+ }
+ return 'Unknown';
+ })()}
Latest detection:
- {detection.device_timestamp ?
- format(new Date(detection.device_timestamp), 'MMM dd, HH:mm:ss') :
- 'Unknown'
- }
+ {(() => {
+ const timestamp = detection.device_timestamp || detection.timestamp || detection.server_timestamp;
+ try {
+ if (timestamp && !isNaN(new Date(timestamp).getTime())) {
+ return format(new Date(timestamp), 'MMM dd, HH:mm:ss');
+ }
+ } catch (e) {
+ console.warn('Invalid detection timestamp:', timestamp, e);
+ }
+ return 'Unknown';
+ })()}
{droneHistory.length > 1 && (
@@ -782,7 +805,17 @@ const DroneDetectionPopup = ({ detection, age, droneTypes, droneDetectionHistory
'bg-green-400'
}`}
style={{ height: `${height}px` }}
- title={`${hist.rssi}dBm at ${format(new Date(hist.device_timestamp), 'HH:mm:ss')}`}
+ title={`${hist.rssi}dBm at ${(() => {
+ const timestamp = hist.device_timestamp || hist.timestamp || hist.server_timestamp;
+ try {
+ if (timestamp && !isNaN(new Date(timestamp).getTime())) {
+ return format(new Date(timestamp), 'HH:mm:ss');
+ }
+ } catch (e) {
+ console.warn('Invalid timestamp:', timestamp, e);
+ }
+ return 'Invalid time';
+ })()}`}
/>
);
})}