diff --git a/src/api/ReturnTypes.tsx b/src/api/ReturnTypes.tsx index 4a74c29..e9b0ad7 100644 --- a/src/api/ReturnTypes.tsx +++ b/src/api/ReturnTypes.tsx @@ -273,7 +273,7 @@ export type ServerLeaderboardList = { }; export type ServerPlayersReturn = { - apiUrl: string; + apiUrl?: string; teams: serverTeamList[]; loading: serverPlayer[]; que: serverPlayer[]; @@ -371,14 +371,14 @@ export type serverTeamList = { }; export type serverPlayer = { - player_id: number; - user_id: number; + player_id?: number; + user_id?: number; name: string; - position: number; + position?: number; latency?: number; - platoon: string; - join_time: number; - localization: string; + platoon?: string; + join_time?: number; + localization?: string; platform?: string; rank?: number; diff --git a/src/api/marneApi.tsx b/src/api/marneApi.tsx index c0c81ca..14a4921 100644 --- a/src/api/marneApi.tsx +++ b/src/api/marneApi.tsx @@ -354,7 +354,7 @@ export class ApiProvider extends JsonClient { settings: result?.settings, description: result?.description, rotation: - result?.rotation == "" + result?.rotation === "" ? [] : result?.rotation?.map((current: RotationReturn, index: number) => { if (current !== null) { diff --git a/src/components/routes/Servers/Detailed/Main.tsx b/src/components/routes/Servers/Detailed/Main.tsx index 4f1aafd..5664117 100644 --- a/src/components/routes/Servers/Detailed/Main.tsx +++ b/src/components/routes/Servers/Detailed/Main.tsx @@ -31,6 +31,7 @@ import { Bf3ServerPlayerlist, BfListServerPlayerList, ServerPlayerlist, + MarnePlayerList, } from "./Players"; import { ServerLeaderboard } from "./Leaderboard"; import { ServerPlatoon } from "./Platoon"; @@ -426,7 +427,12 @@ export function Results(props: Views): React.ReactElement { /> ) : ( props.game === "bf1marne" && ( - + + // ) )} diff --git a/src/components/routes/Servers/Detailed/Players.tsx b/src/components/routes/Servers/Detailed/Players.tsx index 2eb8467..8da025d 100644 --- a/src/components/routes/Servers/Detailed/Players.tsx +++ b/src/components/routes/Servers/Detailed/Players.tsx @@ -108,7 +108,7 @@ function Players(props: { teams.forEach((teamInfo: serverTeamList) => { playerIds = playerIds.concat( teamInfo.players.map((player) => { - return player.player_id.toString(); + return player?.player_id?.toString(); }), ); }); @@ -200,7 +200,7 @@ function Players(props: {

- {teamInfo.faction in factions + {teamInfo?.faction in factions ? t(`servers.factions.${teamInfo.faction}`) : t(`servers.factions.${teamInfo.teamid}`)}

@@ -211,14 +211,13 @@ function Players(props: { {teamInfo.players.map( (key: serverPlayer, index: number) => { const seederPlayer = seederPlayers.get(key.player_id); - const dateAdded = new Date(key.join_time / 1000); return ( - {props.game !== "bf2042" && ( + {key?.rank && ( @@ -253,7 +252,7 @@ function Players(props: { - {props.game !== "bf2042" ? ( - -

- {key.latency} -

- - {t("servers.playerlist.row.ping")} - -
- ) : ( + {props.game === "bf2042" ? (

{key.platform.toUpperCase()} @@ -280,6 +270,17 @@ function Players(props: { {t("servers.playerlist.row.platform")} + ) : ( + props.game !== "bf1marne" && ( + +

+ {key.latency} +

+ + {t("servers.playerlist.row.ping")} + +
+ ) )} {haveSeederPlayers && ( <> @@ -303,14 +304,18 @@ function Players(props: { )} -

- {t("change", { - change: dateAdded, - })} -

- - {t("servers.playerlist.row.timePlayed")} - + {key.join_time && ( + <> +

+ {t("change", { + change: new Date(key?.join_time / 1000), + })} +

+ + {t("servers.playerlist.row.timePlayed")} + + + )}
{ + stats.teams[element.team - 1].players.push(element); + }); + + return ( + + ); +} + export function Bf3ServerPlayerlist(props: { players: ScoreServerPlayer[]; game: string; @@ -617,31 +658,6 @@ export function BfListServerPlayerList(props: { {t("servers.playerlist.row.killDeath")} - {/* - - {t("stats.view")} - - */} ); })}