1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-29 07:54:19 +00:00

🔧 Display <Empty/> when there are no alerts

This commit is contained in:
Steffo 2021-05-27 03:47:23 +02:00
parent 8e868dc29b
commit 65ccebf856
Signed by: steffo
GPG key ID: 6965406171929D01

View file

@ -1,15 +1,29 @@
import React from "react" import React, { useMemo } from "react"
import BoxFullScrollable from "../base/BoxFullScrollable" import BoxFullScrollable from "../base/BoxFullScrollable"
import SummaryAlert from "./SummaryAlert" import SummaryAlert from "./SummaryAlert"
import useStrings from "../../hooks/useStrings" import useStrings from "../../hooks/useStrings"
import Empty from "./Empty"
export default function BoxAlerts({ alerts, destroy, running, ...props }) { export default function BoxAlerts({ alerts, destroy, running, ...props }) {
const strings = useStrings() 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 ( return (
<BoxFullScrollable header={strings.alertTitle} {...props}> <BoxFullScrollable header={strings.alertTitle} {...props}>
{alerts.map(alert => <SummaryAlert alert={alert} destroy={() => destroy(alert["id"])} running={running}/>)} {content}
</BoxFullScrollable> </BoxFullScrollable>
) )
} }