Skip to content

Commit

Permalink
Handle undefined position values
Browse files Browse the repository at this point in the history
  • Loading branch information
tananaev committed Oct 31, 2024
1 parent 5993696 commit 274ee52
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/common/components/PositionValue.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,10 @@ const PositionValue = ({ position, property, attribute }) => {
}
};

if (value === undefined) {
return '';
}

switch (key) {
case 'image':
case 'video':
Expand All @@ -110,20 +114,11 @@ const PositionValue = ({ position, property, attribute }) => {
case 'address':
return <AddressValue latitude={position.latitude} longitude={position.longitude} originalAddress={value} />;
case 'network':
if (value) {
return <Link component={RouterLink} underline="none" to={`/network/${position.id}`}>{t('sharedInfoTitle')}</Link>;
}
return '';
return <Link component={RouterLink} underline="none" to={`/network/${position.id}`}>{t('sharedInfoTitle')}</Link>;
case 'geofenceIds':
if (value) {
return <GeofencesValue geofenceIds={value} />;
}
return '';
return <GeofencesValue geofenceIds={value} />;
case 'driverUniqueId':
if (value) {
return <DriverValue driverUniqueId={value} />;
}
return '';
return <DriverValue driverUniqueId={value} />;
default:
return formatValue(value);
}
Expand Down

2 comments on commit 274ee52

@joystickjockey
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Anton,

After this change on my customised copy of master I get web errors when selecting the "More Details" for a device that is not in a geofence. For devices in a geofence there are no errors.

If I revert back to the below code for geofence the error is gone.

  if (value) {
    return <GeofencesValue geofenceIds={value} />;
  }
  return '';

@tananaev
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reporting. It should be fixed now.

Please sign in to comment.