import useSWR from "swr"; import { FiHardDrive } from "react-icons/fi"; import { BiError } from "react-icons/bi"; import { useTranslation } from "react-i18next"; import UsageBar from "./usage-bar"; export default function Disk({ options }) { const { t } = useTranslation(); const { data, error } = useSWR(`/api/widgets/resources?type=disk&target=${options.disk}`, { refreshInterval: 1500, }); if (error || data?.error) { return (
{t("widget.api_error")}
); } if (!data) { return (
-
); } const percent = Math.round((data.drive.usedGb / data.drive.totalGb) * 100); return (
{t("common.bytes", { value: data.drive.freeGb * 1024 * 1024 * 1024 })} {t("resources.free")} {t("common.bytes", { value: data.drive.totalGb * 1024 * 1024 * 1024 })} {t("resources.total")}
); }