diff --git a/apps/portal/src/components/questions/QuestionSearchBar.tsx b/apps/portal/src/components/questions/QuestionSearchBar.tsx index c5f401ea..69bb3ed5 100644 --- a/apps/portal/src/components/questions/QuestionSearchBar.tsx +++ b/apps/portal/src/components/questions/QuestionSearchBar.tsx @@ -4,29 +4,41 @@ import { } from '@heroicons/react/24/outline'; import { Button, Select, TextInput } from '@tih/ui'; -export type SortOption = { +export type SortOption = { label: string; - value: string; + value: Value; }; -export type QuestionSearchBarProps> = { - onFilterOptionsToggle: () => void; - onSortChange?: (sortValue: SortOptions[number]['value']) => void; - sortOptions: SortOptions; - sortValue: SortOptions[number]['value']; +type SortOrderProps = { + onSortOrderChange?: (sortValue: SortOrder) => void; + sortOrderOptions: ReadonlyArray>; + sortOrderValue: SortOrder; }; -export default function QuestionSearchBar< - SortOptions extends Array, ->({ - onSortChange, - sortOptions, - sortValue, +type SortTypeProps = { + onSortTypeChange?: (sortType: SortType) => void; + sortTypeOptions: ReadonlyArray>; + sortTypeValue: SortType; +}; + +export type QuestionSearchBarProps = + SortOrderProps & + SortTypeProps & { + onFilterOptionsToggle: () => void; + }; + +export default function QuestionSearchBar({ + onSortOrderChange, + sortOrderOptions, + sortOrderValue, + onSortTypeChange, + sortTypeOptions, + sortTypeValue, onFilterOptionsToggle, -}: QuestionSearchBarProps) { +}: QuestionSearchBarProps) { return ( -
-
+
+
-
- - Sort by: - - { + const chosenOption = sortTypeOptions.find( + (option) => String(option.value) === value, + ); + if (chosenOption) { + onSortTypeChange?.(chosenOption.value); + } + }} + /> +
+
+