import React, { useMemo } from "react";
import { useSelector } from "../../store/redux-separate-context";
import { selectActiveAlarms } from "../../domains/global/selectors";
import Item from "./item";
import Pill from "./pill";
const pillProps = {
    "data-toggle": "modal",
    "data-target": "#alarmsModal",
};
const Alarms = () => {
    const activeAlarms = useSelector(selectActiveAlarms);
    const alarms = useMemo(() => (activeAlarms ? Object.values(activeAlarms.alarms) : []), [
        activeAlarms,
    ]);
    const { critical, warning } = useMemo(() => alarms.reduce((acc, { status }) => {
        if (status === "CRITICAL")
            acc.critical = acc.critical + 1;
        if (status === "WARNING")
            acc.warning = acc.warning + 1;
        return acc;
    }, { critical: 0, warning: 0 }), [alarms]);
    return (React.createElement(Item, { icon: "alarm" },
        React.createElement(Pill, Object.assign({ background: "error", hollow: true }, pillProps), critical),
        React.createElement(Pill, Object.assign({ background: "warning", hollow: true }, pillProps), warning)));
};
export default Alarms;
//# sourceMappingURL=alarms.js.map