-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Add categories to search params
- Loading branch information
1 parent
3644b18
commit 68ee11d
Showing
6 changed files
with
69 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
'use client'; | ||
import { useTranslations } from 'next-intl'; | ||
import { useQueryState } from 'nuqs'; | ||
import { createSearchParamsCache, parseAsString } from 'nuqs/parsers'; | ||
import { Combobox } from '../ui/Combobox'; | ||
|
||
type CategorySelectorProps = { | ||
categories: { | ||
value: string; | ||
label: string; | ||
}[]; | ||
t: { | ||
category: string; | ||
sort: string; | ||
defaultDescription: string; | ||
defaultPlaceholder: string; | ||
}; | ||
}; | ||
|
||
function CategorySelector({ categories, t }: CategorySelectorProps) { | ||
const [category, setCategory] = useQueryState( | ||
t.category, | ||
parseAsString.withDefault(''), | ||
); | ||
const [sort, setSort] = useQueryState(t.sort, parseAsString.withDefault('')); | ||
|
||
function valueCallback(category: string | null) { | ||
setCategory(category); | ||
} | ||
|
||
return ( | ||
<Combobox | ||
choices={categories} | ||
defaultDescription={t.defaultDescription} | ||
defaultPlaceholder={t.defaultPlaceholder} | ||
buttonClassName='w-full lg:w-[250px]' | ||
contentClassName='w-full lg:w-[200px]' | ||
valueCallback={valueCallback} | ||
/> | ||
); | ||
} | ||
|
||
export { CategorySelector }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters