1
Fork 0
mirror of https://github.com/pds-nest/nest.git synced 2024-11-25 06:24:19 +00:00
pds-2021-g2-nest/nest_frontend/components/interactive/SummaryAlert.js

50 lines
1.6 KiB
JavaScript
Raw Normal View History

2021-05-25 15:10:40 +00:00
import React from "react"
import { faBell, faTrash } from "@fortawesome/free-solid-svg-icons"
2021-05-25 15:06:53 +00:00
import SummaryBase from "../base/summary/SummaryBase"
import SummaryLeft from "../base/summary/SummaryLeft"
import SummaryLabels from "../base/summary/SummaryLabels"
import SummaryButton from "../base/summary/SummaryButton"
import SummaryRight from "../base/summary/SummaryRight"
import useStrings from "../../hooks/useStrings"
/**
* A {@link SummaryBase} representing a N.E.S.T. alert.
*
* @param alert - The alert to represent.
* @param destroy - Async function with no parameters to destroy the alert from the frontend.
* @param running - Whether another request is already running.
* @param props - Additional props to pass to the summary.
* @returns {JSX.Element}
* @constructor
*/
export default function SummaryAlert({ alert, destroy, running, ...props }) {
const strings = useStrings()
return (
<SummaryBase {...props}>
<SummaryLeft
icon={faBell}
title={alert.name}
/>
<SummaryLabels
upperLabel={strings.alertLimit}
upperValue={alert.limit}
lowerLabel={strings.alertWindow}
lowerValue={alert.window_size}
/>
{destroy ?
<SummaryButton
color={"Red"}
icon={faTrash}
onClick={destroy}
disabled={running}
>
{strings.delete}
</SummaryButton>
: null}
<SummaryRight/>
</SummaryBase>
)
}