2021-05-27 01:47:23 +00:00
|
|
|
import React, { useMemo } from "react"
|
2021-05-25 15:06:53 +00:00
|
|
|
import BoxFullScrollable from "../base/BoxFullScrollable"
|
|
|
|
import SummaryAlert from "./SummaryAlert"
|
|
|
|
import useStrings from "../../hooks/useStrings"
|
2021-05-27 01:47:23 +00:00
|
|
|
import Empty from "./Empty"
|
2021-05-25 15:06:53 +00:00
|
|
|
|
|
|
|
|
|
|
|
export default function BoxAlerts({ alerts, destroy, running, ...props }) {
|
|
|
|
const strings = useStrings()
|
|
|
|
|
2021-05-27 01:47:23 +00:00
|
|
|
const content = useMemo(
|
|
|
|
() => {
|
|
|
|
if(alerts.length === 0) {
|
|
|
|
return <Empty/>
|
|
|
|
}
|
|
|
|
|
|
|
|
return alerts.map(alert => (
|
2021-05-30 15:47:11 +00:00
|
|
|
<SummaryAlert alert={alert} destroy={() => destroy(alert["id"])} key={alert["id"]} running={running}/>
|
2021-05-27 01:47:23 +00:00
|
|
|
))
|
|
|
|
},
|
|
|
|
[alerts, running, destroy]
|
|
|
|
)
|
|
|
|
|
2021-05-25 15:06:53 +00:00
|
|
|
return (
|
|
|
|
<BoxFullScrollable header={strings.alertTitle} {...props}>
|
2021-05-27 01:47:23 +00:00
|
|
|
{content}
|
2021-05-25 15:06:53 +00:00
|
|
|
</BoxFullScrollable>
|
|
|
|
)
|
|
|
|
}
|