From f395b207f8ed3025cb0da765569f8bac1c27f120 Mon Sep 17 00:00:00 2001 From: carmennt Date: Fri, 9 Oct 2026 11:26:39 +0200 Subject: [PATCH 01/29] feat: sorting and filter by genre Not done yet, but the sorting and filter buttons are in place. --- src/css/searchpage.css | 2 +- src/pages/searchpage.tsx | 88 ++++++++++++++++++++++++---------------- 2 files changed, 54 insertions(+), 36 deletions(-) diff --git a/src/css/searchpage.css b/src/css/searchpage.css index a1ebca4..7853929 100644 --- a/src/css/searchpage.css +++ b/src/css/searchpage.css @@ -25,7 +25,7 @@ } .filterbutton { - background-color: var(--primary-component-color); + background-color: var(--primary-background-color); border: 1px solid var(--primary-accent-color); border-left: 0; border-radius: 0 4px 4px 0; diff --git a/src/pages/searchpage.tsx b/src/pages/searchpage.tsx index 1a6f30e..f4d3258 100644 --- a/src/pages/searchpage.tsx +++ b/src/pages/searchpage.tsx @@ -1,27 +1,35 @@ import '../css/searchpage.css' import Header from '../components/header' import Footer from '../components/footer' -import { TextField, Button, ButtonGroup } from '@mui/material' +import { TextField, InputLabel, FormControl, Select, MenuItem } from '@mui/material' import { Funnel } from 'lucide-react' import { useState } from 'react' import PageHeading from '../components/pageheading' +import type { SelectChangeEvent } from '@mui/material' export function SearchPage() { const [isFilterActive, setIsFilterActive] = useState(false) - const [activeSortingButton, setActiveSortingButton] = useState(null) - const [activeFilterButton, setActiveFilterButton] = useState(null) + const [activeFilters, setActiveFilters] = useState([]) + const [activeSorting, setActiveSorting] = useState('') - const sortingbuttons = ['Sorting', 'Sorting', 'Sorting'] - const filterbuttons = ['Filter', 'Filter', 'Filter'] + type SortOption = 'no-sorting' | 'discount-asc' | 'price-asc' | 'price-desc' | 'title-asc' + + + // TODO: Need to get all genres from the database + const filterbuttons = ['Multiplayer', 'Singleplayer', 'Stratergy', 'Action', 'Aventure'] const toggleActive = () => setIsFilterActive((isActive) => !isActive) - const toggleSortingButton = (index: number) => { - setActiveSortingButton((activeIndex) => (activeIndex === index ? null : index)) + const handleSortChange = (e: SelectChangeEvent) => { + setActiveSorting(e.target.value as SortOption) } - const toggleFilterButton = (index: number) => { - setActiveFilterButton((activeIndex) => (activeIndex === index ? null : index)) + const handleFilterChange = (e: SelectChangeEvent) => { + const { value } = e.target + setActiveFilters(typeof value === 'string' ? value.split(',') : value) } + // TODO: Sorting functionallity + + return (
@@ -42,33 +50,43 @@ export function SearchPage() { {isFilterActive && (
- -

Sort by:

- {sortingbuttons.map((button, index) => ( - - ))} -
+ + Sort by + + - -

Filter by:

- {filterbuttons.map((button, index) => ( - - ))} -
+ + Filter by genre + +
)}