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";
|
2022-09-25 16:15:47 -07:00
|
|
|
|
|
|
|
export default function Component({ service }) {
|
2022-09-27 22:59:14 +03:00
|
|
|
const { widget } = service;
|
2022-09-25 16:15:47 -07:00
|
|
|
|
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");
|
2022-09-25 16:15:47 -07:00
|
|
|
|
2022-10-22 23:00:51 -07:00
|
|
|
if (appsError || appsData?.error || messagesError || messagesData?.error || clientsError || clientsData?.error) {
|
|
|
|
const finalError = appsError ?? appsData?.error ?? messagesError ?? messagesData?.error ?? clientsError ?? clientsData?.error;
|
|
|
|
return <Container error={finalError} />;
|
2022-09-25 16:15:47 -07:00
|
|
|
}
|
|
|
|
|
2022-09-29 21:15:25 -07:00
|
|
|
|
|
|
|
if (!appsData || !messagesData || !clientsData) {
|
|
|
|
return (
|
|
|
|
<Container service={service}>
|
|
|
|
<Block label="gotify.apps" />
|
|
|
|
<Block label="gotify.clients" />
|
|
|
|
<Block label="gotify.messages" />
|
|
|
|
</Container>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
2022-09-25 16:15:47 -07:00
|
|
|
return (
|
2022-09-29 21:15:25 -07:00
|
|
|
<Container service={service}>
|
|
|
|
<Block label="gotify.apps" value={appsData?.length} />
|
|
|
|
<Block label="gotify.clients" value={clientsData?.length} />
|
|
|
|
<Block label="gotify.messages" value={messagesData?.messages?.length} />
|
2022-09-26 15:25:10 +03:00
|
|
|
</Container>
|
2022-09-25 16:15:47 -07:00
|
|
|
);
|
|
|
|
}
|