Skip to content

Commit

Permalink
fix friend not seperating between real and integers
Browse files Browse the repository at this point in the history
  • Loading branch information
kistenklaus committed Jul 18, 2024
1 parent 68ef1da commit 20bc4f6
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions src/object_entry/vis/errors/ErrorListItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,30 @@ 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";
import { isInt, isReal, isUInt } from "../../types/Type.tsx";



interface ErrorListItemProps {
event : ErrorEvent
event: ErrorEvent
}

interface FriendItemProps {
friend : Friend,
friend: Friend,
}

function FriendItem({friend} : Readonly<FriendItemProps>) {
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);

console.log("value", value);
if (value === undefined || value === null || info === undefined) {
return <></>;
}else {
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 {
if (info.ty !== undefined && (isInt(info.ty.id) || isUInt(info.ty.id))) {
return <Typography>{`${(Number.parseInt(value as any) as number)} ${(info?.unit !== undefined && info?.unit !== null) ? info.unit : ""}`}</Typography>
} else if (info.ty !== undefined && isReal(info.ty.id)) {
return <Typography>{`${(value as number)} ${(info?.unit !== undefined && info?.unit !== null) ? info.unit : ""}`}</Typography>
} else {
return <Typography>{`${value} ${(info?.unit !== undefined && info?.unit !== null) ? info.unit : ""}`}</Typography>
}
Expand Down Expand Up @@ -80,7 +83,7 @@ function ErrorListItem({
}}
secondaryAction={
<ListItemText>
{(event.friend !== undefined && event.friend !== null) ? <FriendItem friend={event.friend}/> : <></>}
{(event.friend !== undefined && event.friend !== null) ? <FriendItem friend={event.friend} /> : <></>}
</ListItemText>
}
>
Expand Down

0 comments on commit 20bc4f6

Please sign in to comment.