mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
* 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
15 lines
460 B
TypeScript
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;
|
|
}
|
|
}
|