import React, { FC } from 'react'; import { RouteComponentProps } from '@reach/router'; import PathPrefixProps from '../../PathPrefixProps'; import { useFetch } from '../../utils/useFetch'; import { withStatusIndicator } from '../../withStatusIndicator'; import AlertsContent, { RuleStatus, AlertsProps } from './AlertContents'; const AlertsWithStatusIndicator = withStatusIndicator(AlertsContent); const Alerts: FC = ({ pathPrefix = '' }) => { const { response, error, isLoading } = useFetch(`${pathPrefix}/api/v1/rules?type=alert`); const ruleStatsCount: RuleStatus = { inactive: 0, pending: 0, firing: 0, }; if (response.data && response.data.groups) { response.data.groups.forEach(el => el.rules.forEach(r => ruleStatsCount[r.state]++)); } return ( ); }; export default Alerts;