Skip to content

Commit

Permalink
Fix Friend item conversion.
Browse files Browse the repository at this point in the history
  • Loading branch information
NiklasHeneka committed Jul 18, 2024
1 parent e355717 commit 9a75bc8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/object_entry/vis/errors/ErrorListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import WarningIcon from '@mui/icons-material/Warning';
import useObjectEntryValue from "../../../hooks/object_entry_value";
import useObjectEntryInfo from "../../../hooks/object_entry_info";
import { ErrorEvent, Friend } from "../../types/events/ErrorEvent";
import {isInt, isReal, isUInt} from "../../types/Type.tsx";



Expand All @@ -21,10 +22,14 @@ function FriendItem({friend} : Readonly<FriendItemProps>) {
const value = useObjectEntryValue(friend.node_name, friend.object_entry_name);
const info = useObjectEntryInfo(friend.node_name, friend.object_entry_name);

if (value === undefined || value === null) {
if (value === undefined || value === null || info === undefined) {
return <></>;
}else {
return <Typography>{`${(value as number).toFixed(2)} ${(info?.unit !== undefined && info?.unit !== null) ? info.unit : ""}`}</Typography>
if (info.ty !== undefined && (isInt(info.ty.id) || isUInt(info.ty.id) || isReal(info.ty.id))) {
return <Typography>{`${(value as number).toFixed(2)} ${(info?.unit !== undefined && info?.unit !== null) ? info.unit : ""}`}</Typography>
} else {
return <Typography>{`${value} ${(info?.unit !== undefined && info?.unit !== null) ? info.unit : ""}`}</Typography>
}

}
}
Expand Down

0 comments on commit 9a75bc8

Please sign in to comment.