import PropTypes from "prop-types";
import { Box, Stack, Typography, Divider } from "@mui/material";
import { useTheme } from "@emotion/react";
import { useTranslation } from "react-i18next";
import PanelSkeleton from "../IncidentsSummaryPanel/skeleton.jsx";
import IncidentItem from "./IncidentItem.jsx";
import SummaryCard from "../SummaryCard/index.jsx";
import Icon from "@/Components/v1/Icon";
/**
* LatestIncidentsPanel Component
*
* Displays a quick overview of recent incidents (both active and resolved).
* Shows only essential information: monitor name, status, duration, and resolution type.
*
* @param {Object} props
* @param {Array} props.incidents - Array of recent incidents
* @param {boolean} props.isLoading - Loading state
* @param {Object} props.error - Error object if any
*/
const LatestIncidentsPanel = ({ incidents = [], isLoading = false, error = null }) => {
const theme = useTheme();
const { t } = useTranslation();
if (isLoading) {
return ;
}
if (error) {
return (
{t("incidentsPage.incidentsLatestPanelError")}
);
}
return (
{!incidents || incidents.length === 0 ? (
{t("incidentsPage.incidentsLatestPanelEmpty")}
) : (
{incidents.map((incident, index) => (
{index < incidents.length - 1 && }
))}
)}
);
};
LatestIncidentsPanel.propTypes = {
incidents: PropTypes.arrayOf(
PropTypes.shape({
_id: PropTypes.string,
monitorId: PropTypes.string,
monitorName: PropTypes.string,
status: PropTypes.bool,
duration: PropTypes.string,
resolutionType: PropTypes.oneOf(["automatic", "manual"]),
})
),
isLoading: PropTypes.bool,
error: PropTypes.object,
onIncidentClick: PropTypes.func,
};
export default LatestIncidentsPanel;