fix: show 'Unpaired device'

This commit is contained in:
Nikola Ubavic 2021-12-07 16:42:58 +01:00
parent f235eb93b9
commit da1a959a94

View file

@ -31,6 +31,15 @@ const AlertsTable = ({ numToRender, alerts, machines }) => {
const history = useHistory() const history = useHistory()
const classes = useStyles() const classes = useStyles()
const alertsToRender = R.slice(0, numToRender, alerts) const alertsToRender = R.slice(0, numToRender, alerts)
const alertMessage = alert => {
const deviceId = alert.detail.deviceId
if (!deviceId) return `${alert.message}`
const deviceName = R.defaultTo('Unpaired device', machines[deviceId])
return `${alert.message} - ${deviceName}`
}
return ( return (
<List dense className={classes.table}> <List dense className={classes.table}>
{alertsToRender.map((alert, idx) => { {alertsToRender.map((alert, idx) => {
@ -39,8 +48,7 @@ const AlertsTable = ({ numToRender, alerts, machines }) => {
{icons[alert.type] || ( {icons[alert.type] || (
<Wrench style={{ height: 23, width: 23, marginRight: 8 }} /> <Wrench style={{ height: 23, width: 23, marginRight: 8 }} />
)} )}
<P className={classes.listItemText}>{`${alert.message}${alert.detail <P className={classes.listItemText}>{alertMessage(alert)}</P>
.deviceId && ' - ' + machines[alert.detail.deviceId]}`}</P>
<LinkIcon <LinkIcon
className={classes.linkIcon} className={classes.linkIcon}
onClick={() => history.push(links[alert.type] || '/dashboard')} onClick={() => history.push(links[alert.type] || '/dashboard')}