Files
explore/ui/shared/sort/getSortValueFromQuery.ts
T
tom goriunovandGitHub c802f0b5ed Replace system selectors with Blockscout selectors style (#2451)
* migrate from native select to the custom one

* migrate popover radio filter to select component

* migrate stats menu to select

* migrate Sort component

* screenshot updates
2024-12-13 14:42:21 +01:00

15 lines
460 B
TypeScript

import type { SelectOption } from 'ui/shared/select/types';
import type { Query } from 'nextjs-routes';
export default function getSortValueFromQuery<SortValue extends string>(query: Query, sortOptions: Array<SelectOption<SortValue>>) {
if (!query.sort || !query.order) {
return undefined;
}
const str = query.sort + '-' + query.order;
if (sortOptions.map(option => option.value).includes(str as SortValue)) {
return str as SortValue;
}
}