import Block from "components/services/widget/block"; import Container from "components/services/widget/container"; import { useTranslation } from "next-i18next"; import useWidgetAPI from "utils/proxy/use-widget-api"; export default function Component({ service }) { const { t } = useTranslation(); const { widget } = service; const { data: storageData, error: storageError } = useWidgetAPI(widget, "storage"); if (storageError) { return ; } if (!storageData) { return ( ); } const { pools } = storageData; if (!Array.isArray(pools) || pools.length === 0) { return ( ); } const totalBytes = pools.reduce((sum, p) => sum + (p.capacity ?? 0), 0); const usedBytes = pools.reduce((sum, p) => sum + (p.usage ?? 0), 0); const availableBytes = Math.max(0, totalBytes - usedBytes); const status = pools.some((p) => p.status === "degraded") ? "degraded" : pools[0]?.status; let statusValue = status; if (status === "fullyOperational" || status === "noDataProtectionYet") statusValue = t("unifi_drive.healthy"); else if (status === "degraded") statusValue = t("unifi_drive.degraded"); return ( ); }