-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use item lang instead of category lang (#712)
* feat: use item lang instead of category lang * refactor: fix tests * refactor: apply PR requested changes
- Loading branch information
Showing
21 changed files
with
418 additions
and
348 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
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,46 @@ | ||
import React from 'react'; | ||
|
||
import { Category } from '@graasp/sdk'; | ||
|
||
import { useCategoriesTranslation } from '../../config/i18n'; | ||
import { | ||
buildSearchFilterCategoryId, | ||
buildSearchFilterPopperButtonId, | ||
} from '../../config/selectors'; | ||
import { Filter, FilterProps } from './Filter'; | ||
|
||
type CategoryFilterProps = { | ||
category: string; | ||
title: string; | ||
options?: Category[]; | ||
selectedOptionIds: FilterProps['selectedOptionIds']; | ||
onOptionChange: (key: string, newValue: boolean) => void; | ||
onClearOptions: () => void; | ||
isLoading: boolean; | ||
}; | ||
|
||
// eslint-disable-next-line react/function-component-definition | ||
export function CategoryFilter({ | ||
category, | ||
title, | ||
onOptionChange, | ||
onClearOptions, | ||
options, | ||
selectedOptionIds, | ||
isLoading, | ||
}: CategoryFilterProps) { | ||
const { t: translateCategories } = useCategoriesTranslation(); | ||
|
||
return ( | ||
<Filter | ||
id={buildSearchFilterCategoryId(category)} | ||
buttonId={buildSearchFilterPopperButtonId(category)} | ||
title={title} | ||
isLoading={isLoading} | ||
options={options?.map((c) => [c.id, translateCategories(c.name)])} | ||
selectedOptionIds={selectedOptionIds} | ||
onOptionChange={onOptionChange} | ||
onClearOptions={onClearOptions} | ||
/> | ||
); | ||
} |
Oops, something went wrong.