Skip to content

Commit

Permalink
fix: sorting menu hrefs
Browse files Browse the repository at this point in the history
  • Loading branch information
andyesp committed Apr 25, 2024
1 parent 898657b commit f3de8cc
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/components/Search/SortingMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { getUrlFilters } from '../../helpers'
import useFormatMessage from '../../hooks/useFormatMessage'
import useURLSearchParams from '../../hooks/useURLSearchParams'
import { SortingOrder } from '../../types/proposals'
import locations from '../../utils/locations'
import { toSortingOrder } from '../../utils/proposal'

import './SortingMenu.css'
Expand All @@ -18,7 +19,9 @@ export default function SortingMenu() {
const navigate = useNavigate()
const params = useURLSearchParams()
const isSearching = !!params.get('search')
const order = toSortingOrder(params.get('order'), () => (isSearching ? 'RELEVANCE' : SortingOrder.DESC))
const order: SortingOrder | 'RELEVANCE' = toSortingOrder(params.get('order'), () =>
isSearching ? 'RELEVANCE' : SortingOrder.DESC
)
const arrowDirection = order === SortingOrder.ASC ? 'Upwards' : 'Downwards'
const isMobile = useMobileMediaQuery()

Expand All @@ -34,16 +37,16 @@ export default function SortingMenu() {
{isSearching && (
<Dropdown.Item
text={t('navigation.search.sorting.RELEVANCE')}
onClick={() => navigate(getUrlFilters(SORT_KEY, params, undefined))}
onClick={() => navigate(locations.proposals(getUrlFilters(SORT_KEY, params, undefined)))}
/>
)}
<Dropdown.Item
text={t('navigation.search.sorting.DESC')}
onClick={() => navigate(getUrlFilters(SORT_KEY, params, SortingOrder.DESC))}
onClick={() => navigate(locations.proposals(getUrlFilters(SORT_KEY, params, SortingOrder.DESC)))}
/>
<Dropdown.Item
text={t('navigation.search.sorting.ASC')}
onClick={() => navigate(getUrlFilters(SORT_KEY, params, SortingOrder.ASC))}
onClick={() => navigate(locations.proposals(getUrlFilters(SORT_KEY, params, SortingOrder.ASC)))}
/>
</Dropdown.Menu>
</Dropdown>
Expand Down

0 comments on commit f3de8cc

Please sign in to comment.