mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-06 17:15:34 -08:00
29 lines
845 B
JavaScript
29 lines
845 B
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 { data, error } = useWidgetAPI(service.widget);
|
|
|
|
if (error) {
|
|
return <Container service={service} error={error} />;
|
|
}
|
|
|
|
if (!data) {
|
|
return null;
|
|
}
|
|
|
|
const { up, bytesTx, bytesRx } = data;
|
|
|
|
return (
|
|
<Container service={service}>
|
|
<Block label="widget.status" value={up ? t("openwrt.up") : t("openwrt.down")} />
|
|
<Block label="openwrt.bytesTx" value={t("common.bytes", { value: bytesTx })} />
|
|
<Block label="openwrt.bytesRx" value={t("common.bytes", { value: bytesRx })} />
|
|
</Container>
|
|
);
|
|
}
|