parent
8f3ae6d674
commit
f418ee6327
@ -1,26 +1,46 @@
|
|||||||
|
import { useTranslation } from "next-i18next";
|
||||||
|
|
||||||
import Container from "components/services/widget/container";
|
import Container from "components/services/widget/container";
|
||||||
import Block from "components/services/widget/block";
|
import Block from "components/services/widget/block";
|
||||||
import useWidgetAPI from "utils/proxy/use-widget-api";
|
import useWidgetAPI from "utils/proxy/use-widget-api";
|
||||||
|
|
||||||
export default function Component({ service }) {
|
export default function Component({ service }) {
|
||||||
const { widget } = service;
|
const { widget } = service;
|
||||||
const { data: serverData, error: serverError } = useWidgetAPI(widget, "status");
|
const { data: serverData, error: serverError } = useWidgetAPI(widget, "status");
|
||||||
if(serverError){
|
const { t } = useTranslation();
|
||||||
return <Container error={serverError} />;
|
|
||||||
}
|
if(serverError){
|
||||||
if (!serverData) {
|
return <Container error={serverError} />;
|
||||||
return (
|
}
|
||||||
<Container service={service}>
|
if (!serverData) {
|
||||||
<Block label="minecraft.players" />
|
return (
|
||||||
<Block label="minecraft.version" />
|
<Container service={service}>
|
||||||
</Container>
|
<Block label="minecraft.status"/>
|
||||||
);
|
<Block label="minecraft.players" />
|
||||||
}
|
<Block label="minecraft.version" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
const statusIndicator = serverData.online ?
|
||||||
<Container service={service}>
|
<span className="text-green-500">{t("minecraft.up")}</span>:
|
||||||
<Block label="minecraft.players" value={`${serverData.players.online} / ${serverData.players.max}`} />
|
<span className="text-red-500">{t("minecraft.down")}</span>;
|
||||||
<Block label="minecraft.version" value={serverData.version} />
|
|
||||||
</Container>
|
if(serverData.players){
|
||||||
);
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="minecraft.status" value={statusIndicator} />
|
||||||
|
<Block label="minecraft.players" value={`${serverData.players.online} / ${serverData.players.max}`} />
|
||||||
|
<Block label="minecraft.version" value={serverData.version} />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<Container service={service}>
|
||||||
|
<Block label="minecraft.status" value={statusIndicator} />
|
||||||
|
<Block label="minecraft.players" value="-" />
|
||||||
|
<Block label="minecraft.version" value="-" />
|
||||||
|
</Container>
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in new issue