Files
homepage/src/widgets/pyload/component.jsx
shamoon eda06965fa
Some checks are pending
Docker CI / Linting Checks (push) Waiting to run
Docker CI / Docker Build & Push (push) Blocked by required conditions
Chore: add organize imports to pre-commit (#5104)
2025-03-30 21:40:03 -07:00

36 lines
1.2 KiB
JavaScript

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: pyloadData, error: pyloadError } = useWidgetAPI(widget, "status");
if (pyloadError) {
return <Container service={service} error={pyloadError} />;
}
if (!pyloadData) {
return (
<Container service={service}>
<Block label="pyload.speed" />
<Block label="pyload.active" />
<Block label="pyload.queue" />
<Block label="pyload.total" />
</Container>
);
}
return (
<Container service={service}>
<Block label="pyload.speed" value={t("common.byterate", { value: pyloadData.speed })} />
<Block label="pyload.active" value={t("common.number", { value: pyloadData.active })} />
<Block label="pyload.queue" value={t("common.number", { value: pyloadData.queue })} />
<Block label="pyload.total" value={t("common.number", { value: pyloadData.total })} />
</Container>
);
}