mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
9 lines
338 B
TypeScript
9 lines
338 B
TypeScript
export default function getSortParamsFromValue<SortValue extends string, SortField extends string, SortOrder extends string>(val?: SortValue) {
|
|
if (!val || val === 'default') {
|
|
return undefined;
|
|
}
|
|
|
|
const sortingChunks = val.split('-') as [ SortField, SortOrder ];
|
|
return { sort: sortingChunks[0], order: sortingChunks[1] };
|
|
}
|