diff --git a/src/components/routes/Servers/Search/Main.tsx b/src/components/routes/Servers/Search/Main.tsx index 32ce755..9be938e 100644 --- a/src/components/routes/Servers/Search/Main.tsx +++ b/src/components/routes/Servers/Search/Main.tsx @@ -209,6 +209,7 @@ function Main(): React.ReactElement { ); const [regionFilter, setRegionFilter] = React.useState(["all"]); + const [serverTypeFilter, setServerTypeFilter] = React.useState([]); const [gamemodeFilter, setGamemodeFilter] = React.useState([]); const [mapFilter, setMapFilter] = React.useState([]); const [playerFilter, setPlayerFilter] = React.useState([]); @@ -222,6 +223,7 @@ function Main(): React.ReactElement { setGamemodeFilter([]); setPlayerFilter([]); setMapFilter([]); + setServerTypeFilter([]); setRegionFilter([]); setIsPasswordProtected(""); setbf2042OwnerList([]); @@ -239,6 +241,7 @@ function Main(): React.ReactElement { const limitQuery = query.get("limit"); const typeQuery = query.get("searchtype"); const gamemodeQuery = query.get("gamemode"); + const serverTypeQuery = query.get("server_type"); const mapQuery = query.get("map"); const playerFilterQuery = query.get("player_filter"); const isPasswordProtectedQuery = query.get("is_password_protected"); @@ -249,6 +252,7 @@ function Main(): React.ReactElement { gameQuery !== null ? setGameName(gameQuery) : null; regionQuery !== null ? setRegionFilter(regionQuery.split(",")) : null; gamemodeQuery !== null ? setGamemodeFilter(gamemodeQuery.split(",")) : null; + serverTypeQuery !== null ? setServerTypeFilter(serverTypeQuery.split(",")) : null; playerFilterQuery !== null ? setPlayerFilter(playerFilterQuery.split(",")) : null; @@ -288,6 +292,9 @@ function Main(): React.ReactElement { playerFilter.length > 0 ? params.append("player_filter", playerFilter.join(",")) : params.delete("player_filter"); + serverTypeFilter.length > 0 + ? params.append("server_type", serverTypeFilter.join(",")) + : params.delete("server_type"); bf2042OwnerList.length > 0 ? params.append("bf2042_owner_list", JSON.stringify(bf2042OwnerList)) : params.delete("bf2042_owner_list"); @@ -307,6 +314,7 @@ function Main(): React.ReactElement { mapFilter, isPasswordProtected, playerFilter, + serverTypeFilter, bf2042OwnerList, platform, limit, @@ -319,6 +327,7 @@ function Main(): React.ReactElement { regionFilter.length > 0 || gamemodeFilter.length > 0 || playerFilter.length > 0 || + serverTypeFilter.length > 0 || mapFilter.length > 0 || isPasswordProtected != "" || bf2042OwnerList.length > 0 @@ -337,6 +346,9 @@ function Main(): React.ReactElement { if (playerFilter.length > 0) { extraQueries["player_filters"] = playerFilter.join(","); } + if (serverTypeFilter.length > 0) { + extraQueries["server_type_filters"] = serverTypeFilter.join(","); + } if (mapFilter.length > 0) { if (gameName === "bf2042") { extraQueries["maps"] = mapFilter.join(";"); @@ -374,13 +386,13 @@ function Main(): React.ReactElement { } = useQuery({ queryKey: [ "servers" + - gameName + - searchTerm + - searchType + - regionFilter + - platform + - limit + - JSON.stringify(extraQueries), + gameName + + searchTerm + + searchType + + regionFilter + + platform + + limit + + JSON.stringify(extraQueries), ], queryFn: () => GametoolsApi.serverSearch({ @@ -571,6 +583,54 @@ function Main(): React.ReactElement { innerStyle={{ maxHeight: width >= 1000 ? "600px" : "300px" }} >
+ {gameName == "bf1" && ( +
+

+ {t("serverSearch.serverTypeFilter")} + +

+ {!dropdownOpen["serverTypeFilter"] && + Object.keys( + t(`servers.${backendType}.serverTypeFilter`, { + returnObjects: true, + }), + ).map((key, index) => { + return ( + { + if (e.target.checked) { + setServerTypeFilter((oldArray) => [ + ...oldArray, + e.target.value, + ]); + } else { + setServerTypeFilter((oldArray) => [ + ...oldArray.filter( + (item) => item !== e.target.value, + ), + ]); + } + }} + name={t( + `servers.${backendType}.serverTypeFilter.${key}`, + )} + /> + ); + })} +
+ )} {gameName !== "bf3" && gameName !== "bfh" && (

@@ -844,12 +904,12 @@ export function ServerSearch(): React.ReactElement { } = useQuery({ queryKey: [ "servers" + - gameName + - searchTerm + - "servername" + - regionFilter + - platform + - "4", + gameName + + searchTerm + + "servername" + + regionFilter + + platform + + "4", ], queryFn: () => GametoolsApi.serverSearch({ diff --git a/src/locales/languages/en-US.json b/src/locales/languages/en-US.json index 7c26762..acea0f0 100644 --- a/src/locales/languages/en-US.json +++ b/src/locales/languages/en-US.json @@ -234,6 +234,7 @@ "platform": "platform", "gamemode": "Gamemode", "playerFilter": "Available space", + "serverTypeFilter": "Server type", "showFilters": "Show filters", "serverOwner": { "main": "Server owner", @@ -776,6 +777,12 @@ "sixtoten": "6-10", "tenplus": "10+", "none": "None" + }, + "serverTypeFilter": { + "official": "Official", + "ranked": "Ranked", + "unranked": "Unranked", + "private": "Private" } }, "battlelog": {