1
0
mirror of https://github.com/karl0ss/homepage.git synced 2025-06-04 19:15:07 +01:00

30 lines
970 B
React
Raw Normal View History

2022-09-11 04:11:02 +01:00
import useSWR from "swr";
2022-09-25 19:43:00 +03:00
import { useTranslation } from "next-i18next";
2022-09-11 04:11:02 +01:00
import Widget from "../widget";
import Block from "../block";
2022-09-25 19:43:47 +03:00
import { formatProxyUrl } from "utils/api-helpers";
2022-09-11 04:11:02 +01:00
export default function Gotify({ service }) {
const { t } = useTranslation();
const config = service.widget;
2022-09-25 19:43:47 +03:00
const { data: appsData, error: appsError } = useSWR(formatProxyUrl(config, `application`));
const { data: messagesData, error: messagesError } = useSWR(formatProxyUrl(config, `message`));
const { data: clientsData, error: clientsError } = useSWR(formatProxyUrl(config, `client`));
2022-09-11 04:11:02 +01:00
if (appsError || messagesError || clientsError) {
return <Widget error={t("widget.api_error")} />;
}
return (
<Widget>
<Block label={t("gotify.apps")} value={appsData?.length} />
<Block label={t("gotify.clients")} value={clientsData?.length} />
<Block label={t("gotify.messages")} value={messagesData?.messages?.length} />
</Widget>
);
}