33 lines
1.0 KiB
React
33 lines
1.0 KiB
React
import { useTranslation } from "next-i18next";
|
|
|
|
import Container from "components/services/widget/container";
|
|
import Block from "components/services/widget/block";
|
|
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="yourwidget.key1" />
|
|
<Block label="yourwidget.key2" />
|
|
<Block label="yourwidget.key3" />
|
|
</Container>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<Container service={service}>
|
|
<Block label="yourwidget.key1" value={t("common.number", { value: data.key1 })} />
|
|
<Block label="yourwidget.key2" value={t("common.number", { value: data.key2 })} />
|
|
<Block label="yourwidget.key3" value={t("common.number", { value: data.key3 })} />
|
|
</Container>
|
|
);
|
|
} |