Added status field for GameDig widget

pull/1789/head
fredodiable 1 year ago committed by shamoon
parent 5611baa0b8
commit 70ea5ad60d

@ -685,6 +685,9 @@
"approved": "Approved"
},
"gamedig": {
"status": "Status",
"online": "Online",
"offline": "Offline",
"name": "Name",
"map": "Map",
"currentPlayers": "Current players",

@ -26,6 +26,7 @@ export default function Component({ service }) {
if (!serverData) {
return (
<Container service={service}>
<Block label="gamedig.status"/>
<Block label="gamedig.name"/>
<Block label="gamedig.map"/>
<Block label="gamedig.currentPlayers" />
@ -37,23 +38,25 @@ export default function Component({ service }) {
);
}
const status = serverData.online ? <span className="text-green-500">{t("gamedig.online")}</span> : <span className="text-red-500">{t("gamedig.offline")}</span>;
const name = serverData.online ? serverData.name : "-";
const map = serverData.online ? serverData.map : "-";
const currentPlayers = serverData.online ? `${serverData.players} / ${serverData.maxplayers}` : "-";
const players = serverData.online ? `${serverData.players}` : "-";
const maxPlayers = serverData.online ? `${serverData.maxplayers}` : "-";
const bots = serverData.online ? `${serverData.bots}` : "-";
const ping = serverData.online ? `${serverData.ping}` : 0;
const ping = serverData.online ? `${t("common.ms", { value: serverData.ping, style: "unit", unit: "millisecond" })}` : "-";
return (
<Container service={service}>
<Block label="gamedig.status" value={status} />
<Block label="gamedig.name" value={name} />
<Block label="gamedig.map" value={map} />
<Block label="gamedig.currentPlayers" value={currentPlayers} />
<Block label="gamedig.players" value={players} />
<Block label="gamedig.maxPlayers" value={maxPlayers} />
<Block label="gamedig.bots" value={bots} />
<Block label="gamedig.ping" value={t("common.ms", { value: ping, style: "unit", unit: "millisecond" })} />
<Block label="gamedig.ping" value={ping} />
</Container>
);
}

Loading…
Cancel
Save