Skip to content

Commit

Permalink
feat: Add filters, move categories on storage page
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeroWave022 committed Aug 22, 2024
1 parent 06cf66d commit 03cc504
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 16 deletions.
16 changes: 12 additions & 4 deletions messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@
"quantityInfo": "{quantity} units available",
"locationInfo": "Location: {location}"
},
"combobox": {
"dropdown": {
"filters": "Filters",
"buttonLabel": "Sort results",
"popularity": "Popularity",
"sortDescending": "Inventory (descending)",
"sortAscending": "Inventory (ascending)",
"name": "Name (in alphabetical order)",
"defaultDescription": "Choose sorting...",
"defaultPlaceholder": "Search filters..."
"name": "Name (in alphabetical order)"
},
"combobox": {
"defaultDescription": "Choose category...",
"defaultPlaceholder": "Search category...",
"cables": "Cables",
"sensors": "Sensors",
"peripherals": "PC peripherals",
"miniPC": "Mini PC"
}
}
}
16 changes: 12 additions & 4 deletions messages/no.json
Original file line number Diff line number Diff line change
Expand Up @@ -56,13 +56,21 @@
"quantityInfo": "{quantity} stk. på lager",
"locationInfo": "Hylleplass: {location}"
},
"combobox": {
"dropdown": {
"filters": "Filtre",
"buttonLabel": "Sorter resultater",
"popularity": "Popularitet",
"sortDescending": "Lagerbeholdning (synkende)",
"sortAscending": "Lagerbeholdning (stigende)",
"name": "Navn (alfabetisk)",
"defaultDescription": "Velg sortering...",
"defaultPlaceholder": "Søk etter filtere..."
"name": "Navn (alfabetisk)"
},
"combobox": {
"defaultDescription": "Velg kategori...",
"defaultPlaceholder": "Søk etter kategori...",
"cables": "Cables",
"sensors": "Sensors",
"peripherals": "PC peripherals",
"miniPC": "Mini PC"
}
}
}
46 changes: 38 additions & 8 deletions src/app/[locale]/(default)/storage/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ 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 @@ -14,6 +15,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';

export async function generateMetadata({
Expand Down Expand Up @@ -49,27 +58,48 @@ export default function StoragePage({

const categories = [
{
value: 'popularity',
label: t('combobox.popularity'),
value: 'cables',
label: t('combobox.cables'),
},
{
value: 'sortDescending',
label: t('combobox.sortDescending'),
value: 'sensors',
label: t('combobox.sensors'),
},
{
value: 'sortAscending',
label: t('combobox.sortAscending'),
value: 'peripherals',
label: t('combobox.peripherals'),
},
{
value: 'name',
label: t('combobox.name'),
value: 'miniPC',
label: t('combobox.miniPC'),
},
];

const filters = [
'dropdown.popularity',
'dropdown.sortDescending',
'dropdown.sortAscending',
'dropdown.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 />
{filters.map((filter) => (
<DropdownMenuItem key={filter}>{t(filter)}</DropdownMenuItem>
))}
</DropdownMenuContent>
</DropdownMenu>

<Combobox
choices={categories}
defaultDescription={t('combobox.defaultDescription')}
Expand Down

0 comments on commit 03cc504

Please sign in to comment.