From 9bbee734e87c5a5a6802b938579c49e43390a688 Mon Sep 17 00:00:00 2001 From: Alberto Ito <95650418+Alberto-Ito@users.noreply.github.com> Date: Sun, 15 Dec 2024 17:08:51 -0300 Subject: [PATCH] Modify FilterDropdown.tsx --- src/components/Search/FilterDropdown.tsx | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/components/Search/FilterDropdown.tsx b/src/components/Search/FilterDropdown.tsx index 5546876c..e1459cdb 100644 --- a/src/components/Search/FilterDropdown.tsx +++ b/src/components/Search/FilterDropdown.tsx @@ -15,18 +15,21 @@ import { APPLICATION_COMPATIBILITY, GAME_AUTO_SR, GAME_COMPATIBILITY } from "../ import { t } from "i18next"; import { updateLanguage } from "../../util/updateLanguage"; -const _ = updateLanguage(window.location); type FilterKey = "auto_super_resolution.compatibility" | "category" | "compatibility"; -const gameFilters: { key: FilterKey; name: string }[] = [ - { key: "auto_super_resolution.compatibility", name: t('game_filters.auto_sr') }, - { key: "category", name: t('game_filters.category') }, - { key: "compatibility", name: t('game_filters.compatibility') } -]; +function getGameFilters(): { key: FilterKey; name: string }[] { + return [ + { key: "auto_super_resolution.compatibility", name: t('game_filters.auto_sr') }, + { key: "category", name: t('game_filters.category') }, + { key: "compatibility", name: t('game_filters.compatibility') } + ]; +} -const applicationFilters: { key: FilterKey; name: string }[] = [ - { key: "category", name: t('application_filters.category')}, -]; +function getApplicationFilters(): { key: FilterKey; name: string }[] { + return [ + { key: "category", name: t('application_filters.category') }, + ]; +} const FilterDropdown = ({ search, @@ -40,7 +43,8 @@ const FilterDropdown = ({ categories: CollectionEntry<"games_categories" | "applications_categories">[]; }) => { - const filters = type === "applications" ? applicationFilters : gameFilters; + const _ = updateLanguage(window.location); + const filters = type === "applications" ? getApplicationFilters() : getGameFilters(); const [showFilters, setShowFilters] = createSignal>( filters.reduce(