mirror of
https://github.com/gethomepage/homepage.git
synced 2026-09-12 07:05:56 -07:00
81accd8dbe
Lint / Linting Checks (push) Has been cancelled
Release Drafter / Update Release Draft (push) Has been cancelled
Docker CI / Docker Build & Push (push) Has been cancelled
Tests / vitest (1) (push) Has been cancelled
Tests / vitest (2) (push) Has been cancelled
Release Drafter / Auto Label PR (push) Has been cancelled
Tests / vitest (3) (push) Has been cancelled
Tests / vitest (4) (push) Has been cancelled
Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com> Signed-off-by: dependabot[bot] <support@github.com>
43 lines
1.2 KiB
React
43 lines
1.2 KiB
React
import { useTranslation } from "next-i18next/pages";
|
|
|
|
import Block from "components/services/widget/block";
|
|
import Container from "components/services/widget/container";
|
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
|
|
|
export default function Component({ service }) {
|
|
const { t } = useTranslation();
|
|
|
|
const { widget } = service;
|
|
|
|
const { data, error } = useWidgetAPI(widget, "info");
|
|
|
|
if (error) {
|
|
return <Container service={service} error={error} />;
|
|
}
|
|
|
|
if (!data) {
|
|
return (
|
|
<Container service={service}>
|
|
<Block label="changedetectionio.diffsDetected" />
|
|
<Block label="changedetectionio.totalObserved" />
|
|
</Container>
|
|
);
|
|
}
|
|
|
|
const totalObserved = Object.keys(data).length;
|
|
let diffsDetected = 0;
|
|
|
|
Object.keys(data).forEach((key) => {
|
|
if (data[key].last_changed > 0 && !data[key].viewed) {
|
|
diffsDetected += 1;
|
|
}
|
|
});
|
|
|
|
return (
|
|
<Container service={service}>
|
|
<Block label="changedetectionio.diffsDetected" value={t("common.number", { value: diffsDetected })} />
|
|
<Block label="changedetectionio.totalObserved" value={t("common.number", { value: totalObserved })} />
|
|
</Container>
|
|
);
|
|
}
|