mirror of
https://github.com/pds-nest/nest.git
synced 2024-11-25 14:34:19 +00:00
🔧 Display <Empty/> when there are no alerts
This commit is contained in:
parent
8e868dc29b
commit
65ccebf856
1 changed files with 16 additions and 2 deletions
|
@ -1,15 +1,29 @@
|
|||
import React from "react"
|
||||
import React, { useMemo } from "react"
|
||||
import BoxFullScrollable from "../base/BoxFullScrollable"
|
||||
import SummaryAlert from "./SummaryAlert"
|
||||
import useStrings from "../../hooks/useStrings"
|
||||
import Empty from "./Empty"
|
||||
|
||||
|
||||
export default function BoxAlerts({ alerts, destroy, running, ...props }) {
|
||||
const strings = useStrings()
|
||||
|
||||
const content = useMemo(
|
||||
() => {
|
||||
if(alerts.length === 0) {
|
||||
return <Empty/>
|
||||
}
|
||||
|
||||
return alerts.map(alert => (
|
||||
<SummaryAlert alert={alert} destroy={() => destroy(alert["id"])} running={running}/>
|
||||
))
|
||||
},
|
||||
[alerts, running, destroy]
|
||||
)
|
||||
|
||||
return (
|
||||
<BoxFullScrollable header={strings.alertTitle} {...props}>
|
||||
{alerts.map(alert => <SummaryAlert alert={alert} destroy={() => destroy(alert["id"])} running={running}/>)}
|
||||
{content}
|
||||
</BoxFullScrollable>
|
||||
)
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue