Refator/sorts dropdown (#1568)
* WIP * Fixed lint * Ok for sorts * Fixed on dropdown toggle * Fix lint
This commit is contained in:
@@ -0,0 +1,16 @@
|
||||
import { SortOrder as Order_By } from '~/generated/graphql';
|
||||
|
||||
import { Sort } from '../types/Sort';
|
||||
|
||||
export const reduceSortsToOrderBy = (sorts: Sort[]): any[] =>
|
||||
sorts
|
||||
.map((sort) => {
|
||||
const direction = sort.direction === 'asc' ? Order_By.Asc : Order_By.Desc;
|
||||
|
||||
if (sort.definition.getOrderByTemplate) {
|
||||
return sort.definition.getOrderByTemplate(direction);
|
||||
} else {
|
||||
return [{ [sort.definition.key]: direction }];
|
||||
}
|
||||
})
|
||||
.flat();
|
||||
Reference in New Issue
Block a user