diff --git a/apps/portal/src/components/questions/ContributeQuestionCard.tsx b/apps/portal/src/components/questions/ContributeQuestionCard.tsx index be050d96..7ffa2b2a 100644 --- a/apps/portal/src/components/questions/ContributeQuestionCard.tsx +++ b/apps/portal/src/components/questions/ContributeQuestionCard.tsx @@ -1,5 +1,4 @@ import { useState } from 'react'; -import { TextInput } from '@tih/ui'; import { useProtectedCallback } from '~/utils/questions/useProtectedCallback'; @@ -27,22 +26,13 @@ export default function ContributeQuestionCard({ return (
void; @@ -13,6 +16,22 @@ export type QuestionSearchBarProps = SortOptionsSelectProps & { query: string; }; +function getSortOrderLabel(sortOrder: SortOrder, sortType: SortType): string { + switch (sortType) { + case SortType.NEW: + return sortOrder === SortOrder.ASC ? 'Oldest first' : 'Newest first'; + case SortType.TOP: + return sortOrder === SortOrder.ASC + ? 'Least upvotes first' + : 'Most upvotes first'; + case SortType.ENCOUNTERS: + return sortOrder === SortOrder.ASC + ? 'Least received first' + : 'Most received first'; + } + return ''; +} + export default function QuestionSearchBar({ onFilterOptionsToggle, onQueryChange, @@ -20,43 +39,74 @@ export default function QuestionSearchBar({ ...sortOptionsSelectProps }: QuestionSearchBarProps) { return ( -
-
-
- { - onQueryChange(value); - }} - /> -
-
-
-
-
+
+
+ {/* */}
-
- +
+
+ +
+
+
+ { + const newLabel = getSortOrderLabel( + option.value, + sortOptionsSelectProps.sortTypeValue, + ); + + return { + ...option, + label: newLabel, + }; + }, + )} + value={sortOptionsSelectProps.sortOrderValue} + onChange={sortOptionsSelectProps.onSortOrderChange} + /> +
); diff --git a/apps/portal/src/components/questions/SortOptionsSelect.tsx b/apps/portal/src/components/questions/SortOptionsSelect.tsx index 9a9efb64..14e2d841 100644 --- a/apps/portal/src/components/questions/SortOptionsSelect.tsx +++ b/apps/portal/src/components/questions/SortOptionsSelect.tsx @@ -35,7 +35,7 @@ export default function SortOptionsSelect({ const sortOrders = sortOrderOptions ?? SORT_ORDERS; return ( -
+