diff --git a/src/api/GametoolsApi.tsx b/src/api/GametoolsApi.tsx index 3674b2a..dc21e19 100644 --- a/src/api/GametoolsApi.tsx +++ b/src/api/GametoolsApi.tsx @@ -7,6 +7,7 @@ import { PlaygroundInfoReturn, seederPlayersReturn, ServerLeaderboardReturn, + ServerList, ServerOwnerResult, ServerPlayersReturn, ServerSearch, @@ -249,6 +250,31 @@ export class ApiProvider extends JsonClient { }); } + async currentServer({ + game, + playerId, + lang, + platform = "pc", + }: { + game: string; + playerId: number; + lang: string, + platform: string; + }): Promise<{ + [playerId: number]: ServerList; + apiUrl: string; + cache: boolean; + } | undefined> { + if (!newTitles.includes(game)) { + return undefined; + } + return await this.getJsonMethod(`/manager/currentserver/${game}`, { + platform: platform, + lang: lang, + player_ids: playerId.toString(), + }); + } + async sus({ game, playerId, diff --git a/src/components/routes/Servers/Search/Results.tsx b/src/components/routes/Servers/Search/Results.tsx index d6c1db5..2d0d3c9 100644 --- a/src/components/routes/Servers/Search/Results.tsx +++ b/src/components/routes/Servers/Search/Results.tsx @@ -139,9 +139,8 @@ export function Results(props: Views): React.ReactElement { ): React.ReactElement { stats={props.stats} /> + ); } + +function CurrentServer(props: Readonly) { + const { t } = useTranslation(); + + const { + isError, + isLoading, + error, + data: stats, + } = useQuery({ + queryKey: ["managerCurrentServer" + props?.stats?.id], + queryFn: () => + GametoolsApi.currentServer({ + game: props.game, + lang: getLanguage(), + platform: props.platform, + playerId: props?.stats?.id, + }), + }); + + + if (isError) { + return ( +
+

{t("stats.adminPanel.currentServer")}

+ +

{t("stats.error", { error: error })}

+
+
+ ); + } + + if (isLoading || stats === undefined) { + return ( +
+

{t("stats.adminPanel.currentServer")}

+ +

{t("loading")}

+
+
+ ); + } + + let key = stats[props?.stats?.id]; + + return ( +
+

{t("stats.adminPanel.currentServer")}

+ +
+ ) +} \ No newline at end of file diff --git a/src/components/routes/platoons/Platoon.tsx b/src/components/routes/platoons/Platoon.tsx index fb68682..492133b 100644 --- a/src/components/routes/platoons/Platoon.tsx +++ b/src/components/routes/platoons/Platoon.tsx @@ -17,6 +17,7 @@ import sslFix from "../../functions/fixEaAssets"; import useExternalScript from "../../functions/UseExternalScript"; import { BackButton, Box, ConLink } from "../../Materials"; import * as styles from "./Platoon.module.scss"; +import { Results as ServerResults } from "../Servers/Search/Results"; interface Views { loading: boolean; @@ -155,7 +156,7 @@ function Member(props: { className={styles.memberImage} src={sslFix( item?.avatar || - "https://secure.download.dm.origin.com/production/avatar/prod/1/599/208x208.JPEG", + "https://secure.download.dm.origin.com/production/avatar/prod/1/599/208x208.JPEG", )} loading="lazy" /> @@ -262,141 +263,41 @@ function Members(props: {
{props.loading ? [...Array(6)].map((key) => ( - - <>  - - )) + + <>  + + )) : members.map((key: PlatoonPlayer, index: number) => ( - - - - ))} + + + + ))}
); } -const handleChildElementClick = (e: { stopPropagation: () => void }) => { - e.stopPropagation(); - // Do other stuff here -}; - -function Servers(props: { servers: ServerList[] }): React.ReactElement { - const { t } = useTranslation(); - const servers = props.servers; - if (servers?.length <= 0) { - return ( -
-

{t("platoon.servers")}

-

{t("resultNotFound")}

-
- ); - } - return ( -
-
-

- {t("platoon.servers")} -

-

- - - https://joinme.click/download - - -

-
- {servers?.map((key: ServerList, index: number) => { - let queue: number = undefined; - queue = key.inQue; - let queueString = ""; - if (queue !== undefined && queue !== 0) { - queueString = `[${queue}]`; - } - let region: string = undefined; - if (key.region !== undefined) { - region = ` - ${t(`regions.${key.region.toLowerCase()}`)}`; - } - let officialString = ""; - if (key.official !== undefined) { - officialString = key.official - ? ` - ${t("serverType.official")}` - : ` - ${t("serverType.custom")}`; - } - return ( - -
-
-
-
-

{key.smallMode}

-
-
-
-
-

- {key.server} - {key.prefix} -

-

- {key.playerAmount}/{key.maxPlayers} - {key.maxPlayerAmount} {queueString} - {key.mode} - {key.mode === undefined ? key.map : null} - {officialString} - {region} -

-
- handleChildElementClick(e)} - href={`bf1://${key.gameId}`} - style={{ alignSelf: "end" }} - > - - -
-
- ); - })} -
- ); -} - function Results(props: Views): React.ReactElement { const { t } = useTranslation(); const platoon = props.platoon; - document.title = `${t("siteFullName")} ${t("pageTitle.platoon")} | ${ - platoon?.name || t("loading") - }`; + document.title = `${t("siteFullName")} ${t("pageTitle.platoon")} | ${platoon?.name || t("loading") + }`; const ConditionalLink = ({ children, to, condition }: ConLink) => !!condition && to ? {children} : <>{children}; @@ -461,7 +362,21 @@ function Results(props: Views): React.ReactElement { />
- +
+
+

+ {t("platoon.servers")} +

+

+ + + https://joinme.click/download + + +

+
+ +
diff --git a/src/locales/languages/en-US.json b/src/locales/languages/en-US.json index acea0f0..621cfe8 100644 --- a/src/locales/languages/en-US.json +++ b/src/locales/languages/en-US.json @@ -276,6 +276,7 @@ "searchGadget": "Search for gadget", "missingGame": "Current player doesn't have this game", "adminPanel": { + "currentServer": "Current server", "main": "Admin panel", "susWeapons": "Sus weapons", "bannedServer": {