Skip to content

Commit

Permalink
refactor: Use Select instead of DropdownMenu on storage page
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroWave022 committed Aug 25, 2024
1 parent bb5233d commit 5942aaa
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
"quantityInfo": "{quantity} units available",
"locationInfo": "Location: {location}"
},
"dropdown": {
"select": {
"filters": "Filters",
"buttonLabel": "Sort results",
"defaultPlaceholder": "Sort results",
"popularity": "Popularity",
"sortDescending": "Inventory (descending)",
"sortAscending": "Inventory (ascending)",
Expand Down
4 changes: 2 additions & 2 deletions messages/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,9 @@
"quantityInfo": "{quantity} stk. på lager",
"locationInfo": "Hylleplass: {location}"
},
"dropdown": {
"select": {
"filters": "Filtre",
"buttonLabel": "Sorter resultater",
"defaultPlaceholder": "Sorter resultater",
"popularity": "Popularitet",
"sortDescending": "Lagerbeholdning (synkende)",
"sortAscending": "Lagerbeholdning (stigende)",
Expand Down
50 changes: 25 additions & 25 deletions src/app/[locale]/(default)/storage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import Image from 'next/image';
import { createSearchParamsCache, parseAsInteger } from 'nuqs/parsers';

import { PaginationCarousel } from '@/components/layout/PaginationCarousel';
import { Button } from '@/components/ui/Button';
import {
Card,
CardContent,
Expand All @@ -15,15 +14,14 @@ import {
CardTitle,
} from '@/components/ui/Card';
import { Combobox } from '@/components/ui/Combobox';
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@/components/ui/DropdownMenu';
import { SearchBar } from '@/components/ui/SearchBar';
import {
Select,
SelectContent,
SelectItem,
SelectTrigger,
SelectValue,
} from '@/components/ui/Select';

export async function generateMetadata({
params: { locale },
Expand Down Expand Up @@ -77,34 +75,36 @@ export default function StoragePage({
];

const filters = [
'dropdown.popularity',
'dropdown.sortDescending',
'dropdown.sortAscending',
'dropdown.name',
'select.popularity',
'select.sortDescending',
'select.sortAscending',
'select.name',
] as const;

return (
<>
<h1>{t('title')}</h1>
<div className='my-4 flex justify-center gap-2'>
<SearchBar className='max-w-2xl' />
<DropdownMenu>
<DropdownMenuTrigger asChild>
<Button>{t('dropdown.buttonLabel')}</Button>
</DropdownMenuTrigger>
<DropdownMenuContent>
<DropdownMenuLabel>{t('dropdown.filters')}</DropdownMenuLabel>
<DropdownMenuSeparator />
<div className='my-4 flex flex-col justify-center gap-2 lg:flex-row'>
<SearchBar className='lg:max-w-2xl' />
<Select>
<SelectTrigger className='w-full lg:w-[250px]'>
<SelectValue placeholder={t('select.defaultPlaceholder')} />
</SelectTrigger>
<SelectContent>
{filters.map((filter) => (
<DropdownMenuItem key={filter}>{t(filter)}</DropdownMenuItem>
<SelectItem key={filter} value={filter}>
{t(filter)}
</SelectItem>
))}
</DropdownMenuContent>
</DropdownMenu>
</SelectContent>
</Select>

<Combobox
choices={categories}
defaultDescription={t('combobox.defaultDescription')}
defaultPlaceholder={t('combobox.defaultPlaceholder')}
buttonClassName='w-full lg:w-[250px]'
contentClassName='w-full lg:w-[200px]'
/>
</div>
<div className='grid grid-cols-1 gap-3 sm:grid-cols-2 md:grid-cols-3 lg:grid-cols-4'>
Expand Down

0 comments on commit 5942aaa

Please sign in to comment.