From 71b3cc09710f63daa312d99d93907728b341ff60 Mon Sep 17 00:00:00 2001 From: ZeroWave022 <36341766+ZeroWave022@users.noreply.github.com> Date: Sun, 15 Sep 2024 16:46:59 +0200 Subject: [PATCH] feat: Add sorting to search params --- src/app/[locale]/(default)/storage/page.tsx | 39 ++++++---------- src/components/storage/CategorySelector.tsx | 1 - src/components/storage/SortSelector.tsx | 50 +++++++++++++++++++++ 3 files changed, 64 insertions(+), 26 deletions(-) create mode 100644 src/components/storage/SortSelector.tsx diff --git a/src/app/[locale]/(default)/storage/page.tsx b/src/app/[locale]/(default)/storage/page.tsx index 6fba8ca..f228ef7 100644 --- a/src/app/[locale]/(default)/storage/page.tsx +++ b/src/app/[locale]/(default)/storage/page.tsx @@ -8,13 +8,7 @@ import { ItemCard } from '@/components/storage/ItemCard'; import { Button } from '@/components/ui/Button'; import { Combobox } from '@/components/ui/Combobox'; import { SearchBar } from '@/components/ui/SearchBar'; -import { - Select, - SelectContent, - SelectItem, - SelectTrigger, - SelectValue, -} from '@/components/ui/Select'; + import { Tooltip, TooltipContent, @@ -25,6 +19,7 @@ import { ShoppingCart } from 'lucide-react'; import { Link } from '@/lib/navigation'; import { CategorySelector } from '@/components/storage/CategorySelector'; +import { SortSelector } from '@/components/storage/SortSelector'; export async function generateMetadata({ params: { locale }, @@ -78,11 +73,11 @@ export default function StoragePage({ ]; const filters = [ - 'select.popularity', - 'select.sortDescending', - 'select.sortAscending', - 'select.name', - ] as const; + { name: t('select.popularity'), urlName: 'popularity' }, + { name: t('select.sortDescending'), urlName: 'descending' }, + { name: t('select.sortAscending'), urlName: 'ascending' }, + { name: t('select.name'), urlName: 'name' }, + ]; return ( <> @@ -105,19 +100,13 @@ export default function StoragePage({
- - + { + const filterUrlName = filters.find((f) => f.name === value)?.urlName; + if (filterUrlName) { + setFilter(filterUrlName); + } + }} + > + + + + + {filters.map((filter) => ( + + {filter.name} + + ))} + + + ); +} +export { SortSelector };