import { useTranslation } from "next-i18next"; import Container from "components/services/widget/container"; import Block from "components/services/widget/block"; import useWidgetAPI from "utils/proxy/use-widget-api"; export default function Component({ service }) { const { t } = useTranslation(); const { widget } = service; const { systemId } = widget; const { data: systems, error: systemsError } = useWidgetAPI(widget, "systems"); const MAX_ALLOWED_FIELDS = 4; if (!widget.fields?.length > 0) { widget.fields = systemId ? ["name", "status", "cpu", "memory"] : ["systems", "up"]; } if (widget.fields?.length > MAX_ALLOWED_FIELDS) { widget.fields = widget.fields.slice(0, MAX_ALLOWED_FIELDS); } if (systemsError) { return ; } if (!systems) { return ( ); } if (systemId) { const system = systems.items.find((item) => item.id === systemId); return ( ); } const upTotal = systems.items.filter((item) => item.status === "up").length; return ( ); }