diff options
Diffstat (limited to 'modern/src')
-rw-r--r-- | modern/src/DevicesList.js | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/modern/src/DevicesList.js b/modern/src/DevicesList.js index af463ab..fb89260 100644 --- a/modern/src/DevicesList.js +++ b/modern/src/DevicesList.js @@ -104,6 +104,19 @@ const DeviceRow = ({ data, index, style }) => { } }; + const getPositionHours = (pos, it) => { + if (it.category + && (it.category === 'backhoe' || it.category === 'tractor') + && pos) { + if (pos.attributes.io16) { + return formatHours(parseInt(position.attributes.io16) * 60 * 1000, t); + } else if (pos.attributes.hours) { + return formatHours(position.attributes.hours, t); + } + } + return null; + } + return ( <div style={style}> <ListItem button key={item.id} className={classes.listItem} onClick={() => { @@ -144,11 +157,8 @@ const DeviceRow = ({ data, index, style }) => { {/* Datetime */} <CalendarTodayIcon fontSize="inherit" /> {formatPosition(position, 'fixTime', t)} {/* Hours */} - {item.category - && (item.category.toLowerCase() === 'backhoe' || item.category.toLowerCase() === 'tractor' ) - && position.attributes.hours - && position.attributes.hours > 1 - && ` (${formatHours(position.attributes.hours, t)})`}<br /> + {getPositionHours(position, item) && ` (${getPositionHours(position, item)})`} + <br /> {/* Address */} {position.address && ( <> |