1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-23 21:44:19 +00:00
pds-2021-g2-nest/nest_frontend/components/interactive/BoxAlerts.js
2021-05-30 17:47:11 +02:00

29 lines
824 B
JavaScript

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"])} key={alert["id"]} running={running}/>
))
},
[alerts, running, destroy]
)
return (
<BoxFullScrollable header={strings.alertTitle} {...props}>
{content}
</BoxFullScrollable>
)
}