Skip to content

Commit

Permalink
Modify FilterDropdown.tsx
Browse files Browse the repository at this point in the history
  • Loading branch information
Alberto-Ito authored Dec 15, 2024
1 parent f13a148 commit 9bbee73
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions src/components/Search/FilterDropdown.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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<Record<string, boolean>>(
filters.reduce(
Expand Down

0 comments on commit 9bbee73

Please sign in to comment.