homepage/src/widgets/gotify/component.jsx

28 lines
979 B
React
Raw Normal View History

import { useTranslation } from "next-i18next";
2022-09-26 15:25:10 +03:00
import Container from "components/services/widget/container";
import Block from "components/services/widget/block";
2022-09-27 22:59:14 +03:00
import useWidgetAPI from "utils/proxy/use-widget-api";
export default function Component({ service }) {
const { t } = useTranslation();
2022-09-27 22:59:14 +03:00
const { widget } = service;
2022-09-27 22:59:14 +03:00
const { data: appsData, error: appsError } = useWidgetAPI(widget, "application");
const { data: messagesData, error: messagesError } = useWidgetAPI(widget, "message");
const { data: clientsData, error: clientsError } = useWidgetAPI(widget, "client");
if (appsError || messagesError || clientsError) {
2022-09-26 15:25:10 +03:00
return <Container error={t("widget.api_error")} />;
}
return (
2022-09-26 15:25:10 +03:00
<Container>
<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} />
2022-09-26 15:25:10 +03:00
</Container>
);
}